20

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?

terdon
  • 242,166
Atcold
  • 1,603
  • What is the output of echo $TERM in and out of tmux? – jasonwryan Mar 09 '14 at 20:56
  • tmux says screen whereas terminal says xterm :) – Atcold Mar 09 '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 09 '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 09 '14 at 21:40
  • Put xterm*termName: xterm-256color in your ~/.Xresources and see if that makes a difference... – jasonwryan Mar 09 '14 at 21:42
  • I'm not that sure I understood exactly what you meant. Anyway, I created a new ~/.Xresources and entered the line xterm*termName: xterm-256color, saved and opened a new terminal. Nothing changed. (But I've never sourced the new ~/.Xresources.) Shall I do something more? – Atcold Mar 10 '14 at 02:59
  • xrdb -merge ~/.Xresources and then open a new terminal and check the value of $TERM... – jasonwryan Mar 10 '14 at 19:39
  • @illuminÉ, what you see is the current ~/.vimrc configuration file, not the one I use everyday. My question is about understanding why the same (strictly necessary) configuration has two different outputs when you run Vim in Terminal and in tmux. – Atcold Mar 13 '14 at 21:03
  • @Atcold I hear you. I can't reproduce that with lxterminal and t_Co=256. I have the exact same output. It's clear in the first image the secondary attributes i.e. bold etc. are not rendered like you noted. I'll think about it... –  Mar 15 '14 at 01:32
  • @jasonwryan, I did as you said and echo $TERM still answers xterm. Furthermore, nothing changed. Vim shows me (correct?) bold font only within tmux. Anything else that I could try in order to understand what's going on? [Question: how do I revert the xrdb merging? Rebooting would do the job?] – Atcold Mar 16 '14 at 18:44
  • Just run xrdb again after making changes to your ~/.Xresources and it will update the server with your new config. It looks like you don't have a 256 colour terminfo for your xterm. – jasonwryan Mar 16 '14 at 19:46
  • @jasonwryan, I am a bit lost. Actually, I'm not following what you are trying to test. It would be nice if you could add some explanations or references. On the other side, I've answered my question myself. Now (see my answer) I have a following up question. – Atcold Mar 16 '14 at 20:09

1 Answers1

24

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.

Atcold
  • 1,603