Skip to content

Instantly share code, notes, and snippets.

@VladRassokhin
Last active August 29, 2015 14:25
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 VladRassokhin/769d1ff55a6d288307a1 to your computer and use it in GitHub Desktop.
Save VladRassokhin/769d1ff55a6d288307a1 to your computer and use it in GitHub Desktop.
CKAN bash completion
_ckan()
{
local cur=${COMP_WORDS[COMP_CWORD]}
if [ $COMP_CWORD -eq 1 ]; then
# Complete command
local commands="$(ckan help 2>&1 | grep -e '^ ' | awk '{print $1}')"
COMPREPLY=( $(compgen -W "$commands" -- $cur) )
return
fi
local command="${COMP_WORDS[1]}"
case "$command" in
install|show)
local available="$(ckan available | grep '^\*' | awk '{print $2}')"
COMPREPLY=( $(compgen -W "$available" -- $cur) )
;;
remove)
local installed="$(ckan list | grep '^. ' | awk '{print $2}')"
COMPREPLY=( $(compgen -W "$installed" -- $cur) )
;;
esac
}
complete -F _ckan ckan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment