diff options
author | T0mK0 <T0mK0@users.noreply.github.com> | 2017-11-07 11:03:54 -0500 |
---|---|---|
committer | Robby Russell <robby@planetargon.com> | 2017-11-07 08:03:54 -0800 |
commit | 9d6b6c5ce161280e52df3a33d584318d6dbc0bd9 (patch) | |
tree | 5cce654f1b982299c04f41d09b70c3241e5fddd2 /plugins/chruby | |
parent | 47039f645ffa5e59d1d32aeee8e2cb432035f78a (diff) | |
download | zsh-9d6b6c5ce161280e52df3a33d584318d6dbc0bd9.tar.gz zsh-9d6b6c5ce161280e52df3a33d584318d6dbc0bd9.tar.bz2 zsh-9d6b6c5ce161280e52df3a33d584318d6dbc0bd9.zip |
speed up chruby plugin by eliminating(as much as possible) calls to brew (#6080)
* speed up chruby plugin by eliminating(as much as possible) calls to brew
* speed up aws plugin by eliminating(as much as possible) calls to brew
Diffstat (limited to 'plugins/chruby')
-rw-r--r-- | plugins/chruby/chruby.plugin.zsh | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/plugins/chruby/chruby.plugin.zsh b/plugins/chruby/chruby.plugin.zsh index 758b4a56c..998d92098 100644 --- a/plugins/chruby/chruby.plugin.zsh +++ b/plugins/chruby/chruby.plugin.zsh @@ -16,12 +16,28 @@ # rvm and rbenv plugins also provide this alias alias rubies='chruby' + _homebrew-installed() { whence brew &> /dev/null + _xit=$? + if [ $_xit -eq 0 ];then + # ok , we have brew installed + # speculatively we check default brew prefix + if [ -h /usr/local/opt/chruby ];then + _brew_prefix="/usr/local/opt/chruby" + else + # ok , it is not default prefix + # this call to brew is expensive ( about 400 ms ), so at least let's make it only once + _brew_prefix=$(brew --prefix chruby) + fi + return 0 + else + return $_xit + fi } _chruby-from-homebrew-installed() { - [ -r $(brew --prefix chruby) ] &> /dev/null + [ -r _brew_prefix ] &> /dev/null } _ruby-build_installed() { @@ -64,8 +80,8 @@ _chruby_dirs() { } if _homebrew-installed && _chruby-from-homebrew-installed ; then - source $(brew --prefix chruby)/share/chruby/chruby.sh - source $(brew --prefix chruby)/share/chruby/auto.sh + source $_brew_prefix/share/chruby/chruby.sh + source $_brew_prefix/share/chruby/auto.sh _chruby_dirs elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then source /usr/local/share/chruby/chruby.sh |