mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-26 11:45:08 +00:00
Man completions: Show all pages for a section
If one is given, of course.
This commit is contained in:
parent
f23464001f
commit
ebde55f704
1 changed files with 22 additions and 13 deletions
|
@ -1,27 +1,33 @@
|
||||||
|
|
||||||
function __fish_complete_man
|
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
|
set section ""
|
||||||
# use [^)]*, which should match any section
|
set prev (commandline -poc)
|
||||||
|
set -e prev[1]
|
||||||
set section ""
|
while count $prev
|
||||||
set prev (commandline -poc)
|
switch $prev[1]
|
||||||
set -e prev[1]
|
|
||||||
while count $prev
|
|
||||||
switch $prev[1]
|
|
||||||
case '-**'
|
case '-**'
|
||||||
|
|
||||||
case '*'
|
case '*'
|
||||||
set section $prev[1]
|
set section $prev[1]
|
||||||
end
|
|
||||||
set -e prev[1]
|
|
||||||
end
|
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
|
# Do the actual search
|
||||||
apropos (commandline -ct) ^/dev/null | awk '
|
apropos $token ^/dev/null | awk '
|
||||||
BEGIN { FS="[\t ]- "; OFS="\t"; }
|
BEGIN { FS="[\t ]- "; OFS="\t"; }
|
||||||
# BSD/Darwin
|
# BSD/Darwin
|
||||||
/^[^( \t]+\('$section'\)/ {
|
/^[^( \t]+\('$section'\)/ {
|
||||||
|
@ -58,6 +64,9 @@ function __fish_complete_man
|
||||||
print name, sect
|
print name, sect
|
||||||
}
|
}
|
||||||
'
|
'
|
||||||
|
else
|
||||||
|
return 1
|
||||||
end
|
end
|
||||||
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue