Historically I’ve never been one that required much to get the job done. For the better part of 10 years, I did my Java programming in Vim without any syntax highlighting and I was very productive. Over the past few years, as my focus has increasingly spread across multiple projects, I’ve started to embrace the little things that remove the need for me to keep track of my current development state. One such nicety is an informative bash prompt.
The first great step out of the standard prompt was the git_ps_tools project by Rein Henrichs. It’s one of the first things I setup when configuring a new machine.
Recently I’ve found myself needing to use the Ruby Version Manager project to easily switch between 1.8.6, 1.8.7 and 1.9.1 versions of Ruby for my various projects. Having multiple terminals using potentially different Ruby versions has become a little annoying. So, I’ve added a little more info to Rein’s prompt.
First, there is the ruby_pv script:
#!/bin/bash
# Return the ruby version
ruby -v | while read a b c; do echo "($b)"; done
Then I modified my original prompt:
export PS1="\[\033[01;32m\]\u\[\033[00m\]\[\033[01;31m\]\$(git_br)\[\033[01;32m\]\[\033[00m\]:\[\033[01;36m\]\$(git_pwd)\[\033[00m\]\$ "
To include the Ruby version:
export PS1="\[\033[01;32m\]\u\[\033[00m\]\[\033[01;30m\]\$(ruby_pv)\[\033[00m\]\[\033[01;31m\]\$(git_br)\[\033[01;32m\]\[\033[00m\]:\[\033[01;36m\]\$(git_pwd)\[\033[00m\]\$ "
So the resulting prompt looks like:
astone(1.8.7)(master):ruhl$
