containerd/contrib/autocomplete/zsh_autocomplete
Shengjing Zhu 348e683ceb Fix zsh autocomplete script
Fix completion when argument startswith `-`
Merged in upstream https://github.com/urfave/cli/pull/1062

Signed-off-by: Shengjing Zhu <zhsj@debian.org>
2020-02-11 19:56:27 +08:00

24 lines
632 B
Plaintext

#compdef ctr
# This file is a direct copy of https://github.com/urfave/cli/blob/d04c0883fcc8860836ab30ade0fd29afa194ab23/autocomplete/zsh_autocomplete
# With $PROG changed to ctr
_cli_zsh_autocomplete() {
local -a opts
local cur
cur=${words[-1]}
if [[ "$cur" == "-"* ]]; then
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}")
else
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
fi
if [[ "${opts[1]}" != "" ]]; then
_describe 'values' opts
fi
return
}
compdef _cli_zsh_autocomplete ctr