mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 21:03:12 +00:00
7db0958804
To be used by completions to directly determine whether it is either possible or preferable to complete a switch (instead of a subcommand), (presuming that switches must come before subcommands). * __fish_can_complete_switches: we are in a position where a switch may be placed. * __fish_should_complete_switches: we're in a position to accept a switch and the current token starts with `-` so we have no choice but to do so.
12 lines
313 B
Fish
12 lines
313 B
Fish
# Returns whether we *should* complete a -s or --long argument.
|
|
# The preference is NOT to do so, i.e. prefer subcommands over switches.
|
|
function __fish_should_complete_switches
|
|
if not __fish_can_complete_switches
|
|
return 1
|
|
end
|
|
if string match -qr -- "^-" (commandline -ct)[-1]
|
|
return 0
|
|
end
|
|
|
|
return 1
|
|
end
|