mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 09:39:52 +08:00
29f35d6cdf
This gives us more accurate completions because completion scripts get expanded paths
17 lines
401 B
Fish
17 lines
401 B
Fish
# returns 0 only if previous argument is one of the supplied arguments
|
|
function __fish_prev_arg_in
|
|
set -l tokens (commandline -cx)
|
|
set -l tokenCount (count $tokens)
|
|
if test $tokenCount -lt 2
|
|
# need at least cmd and prev argument
|
|
return 1
|
|
end
|
|
for arg in $argv
|
|
if string match -q -- $tokens[-1] $arg
|
|
return 0
|
|
end
|
|
end
|
|
|
|
return 1
|
|
end
|