Tagged with: [ bash ] [ completion ] [ symfony2 ] [ zsh ]
If you do command line work under Linux, you probably are aware that when pressing
<TAB> automatically completes your
command, or give you options for it that are currently available. For instance, when entering
cd l en pressing
bash gives you a list of all directories starting with an
l, which you can select instead of type. If there is only
one available directory that starts with an
l, it will automatically fill this in for you.
A great way to speed up your CLI development work, and an even better way to get acquainted with all options that are available to you for certain applications.
One of the cool things you can do with this, is customize how your shell does this auto-completion. For instance, git uses such customization to allow you to easily select commands, branches etc. No need to remember or check which branches or remotes are available: just press tab and you can select them from the list!
With symfony2, you have a really nice command line tool (
app/console), which enables some really nice commands and
features like generating complete crud controllers directly from entities, clearing caches, adding users, and quite
possible a whole lot more. When developing symfony2 apps, the console is something you need.
But the console does not come with autocompletion, when typing
php app/console, which needs to be followed by a
symfony2 console command, you’re on your own. Either you know them by heart, or you must look them up.
Fortunately, this gist makes it a little better: when used, you can just press
<tab> after your
php app/console, and
you will get automatically a list of all the possible commands that are available.
Better yet, when you typed your command, pressing
<tab> again will actually display all the possible arguments (like
-verbose, or the custom arguments for that specific command).
It’s written in bash, for bash, but fortunately it will work with ZSH too. Have fun.
Download the console completion script here: https://github.com/jaytaph/SFConsole