I just upgraded my gnome-terminal to use 256 colors, yet I am a bit puzzled on the reason why a terminal emulator can't support the full palette any modern desktop environment provides. I guess there's a technical reason for this, but I am not aware of it.
Linux – Why don’t Linux terminal emulators support full colors
gnome-terminallinuxterminal
Related Solutions
Weird aspects of Unix usually exist for good reason, so you're right to look for one. In this case, though, the good reason has long since become obsolete, and you're looking at an antique artifact of a bygone era.
Just about the only "terminal" in existence today is xterm & variants. Their capabilities vary very slightly, in ways that matter to only a few programs. If you just use xterm, and never touch the TERM variable or peek at the terminfo database, your life will generally be better.
The TERM variable communicates information about the terminal to the application through the environment, cf. man xterm. Changing it doesn't change the terminal; it just represents different terminal functionality to the application.
In the days of hardwired terminals, it was necessary to set TERM to represent the attached terminal. In the case of xterm, the software can set the variable itself. A quick tour of the vim docs shows (as you mention in your comment) that you have to change it to support color. That's progress for you.
why today ... emulate these old terminals like VT and not have something new?
The answer is as much anthropological as technical.
Before the GUI, access to Unix machines was via dumb terminals e.g. VT-100. Shells and utilities like top already existed. When the GUI became technologically practical (in which X played a role) in the 1980s, Unix users still needed to use those programs, so xterm was invented to emulate ye olde VT-100.
It was meant as a stopgap. "Everyone knew" that terminals were the past and GUIs were the future, and everyone expected "everything" to be accessed via the GUI. The original Macintosh, for example, had no arrow keys because why would you need them? Surely the cryptic Unix command line, with its missing vowels and helpless help
$ help
help: not found
would soon go the way of drum memory and punch cards. And that did come to pass, in a way: 9 users in 10 running Windows or OS X never see the command line except when tech support drops by to fix something.
Then two things happened to the Unix GUI, such as it was. Windows in particular drained the money out of the market. There was a big move to standardize it (cf. Sun News and OSF Motif), and then it ground to a halt around 1990. Just about that time the Internet took off, and things graphical in Unix moved into the web browser. The motivation and the money (pretty much the same thing) to engineer a complete GUI for Unix and render everything in section 8 of the manual obsolete disappeared.
There is another reason, too, that very few foresaw: the command line has certain advantages over the GUI. Pipelines and regular expressions are remarkably powerful, not to mention repeatable with shell history and scripts. Even in the context of a GUI, the command line remained useful. So much so that it continues to be enhanced even today.
As your question suggests, what's needed is a re-examination of the assumption that the GUI would triumph, and a re-invention of the terminal as an integral part of it. We need a new terminal, with proportional fonts and bit-addressable graphics in the terminal.
Unfortunately, no one seems ready to do that. No corporate entity will undertake it; the market is huge, but still only a tiny proportion of computer users. The logical funder would be a government agency like DARPA, but human-interface research is considered "done" these days (didn't we already invent the GUI?). Until more people -- lots more people -- recognize the need, xterm is your friend, and likely to be your grandson's friend, too.
There is some information on 256-color support in the tmux FAQ.
Detecting the number of colors that the terminal supports is unfortunately not straightforward, for historical reasons. See Checking how many colors my terminal emulator supports for an explanation. This means that
- tmux cannot reliably determine whether the terminal supports more than 8 colors;
- tmux cannot reliably communicate to the application that it supports more than 8 colors.
When you're in tmux, the terminal you're interacting with is tmux. It doesn't support all of xterm's control sequences. In particular, it doesn't support the OSC 4 ; …
control sequence to query or set color values. You need to use that while directly running in xterm, outside tmux.
If you run tmux -2
, then tmux starts with 256-color support, even if it doesn't think that your terminal supports 256 colors (which is pretty common).
By default, tmux advertises itself as screen
without 256-color support. You can change the value of TERM
in .tmux.conf
to indicate 256-color support:
set -g default-terminal "screen-256color"
You can use TERM=xterm-256color
or TERM=screen-256color
on Ubuntu. These values will only cause trouble if you log in to a remote machine that doesn't have a termcap/terminfo entry for these names. You can copy the entries to your home directory on the remote machine; this works with most modern terminfo implementations.
# From the Ubuntu machine to a machine that doesn't have *-256color terminfo entries
ssh somewhere.example.com mkdir -p .terminfo/s .terminfo/x
scp -p /lib/terminfo/s/screen-256color somewhere.example.com:.terminfo/s/
scp -p /lib/terminfo/x/xterm-256color somewhere.example.com:.terminfo/x/
Best Answer
There are no technical reason for it not to be possible. However there are not many reasons to why its not practical. With the limited amount of screen real-estate that characters represents on screen you would have a hard time finding use for more then 256 simultaneous colors on the screen.
As far as I know terminal clients use indexed color space. One of the reasons for that is that in its simplest form, 256 indexed colors can be described with one byte. Whilst RGB color space need two or three bytes. Considering how colors are encoded in a terminal stream, each color would at least be two bytes + any smart markup. This might not be a big issue memory vise, however when on a real time network stream it might add up on latency, especially (correct me if I am wrong) each character is sent in it's own package.