Reputation: 329
I am trying to get tmux to use screen-256color instead of xterm-256color, as it is not recommended. But when I am not using tmux, I would like to keep it as xterm-256color
A little bit of my setup, I am currently using iTerm2 and ssh to my development linux box, which is using zsh.
In my ~/.zshrc, I have:
export TERM="xterm-256color"
In my ~/.tmux.conf, I have:
set -g default-terminal "screen-256color"
With this configuraiton, without tmux, echo $TERM returns xterm-256color (which is right) and with tmux, echo $TERM is still returning xterm-256color instead of screen-256color.
Is there anything else I need to set in order for this to work?
Thanks!
Upvotes: 5
Views: 5918
Reputation: 18409
The reason this does not work as expected is, that the zsh
session that is started inside tmux
overwrites TERM
.
You should not set TERM
from within in your shell. TERM
is the way the terminal informs the shell and other applications about its capabilities (number of colors, key sequences for special keys, etc.). If you change TERM
inside the shell, you change the what features the shell and applications expect from the terminal without the terminal itself knowing about it. Oftentimes this may not be an actual issue, but it is better to change the terminal configuration and set the desired value there.
You already did so when setting screen-256color
in the configuration of tmux
, which is essentially a terminal emulator, too. To do it for iTerm2
(tested with version 3.0.10):
TERM
under Report Terminal Type.Upvotes: 3
Reputation: 54583
You could modify your .zshrc
file to check if you are running in tmux:
[ -z "$TMUX" ] && export TERM=xterm-256color
Upvotes: 0