From 3aa0d3bd66148f52ffc3cfdd8a682e62c9f284ec Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Sat, 27 Aug 2011 20:37:54 -0400 Subject: [PATCH] Abide by Mac conventions when installing gems. --- plugins/ruby/ruby.plugin.zsh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/plugins/ruby/ruby.plugin.zsh b/plugins/ruby/ruby.plugin.zsh index 08ca9c60..2b467b3c 100644 --- a/plugins/ruby/ruby.plugin.zsh +++ b/plugins/ruby/ruby.plugin.zsh @@ -1,6 +1,16 @@ -# TODO: Make this compatible with rvm. -# Run sudo gem on the system ruby, not the active ruby. -alias sgem='sudo gem' +# Install local gems according to Mac OS X conventions. +if [[ "$OSTYPE" == darwin* ]]; then + export GEM_HOME=$HOME/Library/Ruby/Gems/1.8 + export PATH=$GEM_HOME/bin:$PATH + + # gem is slow; cache its output. + cache_file="${0:h}/cache.zsh" + if [[ ! -f "$cache_file" ]]; then + echo export GEM_PATH=$GEM_HOME:$(gem env gempath) >! "$cache_file" + source "$cache_file" + else + source "$cache_file" + fi + unset cache_file +fi -# Find ruby file -alias rfind='find . -name *.rb | xargs grep -n'