256 colors, rxvt and gnu screen
Feb 20, 2009I like my color terminal and use rxvt, urxvt and on OSX iTerm with rxvt emulation but I do nearly everything inside gnu screen sessions over ssh. A quirk is that I use more than the default eight to sixteen colors for highlighting and most of the time it doesn’t work properly. The following is my work around.
First, make sure the terminal or emulator is actually reporting the correct term type. For reasons I can’t understand, it’s popular to set it by hand. This is wrong and the results vary but it works just often enough on Linux that it gets perpetuated. For my iTerm with rxvt emulation, I have:
opal% echo $TERM
rxvt
Check the local terminal for proper color output using any of several
scripts, I use the one by Todd Larsen called `256colors2.pl`, I found
a copy here. It
should look like this:
If that succeeded, log into the target host and confirm that it also
works.
If not, it may be that the host has an outdated terminfo library. At one
time Eric Raymond kept the file up to date but
terminfo.src.gz is
more actively maintained. You’ll need a relatively recent of version of
tic
, acquired from the ncurses
project, to compile
the src into a set of definitions. Create a new set for yourself:
$ tic -s -x -o $HOME/share/terminfo terminfo.src
Try setting TERMINFO
and retrying the above steps:
$ TERMINFO=$HOME/share/terminfo && export TERMINFO
$ ./256colors2.pl