Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@chuangbo
Created November 12, 2010 03:52
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 chuangbo/673701 to your computer and use it in GitHub Desktop.
Save chuangbo/673701 to your computer and use it in GitHub Desktop.
easy to write a bash_completion script file
_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