April 2017

S M T W T F S
      1
2345678
910111213 1415
16171819 2021 22
23242526272829
30      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags

April 10th, 2009

marcmagus: (regexp)
Friday, April 10th, 2009 01:02 pm

For quite a while now, I have been puzzled that, while vim is perfectly willing to use colors other than the 16 ANSI colors when I run it directly from my terminal emulator, rxvt-unicode (which rarely happens), when I am running under screen is drops back to 16 color support. Rxvt-unicode has 88 colors.

Additionally, when I tried to play around with 88-color support, I noticed that while I could get test programs to give the expected effect in straight urxvt, when I ran them under screen the colors were all messed up, and the color cube was primarily made up of ugly olive greens and browns, with some dark blues. Really strange.

Somehow, this time, the latter clicked in my head and I figured out the problem. screen, very helpfully, when it knows it is connected to an 88 color terminal, and receives color codes for colors >15, converts the color codes from the 256 color space it thinks it is receiving to the 88 color space it knows the terminal is expecting. I imagine this would be very useful if you found yourself primarily using a 256 color terminal and occasionally using an 88 color terminal instead, and you had screen configured to report 256 colors to everything which uses it, but it's actually damned annoying when you exclusively use an 88 color terminal.

Workarounds

I haven't tested this, but it should be possible to get things working correctly by setting up your terminfo database entry for screen.rxvt-unicode to specify colors#256 rather than 88 (or 8). You'd probably also want to set screen to provide an appropriate TERMCAP setting for its windows. The drawback is that everything will be trying to provide 256 colors, and screen converting it down to 88, which might bother you.

What I've done, instead, is to set the terminfo for screen.rxvt-unicode to colors#88. Then, lie to screen that rxvt-unicode is a 256-color terminal, so screen stops doing on the fly conversions, with:

termcapinfo rxvt-unicode 'Co#256:pa#256' 'Co#88'

(Note that this instructs screen to tell the shell that the terminal is 88-color, so anything which still uses TERMCAP will get it right, too. You'll have to set up the terminfo database on every host you connect to, though, because that's how these things work. (I think I've mentioned my frustration with terminfo before.))

Bold Dim Colors

While I was at it, I discovered that rxvt-unicode has a way to turn off the feature that automatically assumes that bold ANSI (0-7) colors should be bright as well as bold. Turning it off allows you to have your dim colors be bold, and you can also have your bright colors be non-bold, so bold once again means actual bold. The drawback is that there are a lot of things which are configured to indicate bright by turning on the bold bit (because that's the way it used to work, and it'll work on any terminal), so if you want those to be offering bright colors rather than bold dim colors, you'll have to reconfigure them. That's a lot of work.

Ideally, I'd like a way to have rxvt-unicode do things the old way (bright bold) when getting the old signal (\E[01;3Xm, where X is the 0-7 color code), and do things the new way (just bright) when getting colors using the newer extended format (\E[38;5;XXm, where XX is the 0-whatever color code).

In the meantime, you can turn on this mode by setting the appropriate resource string:

URxvt.intensityStyles: False