mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-22 16:23:55 +08:00
29f35d6cdf
This gives us more accurate completions because completion scripts get expanded paths
10 lines
386 B
Fish
10 lines
386 B
Fish
function __fish_nth_token --description 'Prints the Nth token (ignoring command and switches/flags)' --argument-names n
|
|
set -l tokens (commandline -px | string replace -r --filter '^([^-].*)' '$1')
|
|
# Increment $n by one to account for ignoring the command
|
|
if test (count $tokens) -ge (math "$n" + 1)
|
|
echo $tokens[(math $n + 1)]
|
|
else
|
|
return 1
|
|
end
|
|
end
|