终端emacs颜色只能使用TERM = xterm-256color [英] Terminal emacs colors only work with TERM=xterm-256color
问题描述
我发现终端emacs没有渲染正确的颜色,除非我明确设置TERM = xterm-256color。我使用gnome-terminal,从我的理解,TERM应设置为gnome-256color。同样地,我倾向于使用tmux,它建议不要使用screen-256color以外的任何TERM设置。不幸的是,这两个设置(在各自的上下文中 - gnome-terminal
或 tmux
)导致emacs有错误的颜色,而vim正确显示颜色。但是,如果我导出TERM = xterm-256color
,这些颜色在emacs中正常工作。
任何人都可以解释发生甚么或提供解决方案?
更新
这是我正在处理的: p>
我可以通过将以下内容添加到我的 init.el
中来获得正确的颜色:
(defun terminal-init-gnome()
gnome-terminal的终端初始化函数
;;这个是一个肮脏的黑客,我不小心绊倒:
;;初始化rxvt首先和_then_xterm似乎
;;使颜色工作...虽然我不知道为什么
(tty-run-terminal-initialization(selected-frame)rxvt)
(tty-run-terminal-initialization(selected-frame)xterm))
感觉真的真的错了啊。必须有一个逻辑的解释...
PS
我对terminfo知之甚少以及 $ TERM
在彩色终端行为过程中的确切作用。 如果总是使用 xterm-256color
(即使 $ TERM
应该是code> gnome-256color 或 screen-256color
),我会一起去。
也许我不了解某些东西,买你为什么不运行这样的emacs:
TERM = xterm-256color emacs -nw
Emacs有自己的TERM设置,你知道工作。您也可以在shell脚本中创建别名或将其包装。
I've found that terminal emacs does not render the correct colors unless I explicitly set TERM=xterm-256color. I use gnome-terminal, and from what I understand, TERM should be set to gnome-256color. Similarly, I tend to use tmux a lot, which advises against any TERM setting other than screen-256color. Unfortunately, both of those settings (within their respective context - gnome-terminal
or tmux
) result in emacs having wrong colors, whereas vim displays colors correctly. However, if I export TERM=xterm-256color
, the colors work just fine in emacs.
Can anyone explain what's going on, or offer a solution?
Update
Here's what I'm dealing with:
I can get the colors to look correct in the terminal by adding the following to my init.el
:
(defun terminal-init-gnome ()
"Terminal initialization function for gnome-terminal."
;; This is a dirty hack that I accidentally stumbled across:
;; initializing "rxvt" first and _then_ "xterm" seems
;; to make the colors work... although I have no idea why.
(tty-run-terminal-initialization (selected-frame) "rxvt")
(tty-run-terminal-initialization (selected-frame) "xterm"))
This feels really, really wrong though. There has to be a logical explanation for this...
P.S.
I have very little knowledge of terminfo and the precise role that $TERM
plays in the process of color terminal behavior. If it's safe to always use xterm-256color
(even when $TERM
"should" be gnome-256color
or screen-256color
), I'll go with that.
Maybe I'm not understanding something, buy why don't you run emacs like this:
TERM=xterm-256color emacs -nw
This way Emacs has its own TERM setting that you know works. You can also make an alias or wrap this in shell-script.
这篇关于终端emacs颜色只能使用TERM = xterm-256color的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!