Last active
August 29, 2015 14:19
-
-
Save cevaris/c07f7c075008e1ac38e6 to your computer and use it in GitHub Desktop.
RVM project init script which creates the appropriate .ruby-version .ruby-gemset files
This file contains 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
#!/usr/bin/env zsh | |
# or #!/usr/bin/env bash | |
function rvm_init(){ | |
RVM_VERSION=$(echo $MY_RUBY_HOME | awk -F'-' '{print $2}') | |
RVM_GEMSET=$(basename $(PWD)) | |
for i in "$@" | |
do | |
case $i in | |
-g=*|--gemset=*) | |
RVM_GEMSET="${i#*=}" | |
;; | |
-r=*|--ruby=*) | |
RVM_VERSION="${i#*=}" | |
;; | |
*) # unknown option | |
;; | |
esac | |
done | |
print Gemset: $RVM_GEMSET | |
print Version: $RVM_VERSION | |
if ! type rvm > /dev/null 2>&1; then | |
print RVM is not installed | |
exit 1 | |
fi | |
rvm --create --ruby-version $RVM_VERSION@$RVM_GEMSET | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Installation
Copy and paste contents of
rvm-init.sh
into your~/.zshrc
or~/.bashrc
fileUsage
The following reuses the current Ruby version and directory name for the gemset as defaults
$ rvm_init
Custom ruby version and gemset name can be passed
$rvm_init --ruby=2.1.0 --gemset=custom_project