tmux, Vim and Solarized
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.
Related videos on Youtube
Atcold
Musician, math lover, cook, dancer, 🏳️🌈, and an ass prof of Computer Science at New York University
Updated on September 18, 2022Comments
-
Atcold almost 2 years
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?).Question
Why does tmux allow for bold font whereas the terminal, where tmux is running, does not? Is it a bug or a feature?
-
jasonwryan over 10 yearsWhat is the output of
echo $TERM
in and out oftmux
? -
Atcold over 10 yearstmux says
screen
whereas terminal saysxterm
:) -
terdon over 10 years
-
jasonwryan over 10 years@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 over 10 yearsPut
xterm*termName: xterm-256color
in your~/.Xresources
and see if that makes a difference... -
Atcold over 10 yearsI'm not that sure I understood exactly what you meant. Anyway, I created a new
~/.Xresources
and entered the linexterm*termName: xterm-256color
, saved and opened a new terminal. Nothing changed. (But I've never sourced the new~/.Xresources
.) Shall I do something more? -
jasonwryan over 10 years
xrdb -merge ~/.Xresources
and then open a new terminal and check the value of $TERM... -
Atcold over 10 years@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. -
Admin over 10 years@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...
-
Atcold over 10 years@jasonwryan, I did as you said and
echo $TERM
still answersxterm
. 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 thexrdb
merging? Rebooting would do the job?] -
jasonwryan over 10 yearsJust 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 yourxterm
. -
Atcold over 10 years@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.
-
-
shxfee almost 10 yearsmuch love man!!