Created
December 18, 2012 06:41
-
-
Save outsideris/4325612 to your computer and use it in GitHub Desktop.
bash completion example for user command
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
# bash_completion | |
_instance() | |
{ | |
local cur prev opts | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
opts="CANDIDATE1 CANDIDATE2 CANDIDATE3 CANDIDATE4 ..." | |
if [[ ${cur} == * ]] ; then | |
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | |
return 0 | |
fi | |
} | |
complete -F _instance SHELL_COMMAND | |
//replace CANDIDATE & SHELL_COMMAND |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment