diff --git a/share/functions/__fish_first_token.fish b/share/functions/__fish_first_token.fish new file mode 100644 index 000000000..65b560899 --- /dev/null +++ b/share/functions/__fish_first_token.fish @@ -0,0 +1,9 @@ +# Retrieves the first non-switch argument from the command line buffer +function __fish_first_token + set -l tokens (commandline -co) + set -e tokens[1] + set -l tokens (string replace -r --filter '^([^-].*)' '$1' -- $tokens) + if set -q tokens[1] + echo $tokens[1] + end +end