Why are xterm colors different than gnome-terminal colors?

Posted on

Problem :

In my work environment I use xterm, and sometimes gnome-terminal. I like gnome terminal, but some of the colors are much harder to read than those of my xterm.

I am wondering

  • why the colors display differently in the two terminals?
  • what configuration file or setting governs these colors?
  • how to copy my xterm colors to be used in gnome-terminal?

If it makes a difference, when I query the $TERM variable, both windows report xterm.

See xterm on the left, and gnome-terminal on the right. Note especially the 4th row, which is yellow on the xterm, and more orange on the gnome-terminal.

enter image description here

Solution :

Both terminals are pretending to be xterms, which are pretending to be DEC terminals. They both use the same character escape sequences to say “switch to Bold Red” or whatever. But what “Bold Red” looks like is open for interpretation.

You’d probably have to open the preferences for both Terminals, and check the color number values for both, and copy as appropriate. I’m not sure how to dump the colors in XTerm (i’m sure it’s compiled in XResources), but at least you could take this sceenshot, open it in an editor, such as Gimp, and see what the colors are. Then change your Gnome terminal colors to match.

xterm’s colors were likely chosen in the mid-1990s to more or less match the colors seen on an CGA display. The 256- and 88-color palettes were designed by Todd Larason (patch #111) and Stephen Wall (patch #115) in 1999 to provide easily programmed color palettes (and with compatibility of the 8-, 16-color subsets in mind). Aside from some dispute over the shade of blue used, those have been unchanged since then. The extended (beyond 16) colors are preset with compiled-in defaults generated by a script.

Any of the colors can be altered at runtime using control sequences, as well as queried for their values using control sequences. The xterm sources include several sample scripts, including query-color.pl, which shows how to query the colors using OSC 4.

The first 16 colors correspond also to X resources, whose values can be seen in

appres XTerm

Both gnome-terminal and konsole come with some odd color contrasts which can only be explained by having a design committee involved in look-and-feel. Thus, “black” may not actually be black, but a pleasing (sic) shade of gray. Both do allow customization, neither documents the colors used (aside from source-code).

The question about entering color-scheme information into gnome-terminal has been asked before. Here are a few useful links:

As noted here, gnome-terminal stores its settings (including color-schemes) via tools which change from release to release:

Leave a Reply

Your email address will not be published.