19

Premises

Browsing around tmux, Vim and Solarized I can find lots of complains about 256 colours and "user experience". Well, I'm having the opposite "problem", i.e. Vim works well with a full Solarized theme only in tmux.

Background

I've been tweaking and tuning around for a bit now with my Ubuntu terminal's and Guake's colour scheme and I almost got to the perfection which is reached when I'm using tmux, which in turn means always. I'm trying now to understand why this is happening.

Here below there are two Terminals, the one on the left is running only Vim (showing the current .vimrc) whereas the other is running Vim inside a tmux session. As you can clearly see, only in the tmux session the fonts are bold, which I guess is correct (or not?).

enter image description here

Question

Why does tmux allow for bold font whereas the terminal, where tmux is running, does not? Is it a bug or a feature?

  • What is the output of echo $TERM in and out of tmux? – jasonwryan Mar 9 '14 at 20:56
  • tmux says screen whereas terminal says xterm :) – Atcold Mar 9 '14 at 20:58
  • @jasonwryan read the OP's other question here and Gilles's answer to a similar one here. Apparently $TERM is not that relevant. – terdon Mar 9 '14 at 21:14
  • @terdon it is material in this case: tmux requires that the term is set to screen (or a variant) and xterm is, by default, an 8 colour term. That's why the OP is seeing the difference. – jasonwryan Mar 9 '14 at 21:40
  • Put xterm*termName: xterm-256color in your ~/.Xresources and see if that makes a difference... – jasonwryan Mar 9 '14 at 21:42
22

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).

tmux interprets correctly the non-bold "bold-alternative" colours

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.

  • much love man!! – shxfee Sep 25 '14 at 0:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.