Created
July 14, 2011 17:21
-
-
Save ahawthorne/1082932 to your computer and use it in GitHub Desktop.
setup function for ~/.rvmrc
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
# 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