Skip to content

Instantly share code, notes, and snippets.

@ahawthorne
Created July 14, 2011 17:21
Show Gist options
  • Save ahawthorne/1082932 to your computer and use it in GitHub Desktop.
Save ahawthorne/1082932 to your computer and use it in GitHub Desktop.
setup function for ~/.rvmrc
# This function will pull an .rvmrc from a gist and place it in a directory
# Add this function to /home/username/.rvmrc
#
# usage: setup_rvmrc gemset /path/to/application/
# example setup_rvmrc 1.9.2@app /var/www/app/
#
# NOTE: The trailing slash on the path is important.
function setup_rvmrc() {
_REPO="git://gist.github.com/1080580.git"
_GIT=$(which git)
_SED=$(which sed)
_MKTEMP=$(which mktemp)
if [ -d "$2" -a -w "$2" ];
then
_TMP=$($_MKTEMP -d /tmp/set_rvmrc.XXXXXX)
$_GIT clone $_REPO $_TMP
$_SED -i "s/^rvm [^@]*@.*/rvm $1/" $_TMP/.rvmrc
cp -vf $_TMP/.rvmrc ${2}
rm -rf $_TMP
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment