diff options
author | Fabian Homborg <FHomborg@gmail.com> | 2016-05-29 14:31:12 +0200 |
---|---|---|
committer | Fabian Homborg <FHomborg@gmail.com> | 2016-05-29 14:31:12 +0200 |
commit | ebde55f7047aa56ce69bf33ce8fb62c7e9f2a37d (patch) | |
tree | 026a5e7e3ac5c7033bcafe8efcbe5fccdeca0aea /share | |
parent | f23464001f40a52f2a7aa84a9c16c0fed3e3c3ca (diff) |
Man completions: Show all pages for a section
If one is given, of course.
Diffstat (limited to 'share')
-rw-r--r-- | share/functions/__fish_complete_man.fish | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/share/functions/__fish_complete_man.fish b/share/functions/__fish_complete_man.fish index 1bdaa5c6..7306dd2c 100644 --- a/share/functions/__fish_complete_man.fish +++ b/share/functions/__fish_complete_man.fish @@ -1,27 +1,33 @@ 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 - # 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] + 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 -e prev[1] + end + + set section $section"[^)]*" - set section $section"[^)]*" + set -l token (commandline -ct) + # If we don't have a token but a section, list all pages for that section. + # Don't do it for all sections because that would be overwhelming. + if test -z "$token" -a "$section" != "[^)]*" + set token "." + end + if test -n "$token" # Do the actual search - apropos (commandline -ct) ^/dev/null | awk ' + apropos $token ^/dev/null | awk ' BEGIN { FS="[\t ]- "; OFS="\t"; } # BSD/Darwin /^[^( \t]+\('$section'\)/ { @@ -58,6 +64,9 @@ function __fish_complete_man print name, sect } ' + else + return 1 end + return 0 end |