Skip to content

Instantly share code, notes, and snippets.

@fredipevcin
Created September 25, 2012 09:17
Show Gist options
  • Save fredipevcin/3780808 to your computer and use it in GitHub Desktop.
Save fredipevcin/3780808 to your computer and use it in GitHub Desktop.
Symfony2 console autocomplete
# SYMFONY
_symfony() {
local cur cmd
COMPREPLY=()
cur="${COMP_WORDS[${COMP_CWORD}]}"
command="${COMP_WORDS[1]}"
if [ ${COMP_CWORD} == 1 ]; then
cmds="$(symfony list --no-ansi | grep -e '^\s\s[a-z]' | awk '{ print $1}')"
COMPREPLY=( $(compgen -W '$cmds' -- $cur))
elif [ ${COMP_CWORD} -ge 2 ]; then
cmds="$(symfony | grep -e '^\s\s--' | awk '{print $1}')"
cmds="$(symfony help $command | grep -e '^\s--' | awk '{print $1}') $cmds"
COMPREPLY=($(compgen -W '$cmds' -- $cur))
fi
return 0
}
complete -F _symfony symfony
COMP_WORDBREAKS=${COMP_WORDBREAKS//:}

Symfony2 console autocomplete

  • put symfony in your PATH dir and make it executable
  • add .symfony_completion content to completion script
  • cd /path/to/symfony/project and run symfony
#!/bin/bash
if [ ! -f "app/console" ]; then
echo "Command can only be run in Symfony root folder";
exit 1;
fi;
env php app/console $@
@adrienbrault
Copy link

There an easier way: install oh-my-zsh, and enable the symfony2 plugin.

https://github.com/robbyrussell/oh-my-zsh

@lyrixx
Copy link

lyrixx commented Sep 25, 2012

@adrienbrault This not easier... you need to install zsh, then oh-my-zsh, the sf2 plugin !

@fredipevcin
Copy link
Author

@adrienbrault i'm using bash not zsh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment