gnome-terminal(或VTE)将$ TERM设置为xterm而不是xterm-256color [英] gnome-terminal (or VTE) sets $TERM to xterm rather than xterm-256color

查看:2218
本文介绍了gnome-terminal(或VTE)将$ TERM设置为xterm而不是xterm-256color的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有令人信服的理由为什么 gnome-terminal (并且在引擎盖下,也许 VTE 小部件)将 $ TERM 设置为 xterm 而不是 xterm-256color ?显然它支持256种颜色。

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.

有一段时间,我在我的 .bashrc / .zshrc 简单地 export TERM = xterm-256color ,因为这通常是我正在使用的终端模拟器。但是,然后我打开 tmux ,并且许多CLI应用程序中的行为/颜色错误,例如 emacs htop ,因为 tmux 会将 TERM 变量设置为screen- 256color,然后,shell加载并执行我的。* rc 文件,然后设置 TERM 不正确。

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.

现在,我有:

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

这样,因为如果有一天我打破了我实际的VT-220或使用不同的终端模拟器?

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

推荐答案

很久以前,人们曾经看过 $ COLORTERM ,如果这样设置(连同 TERM = xterm )他们将它切换到 TERM = xterm-256colors

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.

之后,gnome-terminal(实际上是vte) $ COLORTERM ,但是引入了 $ VTE_VERSION

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

最新版本(gnome-terminal 3.16,vte 0.40)立即设置 TERM = xterm-256color (再次不太正确,因为它支持16M颜色,但没有办法在terminfo中表示它。)

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(或VTE)将$ TERM设置为xterm而不是xterm-256color的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