I have a script foo
, which takes few optional commandline arguments in the form of:
foo -A <NUM> -B <NUM> -i
or it can also be without space:
foo -A<NUM> -B<NUM> -i
where NUM is integer number. The script should not complete filenames / directories.
I have following completion rules:
#compdef foo
local -a args
_arguments -S \
'*-A' \
'*-B' \
'*-i'
What do I have to add, so that the completion is aware that the options -A
or -B
are not complete by themselves, but need a number before the completion can continue?
In another script, I have similar situation, the only differece is the option uses =
:
foo --port=<PORT>
How could I do this also?
UPDATE:
I am experiencing weird issue, with following completion:
#compdef foo
_arguments -S \
'-A+:' \
'-B+:' \
'-i'
For some reason, the first argument A
is ignored, ie:
foo -<TAB>
-B -i
But when I put some other option in front of A
#compdef foo
_arguments -S \
'-x+:' \
'-A+:' \
'-B+:' \
'-i'
then not only is A
shown, but also this other new option:
foo -<TAB>
-A -B -i -x
what is happening here ?