Wrong colors in airline text when in tmux but ok in wsltty #196

Closed
opened 2026-01-30 21:45:15 +00:00 by claunia · 14 comments
Owner

Originally created by @persep on GitHub (Mar 15, 2018).

Originally assigned to: @zadjii-msft on GitHub.

  • Your Windows build number: Microsoft Windows [Version 10.0.16299.309]

  • What you're doing and what's happening: see description below

  • What's wrong / what should be happening instead: see description below

Hi,
when in terminal (ubuntu on windows) and in wsltty (mintty 2.8.4 wsltty 1.8.4) I have vim with gruvbox and the gruvbox airline all working ok:
Imgur

If I change to the wombat airline theme, for testing purposes, it also works ok:
Imgur

So the airline themes work fine in the terminal but if I open vim inside tmux on ubuntu for windows I get a different color in the text from the vim status line but it's the correct colors in tmux on wsltty. Look at the different color in the "NORMAL" text
Imgur

And if a change to the wombat airline you can see the "NORMAL" text color is also lighter:
Imgur

It happens to all the other airline themes like solarized for example.
I've tried this in vim 8-1605 and tmux 2.1 and 2.6. I've also tried with tmux in 256 and 24 bit colors and it doesn't make a difference. Vim colors schemes are ok in tmux but not the text color from the airline themes. They render with wrong colors inside tmux on the ubuntu on windows terminal but correctly in tmux on wsltty.

My .tmux.conf file is:

set -g default-terminal "tmux-256color"                                              
# enable 24 bit support                                                              
set -g terminal-overrides ',xterm-256color:Tc'  

And my vimrc is here

