Skip to content

Instantly share code, notes, and snippets.

@kejadlen
Created March 8, 2011 18:19
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 kejadlen/860694 to your computer and use it in GitHub Desktop.
Save kejadlen/860694 to your computer and use it in GitHub Desktop.
_thor() {
COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts=`thor help | tail -n +2 | awk '{print $2}'`
opts="${opts} `thor list | tail -n +3 | awk '{print $2}'`"
if [[ ${#COMP_WORDS[@]} -lt 3 ]]; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
}
complete -F _thor thor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment