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]
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"[^)]*"
# 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.
@ -63,8 +69,10 @@ function __fish_complete_man
'
# Fish commands are not given by apropos
set -l files $__fish_datadir/man/man1/*.1
string replace -r '.*/([^/]+)\.1$' '$1\t1: fish command' -- $files
if not set -ql exclude_fish_commands
set -l files $__fish_datadir/man/man1/*.1
string replace -r '.*/([^/]+)\.1$' '$1\t1: fish command' -- $files
end
else
return 1
end