summaryrefslogtreecommitdiff
path: root/plugins/chruby/chruby.plugin.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/chruby/chruby.plugin.zsh')
-rw-r--r--plugins/chruby/chruby.plugin.zsh38
1 files changed, 17 insertions, 21 deletions
diff --git a/plugins/chruby/chruby.plugin.zsh b/plugins/chruby/chruby.plugin.zsh
index d7a28d4e2..1bcc6c6d9 100644
--- a/plugins/chruby/chruby.plugin.zsh
+++ b/plugins/chruby/chruby.plugin.zsh
@@ -2,7 +2,7 @@
_source-from-omz-settings() {
local _chruby_path _chruby_auto
-
+
zstyle -s :omz:plugins:chruby path _chruby_path || return 1
zstyle -s :omz:plugins:chruby auto _chruby_auto || return 1
@@ -15,6 +15,13 @@ _source-from-omz-settings() {
fi
}
+_source-from-default-location() {
+ [[ -r /usr/local/share/chruby/chruby.sh ]] || return 1
+
+ source /usr/local/share/chruby/chruby.sh
+ source /usr/local/share/chruby/auto.sh
+}
+
_source-from-homebrew() {
(( $+commands[brew] )) || return 1
@@ -22,8 +29,10 @@ _source-from-homebrew() {
# check default brew prefix
if [[ -h /usr/local/opt/chruby ]];then
_brew_prefix="/usr/local/opt/chruby"
+ elif [[ -h /opt/homebrew/opt/chruby ]]; then
+ _brew_prefix="/opt/homebrew/opt/chruby"
else
- # ok , it is not default prefix
+ # 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
@@ -34,27 +43,14 @@ _source-from-homebrew() {
source $_brew_prefix/share/chruby/auto.sh
}
-_load-chruby-dirs() {
- local dir
- for dir in "$HOME/.rubies" "$PREFIX/opt/rubies"; do
- if [[ -d "$dir" ]]; then
- RUBIES+=("$dir")
- fi
- done
-}
-
# Load chruby
-if _source-from-omz-settings; then
- _load-chruby-dirs
-elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then
- source /usr/local/share/chruby/chruby.sh
- source /usr/local/share/chruby/auto.sh
- _load-chruby-dirs
-elif _source-from-homebrew; then
- _load-chruby-dirs
-fi
+_source-from-omz-settings || \
+ _source-from-default-location || \
+ _source-from-homebrew
-unfunction _source-from-homebrew _source-from-omz-settings _load-chruby-dirs
+unfunction _source-from-homebrew \
+ _source-from-default-location \
+ _source-from-omz-settings
## chruby utility functions and aliases