*nix Tip of the Day: rxvt-unicode and terminfo

An important part of a *nix system is a good terminal emulator. For some, this means the classic xterm. The same xterm that's happy to use 7 MiB of resident memory for each instance. Or perhaps you run a full DE like Gnome and are happy to use gnome-terminal and enjoy 19 MiB of resident. Personally, I use rxvt-unicode (urxvt). It's a very lightweight version of rxvt which has neato features like full Unicode support and a daemon mode that lets you pool multiple instances. For example, my urxvtd processs is using 41 MiB of resident, but hosting 9 urxvtc clients (a little over 4 MiB per client). It's several sorts of awesome.

Now, another important part of the terminal emulator infrastructure is the terminfo library (successor to termcap). This library contains terminfo definitions for pretty much every terminal emulator out there and allows the shell to make intelligent decisions about things like fonts, colors, and sizes. Unfortunately, I said "pretty much every terminal emulator" for a reason. rxvt-unicode is not one of the terminal emulators that is part of the standard library. Thus, my prompt, which normally looks like [11:06] <roguelazer@CaveOfBirds> ~ % ends up looking like 33mCaveOfBirds> ~ % when I log into a server that I've never logged into before.

So, what's the resolution to this problem? It took me a while to find out, but the key is the tic utility (which stands for terminfo compiler). Terminfo descriptions are distributed as a (almost) human-readable source format. urxvt's can be found here. Once you've acquired a source file, simply run tic on it. If you run tic as a normal user, the compiled terminfo description will be installed to ~/.terminfo; if run as root, it will be installed system-wide in /usr/share/terminfo.

As usual, come back later for some new and exciting tips.


Comments