Display current ruby version in gnome-terminal title.
You are using rvm and have some projects set up with different rubies and gemsets and want some reminder of which one is in use there are two ways of doing it.
You can modify you bash prompt so that it shows that information.
PS1="\[\e[0;36m\][\$(rvm current)]\n\[\e[1;33m\]\A >>\[\e[0m\]""]]]"

Looks great isn’t it!
We can do better than that, I personally don’t like long prompts maybe because when I started it was just a per cent sign and blinking cursor, oh yeah my first monitor at work had an orange tint to it and I was very jealous of other people around me who used black monitors with green text on them. But, I digress, better place for this information is a title bar on gnome monitor, doesn’t do much does it? Let’s employ it to show useful information. Edit .bashrc and somewhere at the end of it put these lines:
# sets a title with rvm info
case $TERM in
(xterm*)
PROMPT_COMMAND='echo -ne "\033]0;rvm-${rvm_version}($(rvm current)):${PWD/$HOME/~}\007"'
;;
esac
Change a prompt if you want to a smaller one too, comment out your PS1 and paste this one, you can also find a lot about modifying prompt on the interwebs or I will cover it in my next posts.
PS1="\[\e[1;32m\]%\[\e[1;33m\]>>\[\e[0m\]""]]]"

I plan also to right a post about .bashrc sometime. If your are anything like me and have bashrc more then a hundred lines your probably not interested but some other people might be.
Now it looks a lot better isn’t it?
RVM is a great software. Saved countless hours of configuration and frustration for me. I never liked using packages provided by disro, so I used to compile and put ruby in /opt/ruby don’t be afraid to do that it’s better then waiting for package maintainer to upgrade the package, ruby uses gems anyway. Rvm makes managing rubies super easy, just install any ruby you want list of available rubies is huge — (check out command: $rvm list known) and hack away! Don’t forget rvm bash completion though, just insert this line into your .bashrc file near the end:
[[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion
Now you can tab away and it will complete commands.
Like so:
$ rvm install <TAB> <TAB>
Created using VIM and Textile …
blog comments powered by Disqus