0

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?

Hut8
  • 6,080
  • 4
  • 42
  • 59
  • I don't understand: you say "..my .*rc file, which then sets the TERM..", but that sounds like an error: the .rc file shouldn't set $TERM, in general. – Stefan Nov 14 '13 at 00:31
  • 1
    I know that it shouldn't need to, but doesn't gnome-terminal set it incorrectly? So where else am I supposed to put it? – Hut8 Nov 24 '13 at 22:48

1 Answers1

1

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.)

egmont
  • 581
  • 3
  • 11