Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between xterm-color & xterm-256color?

I've come across both xterm-color and xterm-256color as options when trying to set up my terminal program to use color - i.e. you can set your TERM environment variable to either one.

I was wondering if anyone can describe the difference between the two?

I've searched for documentation on my Ubuntu server as well as my mac but haven't found any. I've only been able to find various binary files in /usr/share/terminfo.

like image 710
user12345 Avatar asked Apr 03 '12 23:04

user12345


People also ask

How do I set xterm color?

If you don't want to change your default, use command line arguments: xterm -bg blue -fg yellow. Setting xterm*background or xterm*foreground changes all xterm colors, including menus etc. To change it for the terminal area only, set xterm*vt100.

What is xterm used for?

Description. The xterm program is a terminal emulator for the X Window System. It provides DEC VT102 and Tektronix 4014 compatible terminals for programs that cannot use the window system directly.

Does Konsole support 256 colors?

However, xterm is limited to no more than 256 colors, which I have currently been using. I just recently learned that the Konsole terminal actually supports this True Color, but unfortunately I cannot find the correct environment to use these colors. I have only been able to set "konsole-256color" so far.


3 Answers

xterm-256color describes Xterm with support for 256 colors enabled. xterm-color describes an older branch of Xterm that supports eight colors. xterm-color is not recommended, since it describes a variant of Xterm that’s less functional and that you’re not likely to be using. Usually you’ll want to use xterm, xterm-16color or xterm-256color.

In particular, xterm-256color is the default for Terminal starting with Mac OS X 10.7 Lion, with the next-best recommended values being xterm-16color or xterm (which only describes support for eight ANSI colors). Prior to 10.7, xterm-color was the default because Terminal didn’t support some critical features described by the recommended Xterm terminfo values, e.g., Background Color Erase (BCE), modern codes for switching main/alternate screens, 256 colors.

Sometimes people explicitly set TERM to xterm-color (as opposed to the recommended Xterm values) to disable functionality or work around incompatibilities between the available terminfo values on a particular computer and the terminal emulator being used.

Note that technically Terminal should have its own up-to-date terminfo values that describe exactly which features it supports, instead of using the values for Xterm, but:

  1. There isn’t one that’s up to date currently. nsterm represents Terminal’s ancestor from NeXTSTEP. Someone apparently has updated nsterm recently (sometime in the past couple of years), but I don’t know whether that has made its way into the ncurses distribution, and it may not be completely up to date with Terminal in 10.7.
  2. A number of programs and shell customization scripts explicitly check whether $TERM starts with (or is equal to) xterm. So some users would still need to know about using the recommended Xterm values with Terminal for compatibility with those.

If you’re not familiar with the terminfo system, take a look at the x-man-page://5/terminfo man page. Also, you can use the infocmp command to view the current terminfo settings or compare two different ones, e.g., infocmp xterm-color xterm-256color will show you all the differences between those two.

like image 164
Chris Page Avatar answered Oct 04 '22 17:10

Chris Page


It appears that xterm-256color is Terminal.app on OS/X. The differences are not tiny - I infocmp'd xterm-color and xterm-256color on an Ubuntu box and normalized them a bit, and got quite a few differences. I might even say xterm-256color isn't really xterm anymore.

Normally when you use a specific terminal emulator, you need to "just know" which terminfo entry works best with it. They're a matching pair, though sometimes you can, EG, use a vt100 terminfo entry on a vt220 terminal.

On the plus side, almost everything is vt100-compatible today.

like image 21
user1277476 Avatar answered Oct 04 '22 16:10

user1277476


According to the ncurses FAQ, xterm-color is long obsolete:

Originally, xterm-color corresponded to the color_xterm from the mid-1990s. That was superseded by XFree86 xterm in 1996.

and the terminal database gives details. It was originally intended as a generic terminal description, but from the outset that never was successful because it did not match XFree86 xterm, in particular the color behavior (i.e., the back color erase feature). No one uses nxterm now.

The xterm-256color terminal description is built up from the (XFree86) xterm terminal description by modifying the color behavior (adding more colors, but not the background color erase feature. Use infocmp to see the difference:

$ infocmp xterm-color xterm-256color |wc -l
122
$ infocmp xterm xterm-256color |wc -l
14
$ infocmp xterm xterm-256color
comparing xterm to xterm-256color.
    comparing booleans.
        ccc: F:T.
    comparing numbers.
        colors: 8, 256.
        pairs: 64, 32767.
    comparing strings.
        initc: NULL, '\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\'.
        oc: NULL, '\E]104\007'.
        rs1: '\Ec', '\Ec\E]104\007'.
        setab: '\E[4%p1%dm', '\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m'.
        setaf: '\E[3%p1%dm', '\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m'.
        setb: '\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m', NULL.
        setf: '\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m', NULL.

Because xterm-color was obsolete, it was largely ignored until some (anonymous, of course) developer at Apple decided to reuse it for Terminal.app (in 10.5 Leopard), although it was a poor fit. The nsterm-16color description in ncurses was contributed by someone (apparently outside Apple), to match the 10.5 behavior. Although xterm-color uses 8 colors, nsterm-16color as one might guess uses 16. Perhaps that contributed to users' confusion. In any case, the choice of terminal description for Terminal.app had no effect on Terminal.app other than to set the TERM environment variable, which many applications use to decide how to use the terminal.

Interesting enough, although much of the MacOS userland is from the BSDs, its ncurses configuration is not. MacOS has tic/infocmp utilities, unlike the BSDs (though Apple has not updated it for more than ten years: ncurses 5.7 was released in 2008). In later releases of MacOS, Terminal.app's developers changed the menu to provide "xterm-256color" rather than "xterm-color". That did not improve the user experience because the terminal behavior using the corresponding terminal descriptions was still different. The ncurses FAQ mentions that:

Additionally, Mac OS X 10.7 is reported to use xterm-256color as a default $TERM value. This differs from xterm-color in several ways, in particular, the support for bce. It also differs from the recommended nsterm-256color (infocmp reports 111 differences).

like image 30
Thomas Dickey Avatar answered Oct 04 '22 18:10

Thomas Dickey