Created
November 12, 2010 03:52
-
-
Save chuangbo/673701 to your computer and use it in GitHub Desktop.
easy to write a bash_completion script file
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
_server.py() | |
{ | |
local cur prev opts base | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
# | |
# The first options should be a yaml config | |
# | |
if [ $COMP_CWORD -eq 1 ]; then | |
COMPREPLY=( $(compgen -W "`ls -1 *.yaml 2>/dev/null`" -- ${cur}) ) | |
return 0 | |
fi | |
# | |
# Complete the command | |
# | |
opts="startserver shell ishell help movefiles install script" | |
COMPREPLY=($(compgen -W "${opts}" -- ${cur})) | |
return 0 | |
} | |
complete -F _server.py server.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment