如何为linux shell设置TERM环境变量

时间:2014-11-28 12:35:36

标签: linux bash xterm

当我在〜/ .bash_profile中设置导出TERM = xterm-256color时,我有一个非常奇怪的问题。当我尝试运行nano或emacs时,我收到以下错误。

纳米:

.rror opening terminal: xterm-256color

emacs的:

 is not defined.type xterm-256color
If that is not the actual type of terminal you have,
use the Bourne shell command `TERM=... export TERM' (C-shell:
`setenv TERM ...') to specify the correct type.  It may be necessary
to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.

如果我在shell中手动输入以下内容

export TERM=xterm-256color

我很难过。

1 个答案:

答案 0 :(得分:5)

您的.bash_profile看起来有DOS换行符。不要在Windows上编辑文件,和/或使用适当的工具将它们复制到Linux系统。

  

更好的是,摆脱Windows。

更详细地说,你可能看不到它,但错误的行实际上是

export TERM=xterm-256color^M

其中^M是文字DOS回车。

就像@EtanReisner在评论中提到的那样,你不应该在你的登录文件中对这个值进行硬编码。 Linux非常努力地将其设置为理智值,具体取决于诸如您实际使用的终端以及您的连接方式之类的内容。最多,您可能希望覆盖登录过程经常选择但不符合您喜欢的特定值。假设您想要更改为xterm-256color,如果值为xterm

case $TERM in xterm) TERM=xterm-256color;; esac

这不是一个编程问题,而是StackOverflow上一个非常常见的问题。请先询问谷歌。

相关问题