It can be difficult to get your terminal colors working correctly between your terminal emulator, tmux and your shell.

st, tmux and fish shell sometimes don’t play nice together when it comes to setting a 256 color scheme.

First, check the TERM variable in the fish shell:

$ echo $TERM

Ideally, it should be either screen-256color, st-256color, xterm-256color or something like that.

You shouldn’t set the TERM variable with fish.

The Arch Wiki for st explains that you can set the terminal type with st.

static char *termname = "st-256color";

I start my terminal session with the i3 window manager, so I have the following binding in my i3 config file:

 bindsym $mod+Return exec sterminal -n "st-256color"

Now, when I run this in fish:

$ echo $TERM
> st-256color

Now, add the following to your ~/.tmux.conf:

set -ga terminal-overrides ",st-256color"
set -g default-terminal "tmux-256color"

This sets the TERM variable for tmux to tmux-256color and leaves everything outside of tmux on st-256color.

Problems with NeoVim #checkhealth

Even with the above solution, I got tons of errors with NeoVim.

The easiest solution is to fall back to the bash shell as your default shell and to set fish as interactive shell only.

Add this to your .bashrc:

## Terminal to sterminal
export TERMINAL="sterminal"

## Fish Shell
exec fish

Make sure that the Linux user uses bash as default shell.

Further Reading