Created
March 27, 2015 01:49
-
-
Save jimbocoder/71479e8776ec6dbaabbd to your computer and use it in GitHub Desktop.
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
# Modified version of what `composer _completion -g -p composer` generates | |
# Composer will only load plugins when a valid composer.json is in its working directory, | |
# so for this hack to work, we are always running the completion command in ~/.composer | |
function _composercomplete { | |
export COMP_LINE COMP_POINT COMP_WORDBREAKS; | |
local -x COMPOSER_CWD=`pwd` | |
local RESULT STATUS | |
# Honour the COMPOSER_HOME variable if set | |
local composer_dir=$COMPOSER_HOME | |
if [ -z "$composer_dir" ]; then | |
composer_dir=$HOME/.composer | |
fi | |
RESULT=`cd $composer_dir && composer depends _completion`; | |
STATUS=$?; | |
if [ $STATUS -ne 0 ]; then | |
echo $RESULT; | |
return $?; | |
fi; | |
local cur; | |
_get_comp_words_by_ref -n : cur; | |
COMPREPLY=(`compgen -W "$RESULT" -- $cur`); | |
__ltrim_colon_completions "$cur"; | |
}; | |
complete -F _composercomplete composer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment