Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

24 bit/True color not working in tmux 2.3 #696

Closed
nerdpad opened this issue Dec 21, 2016 · 21 comments
Closed

24 bit/True color not working in tmux 2.3 #696

nerdpad opened this issue Dec 21, 2016 · 21 comments

Comments

@nerdpad
Copy link

nerdpad commented Dec 21, 2016

Hi,

I am on Mac OSX Sierra, and I am struggling to get 24bit color support inside tmux.

Issue

Colors don't look the same inside tmux. Possibly because I am unable to get 256 colors within tmux.

When I run the following script in terminal and inside tmux I see different results. The gradient isn't smooth inside tmux.

awk 'BEGIN{
    s="/\\/\\/\\/\\/\\"; s=s s s s s s s s s s s s s s s s s s s s s s s;
    for (colnum = 0; colnum<256; colnum++) {
        r = 255-(colnum*255/255);
        g = (colnum*510/255);
        b = (colnum*255/255);
        if (g>255) g = 510-g;
        printf "\033[48;2;%d;%d;%dm", r,g,b;
        printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
        printf "%s\033[0m", substr(s,colnum+1,1);
    }
    printf "\n";
}'

Inside iterm
screen shot 2016-12-21 at 5 08 36 pm

inside tmux (iterm > tmux)
screen shot 2016-12-21 at 5 08 17 pm

Note: The gradient isn't smooth.

Environment:

OS: OSX Sierra
Terminal: iTerm2 build 3.0.*
Tmux: Tmux version 2.3

Terminfo

outside tmux

echo $TERM
xterm-256color-italic

Terminfo File: xterm-256color-italic

inside tmux

echo $TERM
tmux-256color-italic

Terminfo File: tmux-256color-italic

Tmux.conf

# tmux display things in 256 colors
set -g default-terminal "tmux-256color-italic"
#  enable terminal compability
set-option -ga terminal-overrides ",tmux-256color-italic:Tc"

Tc Missing?

When I run tmux info I see that the Tc flag is [missing].

⇨ tmux info | grep Tc
 197: Tc: [missing]
