Skip to content

Instantly share code, notes, and snippets.

@dreamcat4
Created June 4, 2009 16:28
Show Gist options
  • Save dreamcat4/123695 to your computer and use it in GitHub Desktop.
Save dreamcat4/123695 to your computer and use it in GitHub Desktop.
ruby in .profile
export GEM_HOME=$HOME/.gem/ruby/active
export PATH=$HOME/.gem/ruby/active/bin:$PATH
# This is the bash version of the zsh script
# Load it in your .profile or .bashrc / .login script
# Its been tweaked for separate gem directories in $HOME/.gem
chruby ()
{
v=`ruby -e "puts RUBY_VERSION.split('.')[0,2].join('.')"`
if [ $v = "1.9" ]; then
cv="1.8"
cvf="1.8"
else
cv="1.9"
cvf="1.9.1"
fi
rubyexes=(erb gem irb rake rdoc ri ruby testrb)
for i in ${rubyexes[*]}; do
sudo unlink "/opt/local/bin/${i}"
sudo ln -s "/opt/local/bin/${i}${cv}" "/opt/local/bin/${i}"
done
unlink "$HOME/.gem/ruby/active"
ln -s "$HOME/.gem/ruby/${cvf}" "$HOME/.gem/ruby/active"
echo "Now Running: "`ruby -v`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment