Skip to content

Instantly share code, notes, and snippets.

@jrbasso
Created August 19, 2012 23:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrbasso/3398516 to your computer and use it in GitHub Desktop.
Save jrbasso/3398516 to your computer and use it in GitHub Desktop.
# Bash completation for application
_my_application()
{
local cur prev opts job
COMPREPLY=()
job="${COMP_WORDS[0]}"
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [[ ${COMP_CWORD} = 1 ]] ; then
opts=$(${job} __check__)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
if [[ ${COMP_CWORD} = 2 ]] ; then
opts=$(${job} __check__ $prev)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0;
}
complete -F _my_application job
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment