diff options
Diffstat (limited to 'share/functions/__fish_complete_man.fish')
-rw-r--r-- | share/functions/__fish_complete_man.fish | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/share/functions/__fish_complete_man.fish b/share/functions/__fish_complete_man.fish new file mode 100644 index 00000000..fa116956 --- /dev/null +++ b/share/functions/__fish_complete_man.fish @@ -0,0 +1,27 @@ + +function __fish_complete_man + if test (commandline -ct) + + # Try to guess what section to search in. If we don't know, we + # use [^)]*, which should match any section + + set section "" + set prev (commandline -poc) + set -e prev[1] + while count $prev + switch $prev[1] + case '-**' + + case '*' + set section $prev[1] + end + set -e prev[1] + end + + set section $section"[^)]*" + + # Do the actual search + apropos (commandline -ct) | grep \^(commandline -ct) | sed -n -e 's/\([^ ]*\).*(\('$section'\)) *- */\1\t\2: /p' + end +end + |