The most surprising thing about tmux’s color support is that it’s not a simple on/off switch, but a layered negotiation between your terminal, tmux itself, and the applications running inside tmux.
Let’s see it in action. First, ensure your terminal emulator is set to support true color (often called 24-bit color or 16 million colors). In Alacritty, this is usually the default. In iTerm2, it’s under Preferences -> Profiles -> Text -> "Report iTerm2’s OpenGL engine to applications," which should be unchecked. In GNOME Terminal, it’s usually on by default.
Next, configure tmux. Add these lines to your ~/.tmux.conf:
set -g default-terminal "xterm-256color"
set-ga terminal-overrides ",xterm-256color:Tc"
The first line, set -g default-terminal "xterm-256color", tells tmux to advertise itself to applications running inside it as supporting 256 colors. This is a common baseline that most modern applications understand.
The second line, set-ga terminal-overrides ",xterm-256color:Tc", is the crucial part for true color. It appends a terminal capability flag (Tc) specifically for the xterm-256color terminal type. The Tc flag signals to applications that the terminal actually supports true color (24-bit RGB). Tmux uses this to override its own default-terminal setting when necessary, allowing applications to query for and use true color if they detect the Tc flag.
Now, let’s test it. Open a new tmux session (tmux) and run nvim (if you have it installed) with a plugin that highlights syntax. You should see rich, accurate colors. Alternatively, run ls --color=auto in a directory with diverse file types, or use a tool like colortest (you might need to brew install colortest or apt install colortest). Run colortest -c in your terminal outside of tmux, then tmux and run colortest -c again. The output should look identical and display a full gradient of colors. If you only see 16 distinct colors or a faded gradient, something’s not quite right.
The magic happens because many applications, like Vim/Neovim, ls, and git, probe the TERM environment variable and check terminal capabilities. When TERM is xterm-256color and the Tc flag is present, they know they can emit 24-bit RGB escape sequences. Tmux, by setting default-terminal to xterm-256color and then overriding with Tc, effectively bridges your terminal’s true color capability to the applications running within its panes. Without the Tc flag, applications might default to 256-color or even 16-color palettes, leading to washed-out or incorrect hues.
A common misconception is that set -g default-terminal "xterm-truecolor" is sufficient. While this variable name sounds more direct, xterm-256color is the widely recognized terminal type that applications expect to see, and the Tc flag is the standardized way to signal true color support for that type. Using xterm-truecolor might work with some very modern applications but breaks compatibility with many others that only look for xterm-256color and then check capabilities.
The terminal-overrides option is powerful because it allows you to fine-tune how tmux presents itself to different applications or situations. The syntax ",xterm-256color:Tc" specifically targets the xterm-256color terminal type and adds the Tc capability. If you were using a different default-terminal value, you’d adjust this override accordingly.
If you find that some colors are still off, double-check that your terminal emulator itself is configured for true color. This is often a setting within the emulator’s preferences, sometimes labeled "24-bit color" or "16 million colors." If your terminal emulator doesn’t support true color, no amount of tmux configuration will enable it.
The next step in color mastery involves understanding how specific applications might still misinterpret or override these settings, often requiring application-level configuration or further tmux overrides for those particular programs.