1

I have an issue that the colors and font don't get produced correctly in tmux. The same output looks different when the command is run outside vs inside tmux.

Outside tmux:

enter image description here

Inside tmux:

enter image description here

As suggested here, I have set -g default-terminal "screen-256color" in my .tmux.conf. The output of tput and $TERM are correct as well.

$ tput colors
256

$ echo $TERM
screen-256color

What am I missing here?

muru
  • 69,900
  • 13
  • 192
  • 292
Abhilash
  • 179
  • 1
  • 10

1 Answers1

5

Inside tmux, the program that produced the output on your screenshots "thinks" the terminal does not support italic mode. The program does not try to use italics, it chooses to manipulate background color instead.

This is because screen-256color you specified apparently does not support italic mode. There's a way to confirm this. In my Kubuntu the following command

TERM=screen-256color infocmp -1 | grep -E 'ritm|sitm'

produces empty output (no support), while

TERM=tmux-256color infocmp -1 | grep -E 'ritm|sitm'

gives us escape sequences to enter (sitm) or exit (ritm) italic mode (see man 5 terminfo).

Any program that queries the terminfo database will see that screen-256color does not support italic mode. To convince programs that your terminal does support it, you need to choose something with the support.

Hopefully your terminfo database contains tmux-256color. This is the right value of $TERM for you. Solution: use tmux-256color instead of screen-256color.

Kamil Maciorowski
  • 19,242
  • 1
  • 50
  • 94
  • Appreciate the clear explanation, I recognize the strange edge case here and everything makes sense :) – Abhilash May 15 '23 at 12:47
  • `TERM=screen-256color` is for the `screen` command. `TERM=tmux=256color` is for the `tmux` command – roaima May 19 '23 at 16:16