Your completion should act as though binary
takes not an option --foo
with an argument of on
or off
, but two separate options --foo:on
and --foo:off
, because that's exactly what binary
takes.
For non-constant options, such as your --path:foo/bar
example, perhaps something like
cur=${COMP_WORDS[COMP_CWORD]}
case $cur in
--path:*)
IFS=: read opt partialFile
for f in $(compgen -f $partialFile); do
COMPREPLY+=( "--path:$f" )
done
;;
I realize this won't work well with file names containing whitespace or other special characters, but then I'm not sure how programmable completion deals with them in the first place.