Skip to content

Instantly share code, notes, and snippets.

@sporkd
Created May 30, 2009 05:48
Show Gist options
  • Save sporkd/120397 to your computer and use it in GitHub Desktop.
Save sporkd/120397 to your computer and use it in GitHub Desktop.
# Shell script for switching between ruby versions
#
# Hat Tip To
# http://www.metaskills.net/2009/1/20/multiruby-the-macports-way-testing-your-rails-apps-with-ruby-1-9
#
chruby () {
v=`ruby -e "puts RUBY_VERSION.split('.')[0,2].join('.')"`
if [ $v = "1.9" ]; then
cv="1.8"
else
cv="1.9"
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
echo "Now Running: "`ruby -v`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment