wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
17.71k stars 793 forks source link

The colors are different inside and outside the tmux session #1148

Closed exdis closed 3 years ago

exdis commented 3 years ago

What Operating System(s) are you seeing this problem on?

macOS

WezTerm version

20210917-081523-9f5d0df1

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

Colors inside tmux session are quite different from the ones I specified in the settings. Outside of tmux session everything is ok. Outside:

Screenshot 2021-09-18 at 13 21 50

Inside tmux:

Screenshot 2021-09-18 at 13 21 52

To Reproduce

I just start a new tmux session

Configuration

local wezterm = require 'wezterm';

return {
    term = "screen-256color",
    enable_tab_bar = false,
    font = wezterm.font("FiraCode Nerd Font", {italic = false}),
    color_scheme = "Gruvbox",
    color_schemes = {
        ["Gruvbox"] = {
            foreground = "#ebdbb2",
            background = "#282828",
            cursor_bg = "#ebdbb2",
            cursor_border = "#ebdbb2",
            cursor_fg = "#282828",
            selection_bg = "#655b53",
            selection_fg = "#ebdbb2",

            ansi = {"#282828", "#cc231c", "#989719", "#d79920", "#448488", "#b16185", "#689d69", "#a89983"},
            brights = {"#928373", "#fb4833", "#b8ba25", "#fabc2e", "#83a597", "#d3859a", "#8ec07b", "#ebdbb2"},
        }
    }
}

Expected Behavior

Colors should be the same

Logs

13:09:07.534 INFO wezterm_mux_server_impl::local > setting up /Users/exdis/.local/share/wezterm/gui-sock-3268
13:09:07.682 INFO wezterm_gui::termwindow > OpenGL initialized! Intel(R) UHD Graphics 630 4.1 INTEL-16.4.5 is_context_loss_possible=false wezterm version: 20210917-081523-9f5d0df1
13:09:16.361 INFO wezterm_gui::termwindow > OpenGL initialized! Intel(R) UHD Graphics 630 4.1 INTEL-16.4.5 is_context_loss_possible=false wezterm version: 20210917-081523-9f5d0df1
13:12:17.766 INFO wezterm_gui::frontend > Ding! (this is the bell)
13:13:15.683 INFO wezterm_gui::frontend > Ding! (this is the bell)
13:26:08.372 WARNING wezterm_term::terminalstate > unhandled SetMode(Unspecified(34))
13:26:08.372 WARNING wezterm_term::terminalstate > unhandled SetMode(Unspecified(34))
13:27:08.377 WARNING wezterm_term::terminalstate > unhandled SetMode(Unspecified(34))
13:27:08.377 WARNING wezterm_term::terminalstate > unhandled SetMode(Unspecified(34))
13:28:08.379 WARNING wezterm_term::terminalstate > unhandled SetMode(Unspecified(34))
13:28:08.379 WARNING wezterm_term::terminalstate > unhandled SetMode(Unspecified(34))

Anything else?

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

You're setting term to screen-256color which is the wrong TERM configuration for wezterm; screen-256color is appropriate for applications talking directly to certain versions of GNU screen and older versions of tmux.

Leave it out of your wezterm configuration to use the default of xterm-256color!

I'd recommend that you also use the following in your tmux config so that clients inside tmux use the modern tmux terminfo, and so that tmux knows that it can use true color:

set -g default-terminal "tmux-256color"
set-option -ga terminal-overrides ',xterm-256color:Tc'
exdis commented 3 years ago

Thank you very much for the explanation! Now it's all displayed correctly.

idr4n commented 2 years ago

I'd recommend that you also use the following in your tmux config so that clients inside tmux use the modern tmux terminfo, and so that tmux knows that it can use true color:

set -g default-terminal "tmux-256color"
set-option -ga terminal-overrides ',xterm-256color:Tc'

Thanks a lot for this @wez. I had been banging my head on this issue which is also present in Alacritty and I couldn't find the answer anywhere. Your tmux config works like a charm (second line) and now colors in Tmux are displaying properly finally!

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.