Last active
August 29, 2015 14:25
-
-
Save VladRassokhin/769d1ff55a6d288307a1 to your computer and use it in GitHub Desktop.
CKAN bash completion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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