From c640b999b4dd14438f0a71f7981c775777d38822 Mon Sep 17 00:00:00 2001 From: Michael Stucki Date: Tue, 6 Mar 2018 22:10:34 +0100 Subject: [PATCH] composer: Fix slowness during startup --- plugins/composer/composer.plugin.zsh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh index d00813e3..cc555927 100644 --- a/plugins/composer/composer.plugin.zsh +++ b/plugins/composer/composer.plugin.zsh @@ -4,6 +4,17 @@ # AUTHOR: Daniel Gomes (me@danielcsgomes.com) # VERSION: 1.0.0 # ------------------------------------------------------------------------------ +# +# USAGE +# ----- +# +# Enable caching: +# +# If you want to use the cache, set the followings in your .zshrc: +# +# zstyle ':completion:*' use-cache yes +# +# ------------------------------------------------------------------------------ # Composer basic command completion _composer_get_command_list () { @@ -51,5 +62,12 @@ alias cgrm='composer global remove' # install composer in the current directory alias cget='curl -s https://getcomposer.org/installer | php' +_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 global config bin-dir --absolute 2>/dev/null) +export PATH=$PATH:$__composer_bin_dir