Created
August 11, 2011 23:19
-
-
Save cebe/1141050 to your computer and use it in GitHub Desktop.
yiic bash completion
This file contains hidden or 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
# basic bash completion for yiic command | |
# | |
# simply add the following to your ~/.bash_profile | |
# | |
# . ~/path/to/this/file/yiic_bash_completion.bash | |
# | |
# note: the . is relevant and you probably have to adjust the path ;-) | |
# | |
_yiic() | |
{ | |
local cur prev opts migrateopts deployopts | |
COMP_WORDBREAKS=${COMP_WORDBREAKS//:} | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
opts="" | |
if [ $COMP_CWORD -le 2 ] ; then | |
case "$prev" in | |
./yiic) | |
opts="api cron message migrate shell test webapp" | |
;; | |
api) | |
opts="check yii doc" | |
;; | |
cron) | |
opts="" | |
;; | |
migrate) | |
opts="up down to mark new history create" | |
;; | |
esac | |
fi | |
if [ $COMP_CWORD == 3 ] ; then | |
case "$prev" in | |
mark|to) | |
opts="`./yiic migrate bash migrations | tail -1`" | |
;; | |
create) | |
opts="`./yiic migrate bash modules | tail -1`" | |
;; | |
esac | |
fi | |
#if [ "${cur:0:9}" == "--module=" ] ; then | |
# opts="${cur:0:9}bla ${cur:0:9}test ${cur:0:9}ixxx ${cur:0:9}hallo" | |
#fi | |
# @todo: add support for module param in yiic migrate and yiic migrate create | |
# @todo: limit completion for versions in mark and to to module, if given | |
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | |
} | |
complete -F _yiic ./yiic |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment