Created
October 13, 2010 20:49
-
-
Save divoxx/624885 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Iterate the directory tree up looking for a .rvmruby file. | |
| # If it finds one, it executes rvm use ${content_of_.rvmruby}. | |
| # | |
| # This way you can easily automate ruby version switching for | |
| # some projects. | |
| rvm_set_ruby_for_path() { | |
| orig_path=$(pwd) | |
| until [[ -f .rvmruby || `pwd` == "/" ]]; do | |
| builtin cd .. | |
| done | |
| if [[ `pwd` != "/" ]]; then | |
| rvm use $(cat "`pwd`/.rvmruby") | |
| fi | |
| builtin cd "${orig_path}" | |
| } | |
| # Automatically change set rvm's ruby when directory changes. | |
| cd() { | |
| builtin cd $@ && rvm_set_ruby_for_path | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Usage example: | |
| $ echo "1.8.7@rails2" > Projects/Foo/.rvmruby | |
| $ echo "1.9.2@rails3" > Projects/Bar/.rvmruby | |
| $ cd Projects/Foo | |
| Using /Users/divoxx/.rvm/gems/ruby-1.8.7-p302 with gemset rails2 | |
| $ cd ../Bar | |
| Using /Users/divoxx/.rvm/gems/ruby-1.9.2-p0 with gemset rails3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment