My question arises from the necessity of understanding why I have now (after multiple trials) Terminal and tmux supporting 256 colours and
tput colors telling me there are only 8 of them.
Let's start from the beginning.
I'm using a Ubuntu box, Guake, tmux, Vim and I love the theme Solarized. They were looking pretty awful, so I decided to enable the 256 colours support and play a bit around.
Let's see what happens for my Terminal.
tput colors says there are 8 colours. I personally set them to purple, on the left, and of course on the right we have 2 different shades of blue.
xterm. (To have the coloured
eval this in my
Vim also looks fine, despite the fact that I call it with the
256 flag in an environment where 256 colours are not supported.
set t_Co=256 let g:solarized_termcolors=256 colorscheme solarized
The only guy who complains about the reduced colour space is tmux. Calling
tmux provides the "wrong" expected results.
tmux with the
-2 flag makes everything work fine, magically.
Now the only thing that I understand is that
-2 is equivalent of
export TERM=screen-256color (source).
Guake behaves analogously to Terminal and both of them answer
xterm to the question
Basically, does anyone understand why everything works even if it shouldn't?
- Am I sadistic that I complaining why things work? Maybe.
- Is there a better reason? Sure: I'd like to fix the appearance of other Ubuntu boxes in my office, and I'd like to understand why things work or don't work.
Running this script (slightly modified) on my
xterm provides the following result: 256 colours, but only 16 are displayed correctly.
Then, changing terminal's profile, also these 16 colours change.
More tests are following.
From left to right, top to bottom, we have Solarized colour theme,
256dark, then default (Tango) colour scheme,
Observation: in theory the
ansi-dark on Solarized colour scheme should have match closely the
256dark. This is not clearly happening for the specific listed files. Instead, this quite happens when in the working directory there are folders, text files and symbolic links. Conclusion: no much attention as been paid while encoding the
xterm supports 256 colours, despite what
tput colors says. Programs can refer to the
ansi palette (customisable by the user) or define their colours, picking from a total of 256 colours.