[zsh] save the real "man" command to history when F1 is pressed

This commit is contained in:
Dmytro Meleshko 2020-09-14 17:45:20 +03:00
parent 8c65e3b5a3
commit 90c01434ef
3 changed files with 9 additions and 4 deletions

4
scripts/fzf-search-manpage Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env sh
set -eu
# https://superuser.com/a/207474
apropos . | fzf --no-multi --tiebreak=begin --query="$*" | sed -n 's/^\([^ ]\+\) \?(\([^)]\+\)).*$/\2 \1/p'

View File

@ -1,4 +1,3 @@
#!/bin/sh
#!/usr/bin/env sh
# https://superuser.com/a/207474
man $(apropos . | fzf --no-multi --tiebreak=begin --query="$*" | sed -n 's/^\([^ ]\+\) \?(\([^)]\+\)).*$/\2 \1/p')
man $(fzf-search-manpage)

View File

@ -154,7 +154,9 @@
local words=("${(@z)BUFFER}")
local cmd_name="${words[1]}"
zle push-line
BUFFER="visman ${(q)cmd_name}"
local manpage=""
manpage="$(fzf-search-manpage "$cmd_name")"
BUFFER="man $manpage"
zle accept-line
}
zle -N find-man-page _widget_find_man_page