Issue
I would like to be able to use tab auto completion with composer in my bash shell, the same way I can for example auto complete filenames or git commands.
Solution
To enable auto complete for composer
in bash you need to write a function that returns an array of possible values for the last typed parameter (_composer()
in this case) and register it using complete -F function command
.
As a complete, working example add the following to your .bashrc
(or any other configuration script you might be using)
_composer()
{
local cur=${COMP_WORDS[COMP_CWORD]}
local cmd=${COMP_WORDS[0]}
if ($cmd > /dev/null 2>&1)
then
COMPREPLY=( $(compgen -W "$($cmd list --raw | cut -f 1 -d " " | tr "\n" " ")" -- $cur) )
fi
}
complete -F _composer composer
complete -F _composer composer.phar
Answered By - Nils Werner Answer Checked By - Senaida (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.