Skip to content

Instantly share code, notes, and snippets.

@fd
Created April 2, 2009 12:28
Show Gist options
  • Save fd/89165 to your computer and use it in GitHub Desktop.
Save fd/89165 to your computer and use it in GitHub Desktop.
Switch between multiple rubies
function use_ruby_186 {
export MY_RUBY_HOME=/System/Library/Frameworks/Ruby.framework/Versions/Current/usr
export GEM_HOME=~/.gem/ruby/1.8
update_path
}
function use_ruby_187 {
export MY_RUBY_HOME=/opt/local
export GEM_HOME=~/.gem/ruby/1.8
update_path
}
function use_jruby_116 {
# after installing JRuby:
# sudo mkdir -p /opt/local/multiruby/jruby-1.1.6/bin/#
# sudo ln -s /opt/local/bin/jtestrb /opt/local/multiruby/jruby-1.1.6/bin/testrb
# sudo ln -s /opt/local/bin/jruby /opt/local/multiruby/jruby-1.1.6/bin/ruby
# sudo ln -s /opt/local/bin/jrake /opt/local/multiruby/jruby-1.1.6/bin/rake
# sudo ln -s /opt/local/bin/jirb /opt/local/multiruby/jruby-1.1.6/bin/irb
# sudo ln -s /opt/local/bin/jgem /opt/local/multiruby/jruby-1.1.6/bin/gem
export MY_RUBY_HOME=/opt/local/multiruby/jruby-1.1.6
export GEM_HOME=~/.gem/jruby/1.8
update_path
}
function use_ree_186 {
export MY_RUBY_HOME=/opt/ruby-enterprise-1.8.6-20090201
export GEM_HOME=~/.gem/ruby/1.8
update_path
}
function use_ruby_191 {
# after installing Ruby 1.9.1:
# sudo mkdir -p /opt/local/multiruby/ruby-1.9.1/bin/#
# sudo ln -s /opt/local/bin/testrb1.9 /opt/local/multiruby/ruby-1.9.1/bin/testrb
# sudo ln -s /opt/local/bin/ruby1.9 /opt/local/multiruby/ruby-1.9.1/bin/ruby
# sudo ln -s /opt/local/bin/rdoc1.9 /opt/local/multiruby/ruby-1.9.1/bin/rdoc
# sudo ln -s /opt/local/bin/gem1.9 /opt/local/multiruby/ruby-1.9.1/bin/gem
# sudo ln -s /opt/local/bin/erb1.9 /opt/local/multiruby/ruby-1.9.1/bin/erb
# sudo ln -s /opt/local/bin/irb1.9 /opt/local/multiruby/ruby-1.9.1/bin/irb
# sudo ln -s /opt/local/bin/ri1.9 /opt/local/multiruby/ruby-1.9.1/bin/ri
export MY_RUBY_HOME=/opt/local/multiruby/ruby-1.9.1
export GEM_HOME=~/.gem/ruby/1.9
update_path
}
function update_path {
export PATH=$GEM_HOME/bin:$MY_RUBY_HOME/bin:$PATH
export RUBY_VERSION="$(ruby -v | colrm 11)"
display_ruby_version
}
function display_ruby_version {
if [[ $SHELL =~ "bash" ]]; then
echo "Using $RUBY_VERSION"
fi
# On ZSH, show it on the right PS1
export RPS1=$RUBY_VERSION
}
use_ruby_187
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment