Skip to content

Instantly share code, notes, and snippets.

@alanstevens
Last active September 28, 2015 21:39
Show Gist options
  • Save alanstevens/1500291 to your computer and use it in GitHub Desktop.
Save alanstevens/1500291 to your computer and use it in GitHub Desktop.
A shell script for creating a new gemset. The default gemset name is the current working directory but there is an optional parameter for creating a custom gemset name
#!/usr/bin/env bash
readonly rubyversion="1.9.3"
# Source RVM as a function into local environment.
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
# First try to load from a user install
source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
# Then try to load from a root install
source "/usr/local/rvm/scripts/rvm"
else
printf "ERROR: An RVM installation was not found.\n"
exit;
fi
if [ "$#" -eq "0" ]
then
name="${PWD##*/}"
else
name="$1"
fi
rvm use $rubyversion
rvm gemset create $name
rvm use $rubyversion@$name
echo "rvm use $rubyversion@$name" >> .rvmrc
rvm rvmrc trust
gem env gemdir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment