I have zsh completion rule for custom script. My script can take zero or more options (starting with -
) and zero or more arbitrary strings (patterns):
_arguments -S : \
'--foo' \
'--bar' \
'1:pattern:'
this rule works only partially, in following format:
script "somestring" <TAB>
offers --foo
or --bar
and --f<TAB>
automatically completes --foo
However,
script <TAB>
does nothing, where I would like to have options listed (--foo
, --bar
)
and even when I explicitly start with --
it shows the options but does not autocomplete them even when I am typing --f<TAB>
and there is no ambiguity what option I want.
script --f<TAB>
should automatically completete --foo
So, to sum up, since string
can be anything, there is nothing to autocomplete. Therefore, when I press , I want to autocomplete the --options, regardless whether i have alredy typed a string/pattern or not
I guess, I have to somehow specify in my completion rule that anything starting with -
is an option, not string, and therefore should be auto completed from available options