如何配置 gnome-terminal 默认使用 xterm-256color?

Rob*_*ier 11 linux debian terminal gnome

当我启动 gnome-terminal 并执行时echo $TERM,我得到了xterm输出。

我希望它是 xterm-256color

我已经考虑过将解决方案添加'export TERM=xterm256color'到我的.bashrc. 但是我不喜欢这个解决方案,如果我决定切换shell怎么办?我必须在我的新 shell 启动脚本中添加其他导出吗?

那么在启动 gnome-terminal 时有没有更好的方法来自动拥有 256 色终端?

Mes*_*ion 13

@javabrett 指出的同一个问题中复制我的答案

建议您不要更改启动脚本,特别是~/.bashrc. 任何使用 current$TERM$COLORTERMin 的“终端检测”~/.profile都只是一种猜测,正如您所说,在使用其他终端(例如,Putty 或 xterm)时可能会导致麻烦。终端仿真器应该集$TERM,这应该 被从外壳内改变。

Gnome 终端 AFAIK 不提供更改其 的配置TERM,但它允许您更改启动命令,这就是您所需要的。这是诀窍:

Profile Preferences => Title and Command => Run a custom command instead of my shell
Run Code Online (Sandbox Code Playgroud)

然后使用以下命令:

env TERM=xterm-256color /bin/bash
Run Code Online (Sandbox Code Playgroud)

/bin/bash如果不同,只需更换您喜欢的外壳。不,您不能"$SHELL"在该行中使用 shell 自动检测;) 您必须对其进行硬编码


egm*_*ont 5

gnome-terminal3.16 版开始,它默认为TERM=xterm-256color.