Fix man autocomplete when a section is set

This commit is contained in:
Cesar Andreu 2018-03-03 05:26:20 -08:00 committed by Fabian Homborg
parent 4414d5c888
commit 3792fb086a

View file

@ -15,6 +15,12 @@ function __fish_complete_man
set -e prev[1] set -e prev[1]
end end
set -l exclude_fish_commands
# Only include fish commands when section is empty or 1
if test -z "$section" -o "$section" = "1"
set -e exclude_fish_commands
end
set section $section"[^)]*" set section $section"[^)]*"
# If we don't have a token but a section, list all pages for that section. # 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. # Don't do it for all sections because that would be overwhelming.
@ -63,8 +69,10 @@ function __fish_complete_man
' '
# Fish commands are not given by apropos # Fish commands are not given by apropos
set -l files $__fish_datadir/man/man1/*.1 if not set -ql exclude_fish_commands
string replace -r '.*/([^/]+)\.1$' '$1\t1: fish command' -- $files set -l files $__fish_datadir/man/man1/*.1
string replace -r '.*/([^/]+)\.1$' '$1\t1: fish command' -- $files
end
else else
return 1 return 1
end end