mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Add function to retrieve first token
This should probably be updated to use argparse at some point?
This commit is contained in:
parent
332e17e8e8
commit
ec14507723
1 changed files with 9 additions and 0 deletions
9
share/functions/__fish_first_token.fish
Normal file
9
share/functions/__fish_first_token.fish
Normal file
|
@ -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
|
Loading…
Reference in a new issue