Wednesday, 21 May 2008

Public service announcement: urxvt (rxvt-unicode)

One good habit I have picked up over the years is to have a separate environment for each project that I am working on. For example, I might want to work on project foo but to do that, I need /opt/foo/bin to be in the path. So what I would do in the bad old days is:

$ cd /path/to/project/foo
$ export PATH=`pwd`/bin:$PATH

Obviously, this can get annoying fast so I would put it in a script and then do the following:

$ cd /path/to/project/foo
$ source

The problem with the above is that it involves two more manual steps. Grr... Fortunately, most terminal emulators have the option to execute a script when a certain "profile" of the shell starts.

I have been using gnome-terminal as a terminal emulator for a long time and it has an option to execute a shell script as described above. Unfortunately, when setting the shell script to run in Ubuntu 8.04 through some pointy-clicky magic, it crashes *all* my windows. I don't even know how its managing to do that. On top of that, setting the script to run is quite unintuitive to me. So with these two things together, I finally got fed up and installed rxvt-unicode.

This program is blazing fast. The only thing I'm missing is tabs but I hear that is possible as well. urxvt uses the Xdefaults file which you can use to set system-wide or application specific options for X programs. The relevant settings for me look like this:

URxvt.background: black
URxvt.foreground: green
URxvt.scrollBar: false
URxvt.font: xft:Bitstream Vera Sans Mono:pixelsize=13

There is a daemon that you can run in the background (call like urxvtd -q -o -f) which you would run when you log in. This daemon starts all urxvt terminals within the same process which can save memory but has the disadvantage of taking all your terminals down if one crashes (which I presume doesn't happen too often!) To request a new terminal window, use the program urxvtc.

Back to my original point (I have one?), given that your shell starting script looks like this:

# Usage:

cd /path/to/project/foo/
pushd $1

You can set up shortcuts to start in that shell by using the command:

# Start a shell for feature_foo
urxvtc -e bash /home/sohail/src/foo/ branches/feature_foo
# start a shell for trunk
urxvtc -e bash /home/sohail/src/foo/ trunk

This ends the public service announcement. You will be returned to your regularly scheduled feed reeding.


Anonymous said...

urxvt -pe tabbed

will get you tabs

Sohail Somani said...

Thanks! That works great.