Created
April 11, 2011 14:19
-
-
Save bretweinraub/913593 to your computer and use it in GitHub Desktop.
better rvm use
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
rvmuse () { | |
if [ -d ~/.rvm/gems ]; then | |
rvmdir=~/.rvm/gems | |
else | |
if [ -d /usr/local/rvm/gems ]; then | |
rvmdir=/usr/local/rvm/gems | |
else | |
echo "RVM installed?" | |
return | |
fi | |
fi | |
gemsets=$(grep '@' < <(cd $rvmdir; find . -maxdepth 1 -type d )|sort) | |
set $gemsets | |
x=0 | |
while [ $# -gt 0 ];do | |
((x=$x+1)) | |
echo $x"): "$1 >&2 | |
shift | |
done | |
read line | |
x=0 | |
set $gemsets | |
while [ $# -gt 0 ];do | |
((x=$x+1)) | |
if [ "$line" = "$x" ]; then | |
eval "rvm use "$(echo $1 | cut -d/ -f2-) | |
fi | |
shift | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment