1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-22 13:50:09 +00:00
ohmyzsh/plugins/composer/composer.plugin.zsh

71 lines
2.2 KiB
Bash
Raw Normal View History

# ------------------------------------------------------------------------------
# FILE: composer.plugin.zsh
# DESCRIPTION: oh-my-zsh composer plugin file.
# AUTHOR: Daniel Gomes (me@danielcsgomes.com)
# VERSION: 1.0.0
# ------------------------------------------------------------------------------
# Composer basic command completion
_composer_get_command_list () {
$_comp_command1 --no-ansi 2>/dev/null | sed "1,/Available commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
}
_composer_get_required_list () {
$_comp_command1 show -s --no-ansi 2>/dev/null | sed '1,/requires/d' | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }'
}
_composer () {
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments \
'*:: :->subcmds'
if (( CURRENT == 1 )) || ( ((CURRENT == 2)) && [ "$words[1]" = "global" ] ) ; then
compadd $(_composer_get_command_list)
else
compadd $(_composer_get_required_list)
fi
}
compdef _composer composer
compdef _composer composer.phar
# Aliases
alias c='composer'
alias csu='composer self-update'
alias cu='composer update'
2013-08-17 15:11:21 +00:00
alias cr='composer require'
alias crm='composer remove'
alias ci='composer install'
alias ccp='composer create-project'
2013-02-28 10:50:39 +00:00
alias cdu='composer dump-autoload'
alias cdo='composer dump-autoload -o'
2013-08-17 15:11:21 +00:00
alias cgu='composer global update'
alias cgr='composer global require'
alias cgrm='composer global remove'
alias co='composer outdated'
alias cod='composer outdated --direct'
# install composer in the current directory
alias cget='curl -s https://getcomposer.org/installer | php'
2014-06-01 23:28:42 +00:00
# Add Composer's global binaries to PATH, using Composer if available.
if (( $+commands[composer] )); then
autoload -Uz _store_cache _retrieve_cache
_retrieve_cache composer
if [[ -z $__composer_bin_dir ]]; then
__composer_bin_dir=$(composer global config bin-dir --absolute 2>/dev/null)
_store_cache composer __composer_bin_dir
fi
# Add Composer's global binaries to PATH
export PATH="$PATH:$__composer_bin_dir"
unset __composer_bin_dir
else
[ -d $HOME/.composer/vendor/bin ] && export PATH=$PATH:$HOME/.composer/vendor/bin
[ -d $HOME/.config/composer/vendor/bin ] && export PATH=$PATH:$HOME/.config/composer/vendor/bin
fi