Typical Technological Trickery

urxvt

01 Oct 2013

urxvt is a lightweight, platform independent unicode-compatible terminal emulator. This is probably the least interesting of the various tools I’ve set up for programming so I thought I’d do it first.

Why use it?

  • It is configured by a simple text file

    This means when I set up a new system (or, more likely, install a new version of linux) all I need to do to get things set up is copy a file into ~/. While terminal settings are not really a big deal (pretty colours mostly…) it’s much easier than all the clicking through menus needed to set up something like mate-terminal.

  • It works on any linux distribution

    Pretty self explanatory really. If I decide at some point to drop gnome-based linux distributions (which I nearly did a few months ago) I don’t want to have to find new versions of various programs.

  • It supports unicode, which lets you have maths characters in your terminal.

I’m sure there are plenty of terminal emulators which fufil these criteria but I’d heard (well, read) good things about urxvt so I gave it a try and it works nicely.

The setup

There should be packages available in pretty much any linux distribution. rxvt-unicode is the package name in Debian etc.

As mentioned above there isn’t all that much to configure here.

The following settings go in the ~/.Xdefaults file (for historical reasons related to xterm I think).

Set some nice colours:

! Colors
*background:                    #262626
*foreground:                    #c2c2b0

! Black + DarkGrey
*color0:                        #262626
*color8:                        #73675b
! DarkRed + Red
*color1:                        #a64211
*color9:                        #cc5214
! DarkGreen + Green
*color2:                        #638046
*color10:                       #80a65b
! DarkYellow + Yellow
*color3:                        #bf8c25
*color11:                       #e6a82d
! DarkBlue + Blue
*color4:                        #4d6d99
*color12:                       #6088bf
! DarkMangenta + Mangenta
*color5:                        #996b89
*color13:                       #bf86ac
! DarkCyan + Cyan
*color6:                        #6b8e99
*color14:                       #86b1bf
! LightGrey + White
*color7:                        #998a7a
*color15:                       #c2c2b0

Use pretty fonts:

urxvt*font: xft:Bitstream Vera Sans Mono:pixelsize=12:antialias=true:hinting=true

Do some fake transparency:

! Transparent background
URxvt*transparent: true
URxvt*shading: 20

With these transparency settings urxvt will display the desktop wallpaper through the back of the terminal. However this stays the same even if there are other windows underneath it, which is why I canlled it fake. If you use a tiling window manager (like me) this isn’t a problem because windows are almost never on top of each other. Alternatively, if you’re using a compositing window manager (or running xcompmgr) you can use the following settings to get real transparency:

urxvt*depth: 32
urxvt*background: rgba:0000/0000/0200/c800

Unfortunately with my setup this causes a bug where the border of urxvt windows is the wrong colour. It looks pretty ugly so I just stick with the fake transparency.

If you have transparency on you’ll probably want to disable the scroll bar with:

URxvt*scrollBar: false

otherwise it looks very strange. You don’t really need a scroll bar anyway: shift-pgup/pgdown is easier.

Finally there are some actually useful (rather than just pretty) settings:

! Save lots of lines
URxvt*saveLines:32767

! Only reset scroll position on keypress
URxvt.scrollWithBuffer: true
URxvt.scrollTtyOutput: false
URxvt.scrollTtyKeypress: true

These options are very useful (necessary really) when you have a process generating output very quickly and you need to actually see it.

Final notes

There are a couple of gotchas when configuring urxvt:

  • Comments CANNOT go at the end of lines! I wasted a lot of time trying to figure out why some of my colours had changed to a violent pink. Turns out adding a comment after a colour setting modifies the colour value and almost always makes it an invalid colour, which comes out pink.

  • Settings don’t apply until you restart the X-server! Or at least they don’t with my setup (running a .Xsession script with various mint goodies).