Full tmux info
⇨ tmux info
Terminal 0: xterm-256color-italic [references=1, flags=0x1]:
   0: AX: [missing]
   1: acsc: (string) ``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~
   2: bce: (flag) true
   3: bel: (string) \007
   4: blink: (string) \033[5m
   5: bold: (string) \033[1m
   6: civis: (string) \033[?25l
   7: clear: (string) \033[H\033[2J
   8: cnorm: (string) \033[?12l\033[?25h
   9: colors: (number) 256
  10: Cr: (string) \033]112\007
  11: Cs: (string) \033]12;%p1%s\007
  12: csr: (string) \033[%i%p1%d;%p2%dr
  13: cub: (string) \033[%p1%dD
  14: cub1: (string) \010
  15: cud: (string) \033[%p1%dB
  16: cud1: (string) \012
  17: cuf: (string) \033[%p1%dC
  18: cuf1: (string) \033[C
  19: cup: (string) \033[%i%p1%d;%p2%dH
  20: cuu: (string) \033[%p1%dA
  21: cuu1: (string) \033[A
  22: cvvis: (string) \033[?12;25h
  23: dch: (string) \033[%p1%dP
  24: dch1: (string) \033[P
  25: dim: [missing]
  26: dl: (string) \033[%p1%dM
  27: dl1: (string) \033[M
  28: E3: [missing]
  29: ech: (string) \033[%p1%dX
  30: el: (string) \033[K
  31: el1: (string) \033[1K
  32: enacs: [missing]
  33: fsl: (string) \007
  34: home: (string) \033[H
  35: hpa: (string) \033[%i%p1%dG
  36: ich: (string) \033[%p1%d@
  37: ich1: [missing]
  38: il: (string) \033[%p1%dL
  39: il1: (string) \033[L
  40: invis: (string) \033[8m
  41: is1: [missing]
  42: is2: (string) \033[!p\033[?3;4l\033[4l\033>
  43: is3: [missing]
  44: kcbt: (string) \033[Z
  45: kcub1: (string) \033OD
  46: kcud1: (string) \033OB
  47: kcuf1: (string) \033OC
  48: kcuu1: (string) \033OA
  49: kDC: (string) \033[3;2~
  50: kDC3: [missing]
  51: kDC4: [missing]
  52: kDC5: [missing]
  53: kDC6: [missing]
  54: kDC7: [missing]
  55: kdch1: (string) \033[3~
  56: kDN: [missing]
  57: kDN3: [missing]
  58: kDN4: [missing]
  59: kDN5: [missing]
  60: kDN6: [missing]
  61: kDN7: [missing]
  62: kend: (string) \033OF
  63: kEND: (string) \033[1;2F
  64: kEND3: [missing]
  65: kEND4: [missing]
  66: kEND5: [missing]
  67: kEND6: [missing]
  68: kEND7: [missing]
  69: kf1: (string) \033OP
  70: kf10: (string) \033[21~
  71: kf11: (string) \033[23~
  72: kf12: (string) \033[24~
  73: kf13: (string) \033[1;2P
  74: kf14: (string) \033[1;2Q
  75: kf15: (string) \033[1;2R
  76: kf16: (string) \033[1;2S
  77: kf17: (string) \033[15;2~
  78: kf18: (string) \033[17;2~
  79: kf19: (string) \033[18;2~
  80: kf2: (string) \033OQ
  81: kf20: (string) \033[19;2~
  82: kf21: (string) \033[20;2~
  83: kf22: (string) \033[21;2~
  84: kf23: (string) \033[23;2~
  85: kf24: (string) \033[24;2~
  86: kf25: (string) \033[1;5P
  87: kf26: (string) \033[1;5Q
  88: kf27: (string) \033[1;5R
  89: kf28: (string) \033[1;5S
  90: kf29: (string) \033[15;5~
  91: kf3: (string) \033OR
  92: kf30: (string) \033[17;5~
  93: kf31: (string) \033[18;5~
  94: kf32: (string) \033[19;5~
  95: kf33: (string) \033[20;5~
  96: kf34: (string) \033[21;5~
  97: kf35: (string) \033[23;5~
  98: kf36: (string) \033[24;5~
  99: kf37: (string) \033[1;6P
 100: kf38: (string) \033[1;6Q
 101: kf39: (string) \033[1;6R
 102: kf4: (string) \033OS
 103: kf40: (string) \033[1;6S
 104: kf41: (string) \033[15;6~
 105: kf42: (string) \033[17;6~
 106: kf43: (string) \033[18;6~
 107: kf44: (string) \033[19;6~
 108: kf45: (string) \033[20;6~
 109: kf46: (string) \033[21;6~
 110: kf47: (string) \033[23;6~
 111: kf48: (string) \033[24;6~
 112: kf49: (string) \033[1;3P
 113: kf5: (string) \033[15~
 114: kf50: (string) \033[1;3Q
 115: kf51: (string) \033[1;3R
 116: kf52: (string) \033[1;3S
 117: kf53: (string) \033[15;3~
 118: kf54: (string) \033[17;3~
 119: kf55: (string) \033[18;3~
 120: kf56: (string) \033[19;3~
 121: kf57: (string) \033[20;3~
 122: kf58: (string) \033[21;3~
 123: kf59: (string) \033[23;3~
 124: kf6: (string) \033[17~
 125: kf60: (string) \033[24;3~
 126: kf61: (string) \033[1;4P
 127: kf62: (string) \033[1;4Q
 128: kf63: (string) \033[1;4R
 129: kf7: (string) \033[18~
 130: kf8: (string) \033[19~
 131: kf9: (string) \033[20~
 132: kHOM: (string) \033[1;2H
 133: kHOM3: [missing]
 134: kHOM4: [missing]
 135: kHOM5: [missing]
 136: kHOM6: [missing]
 137: kHOM7: [missing]
 138: khome: (string) \033OH
 139: kIC: (string) \033[2;2~
 140: kIC3: [missing]
 141: kIC4: [missing]
 142: kIC5: [missing]
 143: kIC6: [missing]
 144: kIC7: [missing]
 145: kich1: (string) \033[2~
 146: kLFT: (string) \033[1;2D
 147: kLFT3: [missing]
 148: kLFT4: [missing]
 149: kLFT5: [missing]
 150: kLFT6: [missing]
 151: kLFT7: [missing]
 152: kmous: (string) \033[M
 153: knp: (string) \033[6~
 154: kNXT: (string) \033[6;2~
 155: kNXT3: [missing]
 156: kNXT4: [missing]
 157: kNXT5: [missing]
 158: kNXT6: [missing]
 159: kNXT7: [missing]
 160: kpp: (string) \033[5~
 161: kPRV: (string) \033[5;2~
 162: kPRV3: [missing]
 163: kPRV4: [missing]
 164: kPRV5: [missing]
 165: kPRV6: [missing]
 166: kPRV7: [missing]
 167: kRIT: (string) \033[1;2C
 168: kRIT3: [missing]
 169: kRIT4: [missing]
 170: kRIT5: [missing]
 171: kRIT6: [missing]
 172: kRIT7: [missing]
 173: kUP: [missing]
 174: kUP3: [missing]
 175: kUP4: [missing]
 176: kUP5: [missing]
 177: kUP6: [missing]
 178: kUP7: [missing]
 179: Ms: (string) \033]52;%p1%s;%p2%s\007
 180: op: (string) \033[39;49m
 181: rev: (string) \033[7m
 182: ri: (string) \033M
 183: rmacs: (string) \033(B
 184: rmcup: (string) \033[?1049l
 185: rmkx: (string) \033[?1l\033>
 186: Se: (string) \033[2 q
 187: setab: (string) \033[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m
 188: setaf: (string) \033[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m
 189: sgr0: (string) \033(B\033[m
 190: sitm: (string) \033[3m
 191: smacs: (string) \033(0
 192: smcup: (string) \033[?1049h
 193: smkx: (string) \033[?1h\033=
 194: smso: (string) \033[7m
 195: smul: (string) \033[4m
 196: Ss: (string) \033[%p1%d q
 197: Tc: [missing]
 198: tsl: (string) \033]0;
 199: vpa: (string) \033[%i%p1%dd
 200: xenl: (flag) true
 201: XT: (flag) true
@nicm
Copy link
Member

nicm commented Dec 21, 2016 via email

@nerdpad
Copy link
Author

nerdpad commented Dec 21, 2016

@nicm I have added Tc in the terminal-overrides

Isn't this how Tc is supposed to be enabled?

set-option -ga terminal-overrides ",tmux-256color-italic:Tc"

@nicm
Copy link
Member

nicm commented Dec 21, 2016 via email

@nerdpad
Copy link
Author

nerdpad commented Dec 21, 2016

@nicm Pardon me if I am being naive, but I have added the TC override in my ~/.tmux.conf

It's in my tmux.conf

set-option -ga terminal-overrides ",tmux-256color-italic:Tc"

Am I missing some step?

@nicm
Copy link
Member

nicm commented Dec 21, 2016 via email

@nerdpad
Copy link
Author

nerdpad commented Dec 21, 2016

@nicm Oh. Thanks that worked. The gradient is now smooth.

Thank you for your patience.

@unphased
Copy link

unphased commented Jan 9, 2017

@this worked for me too.

Curious: Why does adding ",*:Tc" not work?

@yosiat
Copy link

yosiat commented Jan 17, 2017

Hi,

This doesn't work for me.

My environment:

  • macOS sierra 10.12.1
  • iterm2 3.0.13
  • tmux 2.3
> tmux info | grep Tc
197: Tc: [missing]

> echo $TERM
xterm-256color

I have those lines in tmux.conf:

set-option -ga terminal-overrides ",xterm-256color:Tc"

And this the output for the awk in original issue:
Inside tmux:
screen shot 2017-01-18 at 12 42 54 am

Outside tmux:
screen shot 2017-01-18 at 12 43 22 am

And I ran 24-bit-color.sh script from iterm text, and iterm I get colors printed while in tmux I don't get any colors.

What I am doing wrong?

@unphased
Copy link

Did you try removing the comma since you only have one entry?

@yosiat
Copy link

yosiat commented Jan 18, 2017

@unphased I removed the comma and the "24-bit-color" is still not working in tmux and I still get missing for "Tc"

@nicm
Copy link
Member

nicm commented Jan 18, 2017

You need the comma. Make sure you are restarted tmux entirely after changing .tmux.conf.

@yosiat
Copy link

yosiat commented Jan 18, 2017

@nicm now the Tc flag is true.
but the 24-bit-color is still not working.

@nicm
Copy link
Member

nicm commented Jan 18, 2017

You are probably using a script that uses :s for separators in the escape sequence, this is not supported.

LandonSchropp added a commit to LandonSchropp/dotfiles that referenced this issue May 27, 2017
I followed the instructions in this GitHub issue to get this working
with tmux: tmux/tmux#696.
LandonSchropp added a commit to LandonSchropp/dotfiles that referenced this issue Dec 12, 2017
I followed the instructions in this GitHub issue to get this working
with tmux: tmux/tmux#696.
@ivanslo
Copy link

ivanslo commented Jan 11, 2018

This is EXACTLY what I was looking for. Thanks everyone

@b-gran
Copy link

b-gran commented Jan 25, 2018

For anyone having trouble with this, you need to ensure that the terminal name in the terminal overrides matches the terminal tmux is actually using.

When you add this override

set-option -ga terminal-overrides ",tmux-256color-italic:Tc"

to your .tmux.conf, the terminal in the override (in this case tmux-256color-italic) must match the terminal tmux is actually using or else the override won't be applied.
If your tmux term is screen or xterm-256color, the override above will not work.

Run echo $TERM in tmux to determine which terminal tmux is currently using.
You can change the terminal by adding a set -g default-terminal line to your .tmux.conf.

This complete .tmux.conf tells tmux to use xterm-256color as the terminal and then enables Tc

# Use the xterm-256color terminal
set -g default-terminal "xterm-256color"

# Apply Tc
set-option -ga terminal-overrides ",xterm-256color:Tc"

@nicm
Copy link
Member

nicm commented Jan 26, 2018 via email

@Mr-Tao
Copy link

Mr-Tao commented May 5, 2018

For anyone struggling with tmux + true color + italic
My TERM outside tmux is xterm-256color-italic

set -g default-terminal "screen-256color-italic"
set-option -ga terminal-overrides ",xterm-256color*:Tc:smso=^[[3m"

Nb. ^[ in .tmux.conf above is actual escape character (not caret + square bracket). tmux info|grep smso should return smso: (string) \033[3m

@masaeedu
Copy link

masaeedu commented Dec 14, 2018

Another really stupid thing I was doing was having a tmux session hanging around detached from everything else. I kept tweaking my config and restarting my terminal emulator, but I kept getting reattached to the same tmux server/daemon/whatever and couldn't work out why nothing was changing. Make sure there's no tmux processes running.

@tuannvm
Copy link

tuannvm commented Jun 16, 2019

set -g default-terminal "screen-256color-italic"
set-option -ga terminal-overrides ",xterm-256color*:Tc:smso"

Works for me

@trentrand
Copy link

trentrand commented Nov 20, 2019

The active tmux server must be stopped and restarted after changing these settings.

This can be accomplished with the following commands:

$ tmux kill-server
$ tmux

Note, this is different than simply quitting and reopening your terminal emulator (i.e. iTerm2, Alacritty).

vlasakm added a commit to vlasakm/dotfiles that referenced this issue Feb 18, 2020
alacritty sets $TERM to "alacritty", so no longer matches the wildcard.
tmux/tmux#696 (comment)
@lock
Copy link

lock bot commented Mar 11, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

10 participants