From 8b89076dc3fd816f8790004681878d8a80c75ce2 Mon Sep 17 00:00:00 2001 From: pomaxa Date: Thu, 2 Aug 2012 12:13:45 +0300 Subject: [PATCH 1/2] add new plugin to autocomplete composer commands --- plugins/composer/composer.plugin.zsh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 plugins/composer/composer.plugin.zsh diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh new file mode 100644 index 000000000..69a637c02 --- /dev/null +++ b/plugins/composer/composer.plugin.zsh @@ -0,0 +1,13 @@ +# Composer basic command completion + +_composer_get_command_list () { + php composer.phar --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }' +} + +_composer () { + if [ -f composer.phar ]; then + compadd `_composer_get_command_list` + fi +} + +compdef _composer composer.phar From 6102757833936a617b3beebfc3a5a39df3336358 Mon Sep 17 00:00:00 2001 From: pomaxa Date: Thu, 2 Aug 2012 14:05:27 +0300 Subject: [PATCH 2/2] extend composer auto-complete --- plugins/composer/composer.plugin.zsh | 39 +++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh index 69a637c02..73bc5319f 100644 --- a/plugins/composer/composer.plugin.zsh +++ b/plugins/composer/composer.plugin.zsh @@ -1,13 +1,38 @@ # Composer basic command completion -_composer_get_command_list () { - php composer.phar --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }' -} +_composer_chpwd () { + if [ -f composer.json ]; then +# echo "composer exist"; + else +# + fi -_composer () { - if [ -f composer.phar ]; then - compadd `_composer_get_command_list` + if (( $+commands[composer] )) ; then + # it exists + #echo "exist command"; + #$COMPOSER_AS_COMMAND TRUE; + _composer_get_command_list () { + composer --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }' + } + + _composer () { + compadd `_composer_get_command_list` + } + + compdef _composer composer + else + _composer_get_command_list () { + php composer.phar --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }' + } + + _composer () { + if [ -f composer.phar ]; then + compadd `_composer_get_command_list` + fi + } + + compdef _composer composer.phar fi } -compdef _composer composer.phar +chpwd_functions=( "${chpwd_functions[@]}" _composer_chpwd )