简体   繁体   English

gnome-terminal(或VTE)将$ TERM设置为xterm而不是xterm-256color

[英]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 ? 为什么有一个令人信服的理由说明为什么gnome-terminal (并且可能是VTE小部件)将$TERM设置$TERM xterm而不是xterm-256color Clearly it supports 256 colors. 显然,它支持256色。

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. 有一阵子,我在.bashrc / .zshrc有一行可以简单地export TERM=xterm-256color ,因为这通常是我正在使用的终端模拟器。 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. 但是随后我打开tmux ,在许多CLI应用程序中,例如emacshtop ,行为/颜色是错误的,因为tmux会将TERM变量设置为screen-256color, 然后外壳程序加载并执行了我的.*rc文件,该文件然后错误地设置了TERM

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? 我不喜欢这样,因为如果有一天我突破实际的VT-220或使用其他终端模拟器怎么办?

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. 长期以来,人们一直在看$COLORTERM ,如果设置了它(以及TERM=xterm ),他们会改为使用TERM=xterm-256colors

Later, gnome-terminal (actually vte) removed setting $COLORTERM , but introduced $VTE_VERSION . 后来,gnome-terminal(实际上是vte)删除了设置$COLORTERM ,但引入了$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.) 最新版本(gnome-terminal 3.16,vte 0.40)立即设置TERM=xterm-256color (这也不是很正确,因为它支持16M颜色,但是无法在terminfo中表示出来。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM