mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 05:28:49 +00:00
cleanup __fish_complete_man.fish
I looked at this and noted some problems fixed by this change in response to exploring if issue #726 was still unresolved.
This commit is contained in:
parent
b6517250c7
commit
536b1220fd
1 changed files with 5 additions and 8 deletions
|
@ -1,10 +1,9 @@
|
||||||
|
|
||||||
function __fish_complete_man
|
function __fish_complete_man
|
||||||
# Try to guess what section to search in. If we don't know, we
|
# Try to guess what section to search in. If we don't know, we
|
||||||
# use [^)]*, which should match any section
|
# use [^)]*, which should match any section.
|
||||||
|
set -l section ""
|
||||||
set section ""
|
set -l token (commandline -ct)
|
||||||
set prev (commandline -poc)
|
set -l prev (commandline -poc)
|
||||||
set -e prev[1]
|
set -e prev[1]
|
||||||
while set -q prev[1]
|
while set -q prev[1]
|
||||||
switch $prev[1]
|
switch $prev[1]
|
||||||
|
@ -17,8 +16,6 @@ function __fish_complete_man
|
||||||
end
|
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.
|
# 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.
|
||||||
if test -z "$token" -a "$section" != "[^)]*"
|
if test -z "$token" -a "$section" != "[^)]*"
|
||||||
|
@ -67,7 +64,7 @@ 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
|
set -l files $__fish_datadir/man/man1/*.1
|
||||||
string replace -r '.*/([^/]+)\.1$' '$1\tFish command' -- $files
|
string replace -r '.*/([^/]+)\.1$' '$1\t1: fish command' -- $files
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue