当我在X终端窗口中运行emacs -nw
,并请求M-x list-colors-display
时,我只得到了一个简陋的调色板:
black
red
green
yellow
blue
magenta
cyan
white
我被告知可以获取265种颜色。将TERM
环境变量设置为xterm-256color
无法完成任务。应该怎么做?
TERM
设置为xterm-256color
之外,还需要安装ncurses-term
库。The xterm in Ubuntu Edgy does not advertise 256 color support by
default. To fix this you need to install a 256 color terminfo entry,
and tell xterm to use it:
apt-get install ncurses-term
echo XTerm.termName: xterm-256color \
>>~/.Xdefaults
xrdb -merge ~/.Xdefaults
So you need a file term/screen-256color.el in your load-path. Emacs
22 expects it to contain a terminal-init-screen defun. Emacs 21
expects it to contain a bunch of top-level forms. Here's what I use:
;;; This is for GNU Emacs 22
(defun terminal-init-screen ()
"Terminal initialization function for screen."
;; Use the xterm color initialization code.
(load "term/xterm")
(xterm-register-default-colors)
(tty-set-up-initial-frame-faces))
;;; This is for GNU Emacs 21
(if (= 21 emacs-major-version)
(load "term/xterm-256color"))
For Emacs 21, you also need to install the xterm-256color.el file from
http://www.splode.com/~friedman/software/emacs-lisp/src/term/xterm-256color.el
将TERM
设置为xterm-256color
是你想要做的。此外,Emacs 22(至少)不需要我进行任何特殊配置即可显示256种颜色。参见这个相关问题。安装了ncurses-term
包后,我能够在使用我版本的Ubuntu的原始xterm上获得256种颜色(在这种情况下是Interpid,但我猜在早期版本中也可以)。对于Gnome终端、Konsole和PuTTY,我也能够获得256种颜色,如果值得一提的话。
当我谷歌搜索时,我得到的印象是大多数发行版没有在打包的终端模拟器中启用256色支持。
我怀疑如果你继续寻找,你可能会得出和我一样的结论。最好的答案是下载urxvt并自己编译,打开所有的铃铛和哨子。
我正在使用vim,所以可能有其他依赖关系/注意事项是emacs特定的,但我相当确定支持256种颜色的终端很重要。
tput colors
显示256,但emacs只能看到8个。是否需要Emacs 22?(它有致命的错误,阻止我使用它。) - Norman RamseyXTerm
和termName
之间不应该是.
,而应该是*
,即XTerm*termName
。 - Armen Michaeli