diff --git a/plugins/rbenv/rbenv.plugin.zsh b/plugins/rbenv/rbenv.plugin.zsh index ae37404cd..a62dd5602 100644 --- a/plugins/rbenv/rbenv.plugin.zsh +++ b/plugins/rbenv/rbenv.plugin.zsh @@ -1,5 +1,18 @@ +_homebrew-installed() { + type brew &> /dev/null +} + +_rbenv-from-homebrew-installed() { + brew --prefix rbenv &> /dev/null +} + FOUND_RBENV=0 -for rbenvdir in "$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" ; do +rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv") +if _homebrew-installed && _rbenv-from-homebrew-installed ; then + rbenvdirs=($(brew --prefix rbenv) "${rbenvdirs[@]}") +fi + +for rbenvdir in "${rbenvdirs[@]}" ; do if [ -d $rbenvdir/bin -a $FOUND_RBENV -eq 0 ] ; then FOUND_RBENV=1 export RBENV_ROOT=$rbenvdir