Hut8
Hut8

Reputation: 6342

gnome-terminal (or VTE) sets $TERM to xterm rather than xterm-256color

Is there a compelling reason why gnome-terminal (and, under the hood, maybe the VTE widget) sets $TERM to xterm rather than xterm-256color? Clearly it supports 256 colors.

For a while, I had a line in my .bashrc/.zshrc to simply export TERM=xterm-256color, because that's usually the terminal emulator that I'm using. But then I open up tmux, and the behavior / colors are wrong in many CLI applications, such as emacs and htop, because tmux will set the TERM variable to screen-256color, then the shell loads and executes my .*rc file, which then sets the TERM incorrectly.

For now, I have:

if [ "$TERM" != "screen-256color" ]; then
    export TERM="xterm-256color"
fi

I don't like this, because what if one day I break out my actual VT-220 or use a different terminal emulator?

Upvotes: 0

Views: 1259

Answers (1)

egmont
egmont

Reputation: 683

For a long time, people used to look at $COLORTERM, and if that was set (along with TERM=xterm) they switched it to TERM=xterm-256colors instead.

Later, gnome-terminal (actually vte) removed setting $COLORTERM, but introduced $VTE_VERSION.

The newest version (gnome-terminal 3.16, vte 0.40) sets TERM=xterm-256color right away (which is again not quite correct, because it supports 16M colors, but there's no way to denote it in terminfo.)

Upvotes: 1

Related Questions