Originally created by @persep on GitHub (Mar 15, 2018). Originally assigned to: @zadjii-msft on GitHub. * Your Windows build number: Microsoft Windows [Version 10.0.16299.309] * What you're doing and what's happening: see description below * What's wrong / what should be happening instead: see description below Hi, when in terminal (ubuntu on windows) and in wsltty (mintty 2.8.4 wsltty 1.8.4) I have vim with gruvbox and the gruvbox airline all working ok: ![Imgur](https://i.imgur.com/7I8xNWy.jpg) If I change to the wombat airline theme, for testing purposes, it also works ok: ![Imgur](https://i.imgur.com/9DD2mZs.jpg) So the airline themes work fine in the terminal but if I open vim inside tmux on ubuntu for windows I get a different color in the text from the vim status line but it's the correct colors in tmux on wsltty. Look at the different color in the "NORMAL" text ![Imgur](https://imgur.com/AjInN9G.jpg) And if a change to the wombat airline you can see the "NORMAL" text color is also lighter: ![Imgur](https://imgur.com/M4J8FKJ.jpg) It happens to all the other airline themes like solarized for example. I've tried this in vim 8-1605 and tmux 2.1 and 2.6. I've also tried with tmux in 256 and 24 bit colors and it doesn't make a difference. Vim colors schemes are ok in tmux but not the text color from the airline themes. They render with wrong colors inside tmux on the ubuntu on windows terminal but correctly in tmux on wsltty. My `.tmux.conf` file is: set -g default-terminal "tmux-256color" # enable 24 bit support set -g terminal-overrides ',xterm-256color:Tc' And my vimrc is [here](https://gist.github.com/persep/e66f00f84f619b8086ec60e4e878ef5a)
claunia added the Product-ConhostResolution-Fix-Available labels 2026-01-30 21:45:15 +00:00
Author
Owner

@mkarpoff commented on GitHub (Mar 15, 2018):

I've noticed this as well.

@mkarpoff commented on GitHub (Mar 15, 2018): I've noticed this as well.
Author
Owner

@zadjii-msft commented on GitHub (Mar 15, 2018):

I'll add it to my bug backlog. It might have been fixed for the upcoming release, but I doubt it. Looks like vim is doing something to change the attributes, and then tmux is emitting something like "use defaults", but we're not properly undoing whatever vim did.

@zadjii-msft commented on GitHub (Mar 15, 2018): I'll add it to my bug backlog. It *might* have been fixed for the upcoming release, but I doubt it. Looks like vim is doing something to change the attributes, and then tmux is emitting something like "use defaults", but we're not properly undoing whatever vim did.
Author
Owner

@slabua commented on GitHub (Mar 15, 2018):

I'm quite positive the issue is related to how the bold attribute is handled.
Should it be posted somewhere here too, perhaps? https://github.com/Microsoft/wsl/issues

@slabua commented on GitHub (Mar 15, 2018): I'm quite positive the issue is related to how the bold attribute is handled. Should it be posted somewhere here too, perhaps? https://github.com/Microsoft/wsl/issues
Author
Owner

@persep commented on GitHub (Mar 16, 2018):

Yes it looks like a bug with the bold rendering

In wsltty outside tmux:
img

In bash ubuntu on windows outside tmux:
img

@persep commented on GitHub (Mar 16, 2018): Yes it looks like a bug with the bold rendering In wsltty outside tmux: ![img](https://i.imgur.com/wPg6wMn.jpg) In bash ubuntu on windows outside tmux: ![img](https://i.imgur.com/1yGFfIl.jpg)
Author
Owner

@WSLUser commented on GitHub (Mar 16, 2018):

No console issues regarding WSL should be in WSL per WSL Contributing.md

@WSLUser commented on GitHub (Mar 16, 2018): No console issues regarding WSL should be in WSL per WSL [Contributing.md](https://github.com/Microsoft/WSL/blob/master/CONTRIBUTING.md)
Author
Owner

@zadjii-msft commented on GitHub (Mar 16, 2018):

@persep god bless your soul for a repro that doesn't involve invoking vim and tmux. That's a string I can write a unit test against :)

@zadjii-msft commented on GitHub (Mar 16, 2018): @persep god bless your soul for a repro that doesn't involve invoking vim and tmux. That's a string I can write a unit test against :)
Author
Owner

@persep commented on GitHub (Mar 16, 2018):

@zadjii-msft Don't tell me about it. I opened a bug report in gruvbox, vim-airline, and tmux before I got to the console :-) . It was @nicm from tmux that had the idea, credit where credit's due.

Just so you can copy the string:
printf '\033[38;2;40;40;40m\033[48;2;168;153;132m\033[1m NORMAL \033[m'

@persep commented on GitHub (Mar 16, 2018): @zadjii-msft Don't tell me about it. I opened a bug report in gruvbox, vim-airline, and tmux before I got to the console :-) . It was @nicm from tmux that had the idea, credit where credit's due. Just so you can copy the string: `printf '\033[38;2;40;40;40m\033[48;2;168;153;132m\033[1m NORMAL \033[m'`
Author
Owner

@ehuss commented on GitHub (Mar 26, 2018):

From my experiments, it appears issuing the bold sequence after any of the extended color sequences will override the foreground color.

\033[33m\033[1mBold Yellow\033[m
\033[38;2;255;0;0m\033[1mBold Red\033[m
\033[38;5;46m\033[1mBold Green\033[m

image

But if you issue the bold sequence first, then it doesn't override the foreground color.

\033[1m\033[38;2;255;0;0mBold Red\033[m
\033[1m\033[38;5;46mBold Green\033[m

image

@ehuss commented on GitHub (Mar 26, 2018): From my experiments, it appears issuing the bold sequence after any of the extended color sequences will override the foreground color. ``` \033[33m\033[1mBold Yellow\033[m \033[38;2;255;0;0m\033[1mBold Red\033[m \033[38;5;46m\033[1mBold Green\033[m ``` ![image](https://user-images.githubusercontent.com/43198/37883634-71c8506e-3060-11e8-96bd-8f4b19e0f375.png) But if you issue the bold sequence first, then it doesn't override the foreground color. ``` \033[1m\033[38;2;255;0;0mBold Red\033[m \033[1m\033[38;5;46mBold Green\033[m ``` ![image](https://user-images.githubusercontent.com/43198/37883665-9725cab2-3060-11e8-82f2-14531a448acf.png)
Author
Owner

@j4james commented on GitHub (Mar 27, 2018):

The bold/brightness attribute was designed to work with the basic color system that had a palette of only 8 colors with dim and bright counterparts. When you're dealing with the 256-color palette or 24-bit colors there obviously isn't a similar bright version of each color, so what happens is you get the bright version of the last selected color from the 8-color palette.

As an example:

printf "\033[31m Basic Red \033[38;2;0;255;0m 24-bit Green \033[1m Bright Red, Not Green \033[m"

There's never going to be a perfect solution to this problem, but what some terminal emulators do is try and find the closest match in the 8-color palette whenever you select a 24-bit color or one of the 256-color palette values. That color then becomes the base value used when the bold attribute is applied (or turned off).

@j4james commented on GitHub (Mar 27, 2018): The bold/brightness attribute was designed to work with the basic color system that had a palette of only 8 colors with dim and bright counterparts. When you're dealing with the 256-color palette or 24-bit colors there obviously isn't a similar bright version of each color, so what happens is you get the bright version of the last selected color from the 8-color palette. As an example: printf "\033[31m Basic Red \033[38;2;0;255;0m 24-bit Green \033[1m Bright Red, Not Green \033[m" There's never going to be a perfect solution to this problem, but what some terminal emulators do is try and find the closest match in the 8-color palette whenever you select a 24-bit color or one of the 256-color palette values. That color then becomes the base value used when the bold attribute is applied (or turned off).
Author
Owner

@nicm commented on GitHub (Mar 27, 2018):

I don't know what terminal you are specifically talking about but this is a not a useful way to implement attributes.

Making SGR 1 (or any other attribute) change the foreground colour as well as the attribute is a mistake and not what applications will expect. If I send your example, I expect the last text to be green, not red, whether or not the terminal supports combining bright with RGB colours.

If the terminal does not support combining bright with a colour from the 256 palette or an RGB colour, the least surprising thing to do is to render the colour without the bright attribute at all, but remember the attribute if the foreground colour is changed to a colour where it is supported.

@nicm commented on GitHub (Mar 27, 2018): I don't know what terminal you are specifically talking about but this is a not a useful way to implement attributes. Making SGR 1 (or any other attribute) change the foreground colour as well as the attribute is a mistake and not what applications will expect. If I send your example, I expect the last text to be green, not red, whether or not the terminal supports combining bright with RGB colours. If the terminal does not support combining bright with a colour from the 256 palette or an RGB colour, the least surprising thing to do is to render the colour without the bright attribute at all, but remember the attribute if the foreground colour is changed to a colour where it is supported.
Author
Owner

@RobertDurfee commented on GitHub (Apr 21, 2018):

A quick workaround is to just tell airline not to bold those elements. Just add the following to your .vimrc:

call airline#parts#define_accent('mode', 'none')
call airline#parts#define_accent('linenr', 'none')
call airline#parts#define_accent('maxlinenr', 'none')

Not a solution, but it makes airline a little more usable in tmux in wsl.

@RobertDurfee commented on GitHub (Apr 21, 2018): A quick workaround is to just tell airline not to bold those elements. Just add the following to your `.vimrc`: ``` call airline#parts#define_accent('mode', 'none') call airline#parts#define_accent('linenr', 'none') call airline#parts#define_accent('maxlinenr', 'none') ``` Not a solution, but it makes airline a little more usable in tmux in wsl.
Author
Owner

@zadjii-msft commented on GitHub (Jun 7, 2018):

Before and after:
image

Heading to code review :)

@zadjii-msft commented on GitHub (Jun 7, 2018): Before and after: ![image](https://user-images.githubusercontent.com/18356694/41072028-18cbf5a4-69b0-11e8-8696-e6c4959a292e.png) Heading to code review :)
Author
Owner

@persep commented on GitHub (Jun 7, 2018):

Looks good

@persep commented on GitHub (Jun 7, 2018): Looks good
Author
Owner

@zadjii-msft commented on GitHub (Oct 25, 2018):

Fix is in the October 2018 update.

@zadjii-msft commented on GitHub (Oct 25, 2018): Fix is in the October 2018 update.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#196