Skip to content

Instantly share code, notes, and snippets.

@bretweinraub
Created April 11, 2011 14:19
Show Gist options
  • Save bretweinraub/913593 to your computer and use it in GitHub Desktop.
Save bretweinraub/913593 to your computer and use it in GitHub Desktop.
better rvm use
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