From 0cc3afe27788e35d5f72236f41a7e4514c11491d Mon Sep 17 00:00:00 2001 From: Julien Pepy Date: Fri, 5 Dec 2014 09:57:59 +0100 Subject: [PATCH 1/4] Fix get command list for recent composer versions --- plugins/composer/composer.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh index 86f2ca4d..f75119c4 100644 --- a/plugins/composer/composer.plugin.zsh +++ b/plugins/composer/composer.plugin.zsh @@ -7,7 +7,7 @@ # Composer basic command completion _composer_get_command_list () { - composer --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }' + composer --no-ansi | sed "1,/Available commands/d" | awk '/^\s*[a-z]+/ { print $1 }' } _composer_get_required_list () { From 5f4e8e57da117b5fc2325ea411aafc66053b8570 Mon Sep 17 00:00:00 2001 From: Andrey Janzen Date: Fri, 26 Jul 2013 00:37:11 +0700 Subject: [PATCH 2/4] Allow completion for 'composer.phar', not only 'composer' Use $_comp_command1 for command list generation instead of 'composer': `$_comp_command1` contains the command written in the command line. This allows us to have a different composer name --- plugins/composer/composer.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh index f75119c4..324bc64a 100644 --- a/plugins/composer/composer.plugin.zsh +++ b/plugins/composer/composer.plugin.zsh @@ -7,11 +7,11 @@ # Composer basic command completion _composer_get_command_list () { - composer --no-ansi | sed "1,/Available commands/d" | awk '/^\s*[a-z]+/ { print $1 }' + $_comp_command1 --no-ansi | sed "1,/Available commands/d" | awk '/^\s*[a-z]+/ { print $1 }' } _composer_get_required_list () { - composer show -s --no-ansi | sed '1,/requires/d' | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }' + $_comp_command1 show -s --no-ansi | sed '1,/requires/d' | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }' } _composer () { @@ -35,6 +35,7 @@ _composer () { } compdef _composer composer +compdef _composer composer.phar # Aliases alias c='composer' From ef220f0928269f3cdb613db3d3f9ba7775317109 Mon Sep 17 00:00:00 2001 From: Maxime Fabre Date: Sat, 17 Aug 2013 17:11:21 +0200 Subject: [PATCH 3/4] Add aliases for composer global --- plugins/composer/composer.plugin.zsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh index 324bc64a..97207242 100644 --- a/plugins/composer/composer.plugin.zsh +++ b/plugins/composer/composer.plugin.zsh @@ -41,9 +41,12 @@ compdef _composer composer.phar alias c='composer' alias csu='composer self-update' alias cu='composer update' +alias cr='composer require' alias ci='composer install' alias ccp='composer create-project' alias cdu='composer dump-autoload' +alias cgu='composer global update' +alias cgr='composer global require' # install composer in the current directory alias cget='curl -s https://getcomposer.org/installer | php' From 6fb866183d84e53fa009853691e5c0bdd101820b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Sun, 4 Jan 2015 22:24:55 +0100 Subject: [PATCH 4/4] Remove composer.json file requirement This is because we can't be sure which arguments require a json file and which don't, so the `else' statement will always be difficult to check for correctness. --- plugins/composer/composer.plugin.zsh | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh index 97207242..7f70e3d7 100644 --- a/plugins/composer/composer.plugin.zsh +++ b/plugins/composer/composer.plugin.zsh @@ -20,18 +20,15 @@ _composer () { _arguments \ '1: :->command'\ '*: :->args' - if [ -f composer.json ]; then - case $state in - command) - compadd `_composer_get_command_list` - ;; - *) - compadd `_composer_get_required_list` - ;; - esac - else - compadd create-project init search selfupdate show - fi + + case $state in + command) + compadd $(_composer_get_command_list) + ;; + *) + compadd $(_composer_get_required_list) + ;; + esac } compdef _composer composer