Get Rxvt-unicode With 256 Color Support on Ubuntu

rxvt-unicode (commonly called urxvt) already has 88 color support, and for most things, this is fine. But I recently just found the CSApprox plugin for vim, which lets you use Gvim themes in console vim. CSApprox actually does a pretty good job interpolating for 88 colors too, but it is best at 256.

So here’s my build log of compiling rxvt-unicode with the 256 color patch on Ubuntu Hardy, and debianizing (packaging) it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# I keep all custom deb's here, use any directory you want
cd ~/debian-src

# Make a place for rxvt-unicode
mkdir rxvt-unicode
cd rxvt-unicode/

# Get the source
apt-get source rxvt-unicode
cd rxvt-unicode-8.4/

# Apply 256 color patch, it's included with the source
patch -p1 < doc/urxvt-8.2-256color.patch

# Make sure you have all depdencies to build it
sudo apt-get build-dep rxvt-unicode

# Build it
dpkg-buildpackage -us -uc -rfakeroot

This will actually build three separate packages:

  • rxvt-unicode
  • rxvt-unicode-lite
  • rxvt-unicode-ml

All I care about is rxvt-unicode, but you might want -lite or -ml. If someone more adept in Debian package building than I am can tell me how to just compile one of these versions, that’d be great. :)

Moving along:

1
2
3
4
5
6
# Install it!
cd ~/debian-src/rxvt-unicode
sudo dpkg -i rxvt-unicode_8.4-1_amd64.deb

# As always, your arch may be different.  Replace amd64 with whatever is
# appropriate for you.

Now we need to make terminfo aware that rxvt-unicode supports 256 colors. The default terminfo entry you’ll have for rxvt-unicode will say 88, and that won’t be right for your new version.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
cd ~
infocmp -L rxvt-unicode > rxvt-unicode.terminfo

vi rxvt-unicode.terminfo
# Change the following from:
#
#    lines_of_memory#0, max_colors#88, max_pairs#256,
#
# to:
#
#    lines_of_memory#0, max_colors#256, max_pairs#32767

# Make .terminfo dir if you don't already have it
install -d .terminfo

# Rebuild terminfo for rxvt-unicode
tic -o .terminfo/ rxvt-unicode.terminfo

# Cleanup
rm rxvt-unicode.terminfo

That should do it.

To test it out, use this 256colors2.pl script (it’s the same one included in the xterm distribution). Download it, set it executable, open a fresh urxvt terminal, and run:

1
$ ./256colors2.pl

The output should look like:

Any program that supports 256 colors that had to fallback to 88 or even 8 colors can now be used in all its glory.

Does this make your consoling experience better? Let me know, post a comment.

Comments