[英]How to set TERM environment variable for linux shell
當我在〜/ .bash_profile中設置export 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.
如果我在外殼中手動輸入以下內容,則可以正常工作
export TERM=xterm-256color
我很沮喪
看起來您的.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上的一個極為常見的問題。 請先用Google詢問。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.