Short answer
It's a bug.
Full answer
It looks like the "correct" visualisation is the one on the left, where the bold font are not rendered. For what I could understand (here is the reference) the bold attribute was used, originally, to set the highlighted version of the 8 base colours.
Historically, there has been a one-to-one correspondence between the bolded versions of the 8 default ANSI colors and the bright versions of the 8 default colors. Back in the day, when a color program demanded the display of bold text, it was probably just easier for terminal emulators to display a brighter version of whatever color the text was (and expect the user to interpret that as bold) than to display a typeface with a bold weight.
Basically, what is happening here is that, in order to use the full Solarized palette, with the orange, purple and all the levels of grey, the colours are called with the bold attribute, which in turn refers to the alternative 8 colours of the ANSI palette.
Terminal understands this correctly, and shows the orange and the comment grey in normal typesetting, whereas tmux adds an unnecessary bold font to them. In conclusion, the left side is correct whereas the right one is not.
Question 2
Is there a way to disable the bold rendering of tmux?
I still have to do some research about it, and I will update this answer as soon as I find something.
Answer 2
And here we have the solution! :)
In order to have tmux behave correctly we have to call it telling him that we are in a 256 colours enabled environment.
TERM=xterm-256color /usr/bin/tmux
For convenience we could alias
this (i.e. you add alias tmux="<the line above>"
to your ~/.bashrc
).
Calling tmux
as tmux -2
, for forcing tmux to run with 256 colours support (instead of redefining the TERM
environmental variable) will not allow for correct interpretation of the "bold-alternative" 8 colours (i.e. the brighter variant will also result having a bold typesetting). Therefore, I highly recommend to use the solution here above for having both correct 256 colours interpretation and non-bold "bold-alternative" colours.
The value of $TERM
must be screen-256color
, so that Vim correctly detects the availability of 256 colors. (tmux
reuses the terminal definitions of screen
, as this tool implements similar multiplexing.)
You either need to set the correct value for TERM
inside tmux adding the line
set-option -g default-terminal "screen-256color"
to ~/.tmux.conf
, or force 256 colors in your ~/.vimrc
via set t_Co=256
(which would be a workaround, and best guarded by if $TERM == 'screen'
if you also use non-high color terminals).
Best Answer
Solarized gives very specific colours. You can't really achieve these colours in a standard 256 colour palette. The only way you can achieve this is through setting up the exact colours in your terminal emulator, then apps think they're just using standard 16 colours (8 + 8 brights) but these have been accurately mapped to the Solarized palette.
Gnome terminal does not provide a very easy way to export/import palettes or profiles, but you can do it with this bash script:
Nb. here I've overridden Solarized's darkest and lightest colours. You can use the originals if you like, as commented.
Good enough. Now install the Solarized vim colours file by placing that file in
~.vim/colors/solarized.vim
.Now you can tell Vim to use that colour scheme with
colo solarized
. But this did not quite work and I had to tell Vim to use a 16 colour pallete,set t_Co=16
. I stuck both of those in my~/.vimrc
file.Now vim colours were working, but not if it ran inside tmux.
This next bit is very confusing. Most advice says about setting
TERM
outside tmux toxterm-256colors
, but when I did that tmux would not even start. It confused me, too: doesn't solarized say that the 256 colour palette is a poor approximation? Well, it is confusing, and anyway, it wasn't working so I needed another way forward:Create a file
/tmp/foo
containing:Then install this with
sudo tic /tmp/foo
Finally, alias
tmux
as follows:I now get exactly the right colours in the terminal, in vim, and in vim-inside-tmux. Nb. the
-2
option tellstmux
to use a 256 colour palette, which is really confusing because the env variables would appear to be telling it otherwise... I genuinely don't know, and I'm afraid I don't really care to climb that learning curve because I now have a beautiful coloured terminal that Just Works.