Yii 1.1: Autocomplete in console command


Missed of autocomplete in bash console commands yii make me sad.

This tutorial is working on normal system (*nix): BSD, Linux, etc.

If your project under git, you need to add submodule:

git submodule add git://github.com/Stamm/yii-console-completion protected/extensions/complete/

Or just create file LCompleteCommand.php in protected/extensions/complete/

Next enable command class in config file for console application (usually console.php)

'commandMap' => array(
    'complete' => array(
        'class' => 'ext.complete.LCompleteCommand',
        //'bashFile' => '/etc/bash_completion.d/yii_applications' //Defaults to </etc/bash_completion.d/yii_applications>. May be changed if needed

Path to dir bash-completion may be different depending on OS. On Debian or Ubuntu you may leave standart path. In Mac OS X bash-completion has installed with homebrew, so your path is /usr/local/etc/bash_completion.d/yii_applications.

Run command to create file of bash-completion. You need permission to write in bash-complete dir.

sudo ./yiic complete install

Now when new session is create in bash will be work autocompletion to yiic:

  1. For application - sets of commands
  2. For command - list of actions and named params for default action
  3. For action - hint for his named params

Original article in russian: http://habr-sandbox.livejournal.com/230319.html

Total 1 comment

#5598 report it
CeBe at 2011/10/24 02:37am
My approach

Did not check out your code, but if someone is interested in, here is what I wrote to get ./yiic bash-completion: https://gist.github.com/1141050 (it might has to be changed somehow to fit your needs)

Leave a comment

Please to leave your comment.

Write new article