mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-22 04:51:12 +02:00
Merge pull request #1 from tilgovi/chruby-performance
Avoid brew unless necessary to find chruby
This commit is contained in:
commit
26d0d550ba
1 changed files with 24 additions and 23 deletions
|
|
@ -36,33 +36,34 @@ if _ruby-build_installed; then
|
||||||
compdef _ruby-build ruby-build
|
compdef _ruby-build ruby-build
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_source_from_omz_settings() {
|
|
||||||
local _chruby_path
|
|
||||||
local _chruby_auto
|
|
||||||
|
|
||||||
zstyle -s :omz:plugins:chruby path _chruby_path
|
|
||||||
zstyle -s :omz:plugins:chruby auto _chruby_auto
|
|
||||||
|
|
||||||
if [[ -r "$_chruby_path" ]]; then
|
|
||||||
source "$_chruby_path"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -r "$_chruby_auto" ]]; then
|
|
||||||
source "$_chruby_auto"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function () {
|
function () {
|
||||||
local _chruby_homebrew_prefix="$(brew --prefix chruby 2> /dev/null)"
|
local _path
|
||||||
|
local _auto
|
||||||
|
local _prefix="/usr/local/share/chruby"
|
||||||
|
|
||||||
if _homebrew-installed && [[ -r "$_chruby_homebrew_prefix" ]] ; then
|
# Honor explicit user preference
|
||||||
source "${_chruby_homebrew_prefix}/share/chruby/chruby.sh"
|
zstyle -s :omz:plugins:chruby path _path
|
||||||
source "${_chruby_homebrew_prefix}/share/chruby/auto.sh"
|
zstyle -s :omz:plugins:chruby auto _auto
|
||||||
elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then
|
|
||||||
source /usr/local/share/chruby/chruby.sh
|
# Default to /usr/local/share/chruby if either is not defined
|
||||||
source /usr/local/share/chruby/auto.sh
|
[[ -r "$_path" ]] || _path="${_prefix}/chruby.sh"
|
||||||
else
|
[[ -r "$_auto" ]] || _auto="${_prefix}/auto.sh"
|
||||||
_source_from_omz_settings
|
|
||||||
|
# Fall back on homebrew
|
||||||
|
if [[ ! ( -r "$_path" && -r "$_auto" ) ]]; then
|
||||||
|
if _homebrew-installed; then
|
||||||
|
_prefix="$(brew --prefix chruby 2> /dev/null)/share/chruby"
|
||||||
|
[[ -r "$_path" ]] || _path="${_prefix}/chruby.sh"
|
||||||
|
[[ -r "$_auto" ]] || _auto="${_prefix}/auto.sh"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -r "$_path" ]]; then
|
||||||
|
source "$_path"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -r "$_auto" ]]; then
|
||||||
|
source "$_auto"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue