home icon contact icon rss icon last FM icon facebook icon
LinkedIn icon Delicious icon twitter icon  Archive pour le mot
clé Bash  RVM tips - Tell me my ruby version !  Now that Rails 3
is out, I'm starting to use it on recent application. But I also
have some work to do on older applications from time to time.
The first annoying thing is that older applictions are built for
Ruby 1.8.6 and Rails 3 works with Ruby 1.9.2. The other thing is
that the rails command is radicaly different from Rails 2.3.8 to
Rails 3.  Using RVM, I'm able to easily switch from one Ruby
version to another and from one gems configuration to another.
And this depending on the shell I am on.  The counterpart of
this is that I'm very confused and never know on which
configuration my shell is currently. So I needed a clear way to
know it. It would be great if the prompt can tell it to me. Here
is how to do that with bash :  # Copy this in ~/.bashrc
__ruby_ps1 ()         local g=`ruby -v | cut -d' ' -f2`
if [ -n "$1" ]; then