Symfony Bash auto-completion
Add this to your bash completion :
- Debian / Ubuntu : /etc/bash_completion.d/symfony
- Redhat : /etc/profile.d/symfony
- SLES : /etc/bash_completion.d/symfony.sh
_symfony()
{
local cur prev action
COMREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
action=${COMP_WORDS[1]}
case "$prev" in
init-module|propel-generate-crud|propel-init-crud|propel-init-admin|propel-load-data|propel-build-all-load)
COMPREPLY=( $( compgen -W "$( ls --color=n -1 apps 2>/dev/null| sed -e 's/ /\\ /g' )" -- $cur ))
return 0
;;
init-project)
COMPREPLY=( $( compgen -W "$( basename $PWD )" -- $cur ))
return 0
;;
init-app)
COMPREPLY=( $( compgen -W "frontend backend" -- $cur))
return 0
;;
symfony)
COMPREPLY=( $( compgen -W "$( symfony -T | awk '/^ /' | cut -d' ' -f3 )" -- $cur ) )
return 0
;;
plugin-install)
COMPREPLY=( $( compgen -W 'local global' -- $cur ) )
return 0
;;
global|local)
COMPREPLY=( $( compgen -W 'symfony/' ) )
return 0
;;
*)
case "$action" in
propel-generate-crud|propel-init-crud|propel-init-admin)
if (($COMP_CWORD == 3)); then
COMPREPLY=( $( compgen -W "$( find lib/model -maxdepth 1 -name '*.php' -exec basename {} .php \; |grep -v Peer\$| tr [:upper:] [:lower:] )" -- $cur ) )
elif (($COMP_CWORD == 4)); then
COMPREPLY=( $( compgen -W "$( find lib/model -maxdepth 1 -name '*.php' -exec basename {} .php \; |grep -v Peer\$ )" -- $cur ) )
fi
return 0
;;
esac
return 0
;;
sync)
if (($COMP_CWORD == 3)); then
COMPREPLY=( $( compgen -W 'go' -- $cur))
fi
return 0
;;
esac
return 0
}
complete -F _symfony symfony
Alternatively you can put the above code in ~/.bash-completion and add this line to your .bashrc:
[ -f ~/.bash-completion ] && source ~/.bash-completion