diff options
author | Daniel Wallace <danielwallace@gtmanfred.com> | 2013-06-28 20:19:55 -0500 |
---|---|---|
committer | Daniel Wallace <danielwallace@gtmanfred.com> | 2013-06-28 20:39:28 -0500 |
commit | 2770e059e9b5a3b36298b701e12827aea183acfd (patch) | |
tree | e23a5fc065aa2f1c3d949eb40e484955c0b917ef /tools | |
parent | b526c9beff3f88d792d4c5a17d68f357eaf139ac (diff) | |
download | python-novaclient-2770e059e9b5a3b36298b701e12827aea183acfd.tar.gz |
Adds zsh completion
Use nova bash-completion to add native zsh completion using built in
parameter expansion. Nothing spectacular or new, this is mostly so that
zsh users do not need to autoload bashcompinit just to use nova.
Change-Id: I56f62f036e0c85e79197f4c7dfd25abf7eb4110a
Implements: zsh completion
Diffstat (limited to 'tools')
-rw-r--r-- | tools/nova.zsh_completion | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/nova.zsh_completion b/tools/nova.zsh_completion new file mode 100644 index 00000000..43c4d649 --- /dev/null +++ b/tools/nova.zsh_completion @@ -0,0 +1,29 @@ +#compdef nova + +local -a nbc _nova_opts _nova_flags _nova_opts_exp cur prev + +nbc=(${(ps: :)$(_call_program options "$service bash-completion" 2>/dev/null)}) +_nova_opts=(${nbc:#-*}) +_nova_flags=(${(M)nbc:#-*}) +_nova_opt_exp=${${nbc:#-*}// /|} +cur=$words[CURRENT] +prev=$words[(( CURRENT - 1 ))] + +_checkcomp(){ + for word in $words[@]; do + if [[ -n ${_nova_opts[(r)$word]} ]]; then + return 0 + fi + done + return 1 +} + +echo $_nova_opts[@] |grep --color nova +if [[ "$prev" != "help" ]] && _checkcomp; then + COMPLETION_CACHE=(~/.novaclient/*/*-cache) + cflags=($_nova_flags[@] ${(ps: :)$(cat $COMPLETION_CACHE 2>/dev/null)}) + compadd "$@" -d $cflags[@] +else + compadd "$@" -d $_nova_opts[@] +fi + |