I have zsh completion
for my custom script. It takes 3 optional arguments --insert
, --edit
, --rm
and it completes files from given path:
#compdef pass
_pass() {
local -a args
args+=(
'--insert[Create a new password entry]'
'--edit[Edit a password entry]'
'--rm[Delete a password entry]'
)
_arguments $args '1: :->directory'
case $state in
directory)
_path_files -W $HOME/passwords -g '*(/)' -S /
_path_files -W $HOME/passwords -g '*.gpg(:r)' -S ' '
;;
esac
}
I need to add another option -P
, that will also be offered for completion (when I type -
and TAB), but does not offer path completion. This option should only take a string. So it should not match a path, and also it should not offer the other options if -P
has been specified.
How can I add this new option to my completion script?
UPDATE:
The completion does not work for option -P
, ie when i do:
pass -P <TAB>
it completes nothing because option -P needs a string. This is good. But, when I do
pass -P foo <TAB>
it also does not complete nothing. But it should complete directories in current path. How can do that?