mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 09:20:10 +08:00
47b0d0c293
Their names are not perfect, so let's keep them as internal functions,
until we figure out how/if we want to expose this.
This reverts 0445126c2
(Undunder __fish_is_nth_token, 2021-06-29) (but I
did it without "git revert").
Closes #8008
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 -po | 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
|