fish-shell/share/functions/__fish_seen_argument.fish

35 lines
850 B
Fish
Raw Normal View History

function __fish_seen_argument --description 'Check whether argument is used'
argparse 's/short=+' 'o/old=+' 'l/long=+' 'w/windows=+' -- $argv
set --local tokens (commandline --current-process --tokenize --cut-at-cursor)
set --erase tokens[1]
for t in $tokens
for s in $_flag_s
if string match --regex --quiet -- "^-[A-z0-9]*"$s"[A-z0-9]*\$" $t
return 0
end
end
2019-11-03 03:40:40 +08:00
for o in $_flag_o
if string match --quiet -- "-$o" $t
2019-11-03 03:40:40 +08:00
return 0
end
end
for l in $_flag_l
if string match --quiet -- "--$l" $t
return 0
end
end
for w in $_flag_w
if string match --quiet -- "/$w" $t
return 0
end
end
end
return 1
end