mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 06:10:57 +08:00
Fix apropos completions
The 'str' variable was apparently mistakenly removed by 49c5f96470
.
Re-add it, and regex-escape it as well.
Allow completing on apropos <TAB> instaed of requiring an initial char.
Use __fish_apropos instead of apropos.
New regex to hopefully work on more platforms.
Explicitly use ^ instead of adding it at __fish_apropos
This commit is contained in:
parent
054d0ac0ea
commit
c887e5dbde
|
@ -1,11 +1,10 @@
|
|||
function __fish_complete_apropos
|
||||
if test (commandline -ct)
|
||||
switch (commandline -ct)
|
||||
case '-**'
|
||||
set -f str (commandline -ct | string escape --style=regex)
|
||||
switch "$str"
|
||||
case '-**'
|
||||
|
||||
case '*'
|
||||
apropos $str 2>/dev/null | string replace -rf -- "^(.*$str([^ ]*).*)" "$str\$2\t\$1"
|
||||
end
|
||||
case '*'
|
||||
__fish_apropos "^$str" 2>/dev/null | string replace -rf -- '^([^(\s]+) ?\([,\w]+\)\s+-?\s?(.*)$' '$1\t$2'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ if test $status -eq 0 -a (count $sysver) -eq 3
|
|||
set age (path mtime -R -- $whatis)
|
||||
end
|
||||
|
||||
MANPATH="$dir" apropos "^$argv"
|
||||
MANPATH="$dir" apropos "$argv"
|
||||
|
||||
if test $age -ge $max_age
|
||||
test -d "$dir" || mkdir -m 700 -p $dir
|
||||
|
@ -46,6 +46,8 @@ if test $status -eq 0 -a (count $sysver) -eq 3
|
|||
end
|
||||
else
|
||||
function __fish_apropos
|
||||
apropos $argv
|
||||
# we only ever prefix match for completions. This also ensures results for bare apropos <TAB>
|
||||
# (apropos '' gives no results, but apropos '^' lists all manpages)
|
||||
apropos "$argv"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,7 +32,7 @@ function __fish_complete_man
|
|||
|
||||
if test -n "$token"
|
||||
# Do the actual search
|
||||
__fish_apropos $token 2>/dev/null | awk '
|
||||
__fish_apropos ^$token 2>/dev/null | awk '
|
||||
BEGIN { FS="[\t ]- "; OFS="\t"; }
|
||||
# BSD/Darwin
|
||||
/^[^( \t]+(, [^( \t]+)*\('$section'\)/ {
|
||||
|
@ -55,7 +55,7 @@ function __fish_complete_man
|
|||
split($1, t, " ");
|
||||
sect = substr(t[3], 2, length(t[3]) - 2);
|
||||
print t[1], sect ": " $2;
|
||||
}
|
||||
}
|
||||
# Solaris 11
|
||||
# Does not display descriptions
|
||||
# Solaris apropos outputs embedded backspace in descriptions
|
||||
|
|
|
@ -12,7 +12,7 @@ end
|
|||
function __fish_describe_command -d "Command used to find descriptions for commands"
|
||||
# $argv will be inserted directly into the awk regex, so it must be escaped
|
||||
set -l argv_regex (string escape --style=regex -- "$argv")
|
||||
__fish_apropos $argv 2>/dev/null | awk -v FS=" +- +" '{
|
||||
__fish_apropos ^$argv 2>/dev/null | awk -v FS=" +- +" '{
|
||||
split($1, names, ", ");
|
||||
for (name in names)
|
||||
if (names[name] ~ /^'"$argv_regex"'.* *\([18]\)/ ) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user