How to set $TERM permanently in fish shell

dotfilesenvironment-variablesfishshell

I use the fish shell. I'm trying to run vim inside tmux with the solarized theme, but the colors are broken unless I run:

set -lx TERM screen-256color-bce;

before running tmux attach.

It's annoying having to run this every day, so I want to set the TERM variable permanently. However, fish seems to ignore when I set this particular variable with set -U:

$ set -U foo bar; echo $foo
foo bar
$ set -U TERM screen-256color-bce; echo $TERM
TERM xterm
$ set -lx TERM screen-256color-bce; echo $TERM
TERM screen-256color-bce

I even tried putting set -lx TERM screen-256color-bce in ~/.config/fish/config.fish, but a new fish (initiated outside tmux) always has TERM set to xterm.

Best Answer

set -gx TERM screen-256color-bce;

I had the exact same problem as you. replace the "l" with "g" as g means global.