From e9a9deacb09196a48a39adc827d861e1896f4c59 Mon Sep 17 00:00:00 2001 From: Tima Maslyuchenko Date: Mon, 18 Jun 2012 20:15:57 +0300 Subject: [PATCH 1/2] rbenv plugin now uses 'brew --prefix rbenv' command to find rbenv folder --- plugins/rbenv/rbenv.plugin.zsh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/rbenv/rbenv.plugin.zsh b/plugins/rbenv/rbenv.plugin.zsh index ae37404c..a0a64c7e 100644 --- a/plugins/rbenv/rbenv.plugin.zsh +++ b/plugins/rbenv/rbenv.plugin.zsh @@ -1,5 +1,18 @@ +function is_homebrew_installed() { + type brew &> /dev/null +} + +function is_rbenv_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 is_homebrew_installed && is_rbenv_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 From 5931f64308cbf4b0a8ef740a6b4eda5834479bd7 Mon Sep 17 00:00:00 2001 From: Tima Maslyuchenko Date: Mon, 18 Jun 2012 21:29:24 +0300 Subject: [PATCH 2/2] sanitized code according to coding style --- plugins/rbenv/rbenv.plugin.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/rbenv/rbenv.plugin.zsh b/plugins/rbenv/rbenv.plugin.zsh index a0a64c7e..a62dd560 100644 --- a/plugins/rbenv/rbenv.plugin.zsh +++ b/plugins/rbenv/rbenv.plugin.zsh @@ -1,14 +1,14 @@ -function is_homebrew_installed() { +_homebrew-installed() { type brew &> /dev/null } -function is_rbenv_installed() { +_rbenv-from-homebrew-installed() { brew --prefix rbenv &> /dev/null } FOUND_RBENV=0 rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv") -if is_homebrew_installed && is_rbenv_installed ; then +if _homebrew-installed && _rbenv-from-homebrew-installed ; then rbenvdirs=($(brew --prefix rbenv) "${rbenvdirs[@]}") fi