Skip to content

Instantly share code, notes, and snippets.

@jtai
Created December 13, 2013 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtai/7949209 to your computer and use it in GitHub Desktop.
Save jtai/7949209 to your computer and use it in GitHub Desktop.
Bash completion for stemcell
_stemcell_role()
{
COMPREPLY=( $( compgen -W '$(ls -1 roles | sed "s/\.rb$//")' -- "$cur" ) )
}
_stemcell()
{
local cur prev words cword
COMPREPLY=()
_get_comp_words_by_ref cur prev words cword
case "$prev" in
-d|--chef-data-bag-secret|-y|--git-key)
_filedir
return 0
;;
-l|--local-chef-root)
_filedir -d
return 0
;;
--git-branch)
if type _git_branch 2>&1 | grep -q 'function'; then
_git_branch
fi
return 0
;;
--chef-role)
_stemcell_role
return 0
;;
esac
case "$cur" in
-*)
COMPREPLY=( $( compgen -W '--local-chef-root -l --aws-creds -a \
--aws-access-key -w --aws-secret-key -s --region -r \
--instance-type -i --backing-store -b --image-id -m \
--security-groups -e --availability-zone -v --tags -g \
--key-name -k --iam-role -o --placement-group -p \
--ebs-optimized -z --block-device-mappings -c \
--ephemeral-devices -h --chef-data-bag-secret -d --chef-role \
--chef-environment -n --git-origin --git-branch --git-key -y \
--instance-hostname --instance-domain-name --count --tail -t \
--ssh-user -u --non-interactive -f --version --help' -- "$cur" ) )
;;
*)
if [[ $COMP_CWORD -eq 1 ]]; then
_stemcell_role
fi
;;
esac
} &&
complete -F _stemcell stemcell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment