Last active
December 17, 2015 12:59
-
-
Save nils-werner/5613468 to your computer and use it in GitHub Desktop.
Autocompletion for Composer and Artisan
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put this either in | |
# | |
# 1. a new file called ~/.bash_completion | |
# 2. your ~/.bashrc | |
# | |
_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 | |
_artisan() | |
{ | |
local cur | |
_get_comp_words_by_ref -n : cur | |
if( [ ${COMP_WORDS[0]} = "artisan" ] || [ ${COMP_WORDS[0]} = "./artisan" ] || ( [ ${COMP_WORDS[0]} == "php" ] && [ ${COMP_WORDS[1]} = "artisan" ] ) ) | |
then | |
if (php artisan > /dev/null 2>&1) | |
then | |
COMPREPLY=( $(compgen -W "$(php artisan list --raw | cut -f 1 -d " " | tr "\n" " ")" -- $cur) ) | |
__ltrim_colon_completions "$cur" | |
fi | |
fi | |
} | |
complete -F _artisan php | |
complete -F _artisan artisan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment