I would like for tmux
to automatically pick up 256-color mode, i.e. have an environment variable
TERM=tmux-256color
inside tmux
when the environment variable
TERM=xterm-256color
was set outside.
Default behaviour
256-color terminal emulator
The current behaviour is for tmux
to pick 8 color mode in any case: use a terminal emulator that supports 256 colors, i.e. Gnome Terminal or xterm, and make sure it supports 256 colors
echo $TERM; tput colors
# xterm-256colors
# 256
then start tmux
. By default tmux
will switch to 8 colors:
echo $TERM; tput colors
# screen
# 8
8-color terminal emulator
If instead you switch to a 8 color terminal, i.e. by switching to /dev/tty2
by pressing Ctrl+Alt+F2, you get
echo $TERM; tput colors
# linux
# 8
and inside tmux
the same old
echo $TERM; tput colors
# screen
# 8
Forced 256-color mode
I can force tmux
to pick up 256-color mode by adding the following to ~/.tmux.conf
set -s default-terminal "tmux-256color"
However this also applies if the outer terminal emulator did not support 256 colors to begin with. This is not what I want.
Adaptive 256-color mode
There is an issue and a FAQ on GitHub that state setting one of (people are reporting contradicting parameters)
set -ga terminal-overrides ",xterm-256color*:Tc"
set -sa terminal-overrides ",xterm-256color*:Tc"
set -ga terminal-overrides ",*256col*:Tc"
set -sa terminal-overrides ",*256col*:Tc"
should make tmux
pick up the terminal's color mode, but none of them work on my installation (tmux 3.0 on Arch).
Is there a definitive way of letting tmux
pick up either 8 or 256 colors, depending on what the current terminal emulator supports?