fish-shell/share/functions/__fish_is_first_arg.fish
Mahmoud Al-Qudsi 6dc74d3b6c New helper functions __fish_is_first_arg and __fish_prev_arg_in
For usage in completion scripts.

Unlike `__fish_is_first_token` (which is probably not correctly named),
`__fish_is_first_arg` returns true regardless of whether existing tokens start with `-`
or not, to be used when an arg cannot be used with any other argument.

`__fish_prev_arg_in` is similar to `__fish_seen_...` but it explicitly
tests the preceding token only, for arguments that take only a single
parameter.
2018-05-06 18:55:12 -05:00

5 lines
171 B
Fish

# determine if this is the very first argument (regardless if switch or not)
function __fish_is_first_arg
set -l tokens (commandline -co)
test (count $tokens) -eq 1
end