Skip to content

Instantly share code, notes, and snippets.

@petere
Created April 9, 2014 19:49
Show Gist options
  • Save petere/10307599 to your computer and use it in GitHub Desktop.
Save petere/10307599 to your computer and use it in GitHub Desktop.
zsh completion for test-kitchen
#compdef kitchen
_kitchen() {
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments '1: :->cmds'\
'2: :->args'
case $state in
cmds)
_arguments "1:Commands:(console converge create destroy diagnose driver help init list login setup test verify version)"
;;
args)
case $line[1] in
converge|create|destroy|diagnose|list|setup|test|verify)
compadd "$@" all
_kitchen_instances
;;
login)
_kitchen_instances
;;
esac
;;
esac
}
_kitchen_instances() {
if [[ $_kitchen_instances_cache_dir != $PWD ]]; then
unset _kitchen_instances_cache
fi
if [[ ${+_kitchen_instances_cache} -eq 0 ]]; then
_kitchen_instances_cache=(${(f)"$(bundle exec kitchen list -b 2>/dev/null || kitchen list -b 2>/dev/null)"})
_kitchen_instances_cache_dir=$PWD
fi
compadd -a _kitchen_instances_cache
}
_kitchen "$@"
@amaltson
Copy link

Is this in oh-my-zsh as a plugin by any chance?

@webframp
Copy link

Hopefully it will be soon! ohmyzsh/ohmyzsh#2829

@jeremyolliver
Copy link

It's already in zsh-users completions which is used by prezto zsh framework

@unixorn
Copy link

unixorn commented Aug 26, 2014

I packaged this as a plugin for antigen at https://github.com/unixorn/test-kitchen-completion.zshplugin. @petere, what license do you want on this?

@unixorn
Copy link

unixorn commented Aug 26, 2014

Never mind; I have a PR that makes zsh-lovers/zsh-completion compatible with antigen as a plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment