如何设置 Linux X 终端以便 Emacs 可以访问 256 种颜色?

发布于 2024-07-16 00:52:05 字数 342 浏览 13 评论 0原文

当我在 X 终端窗口中运行 emacs -nw 并请求 Mx list-colors-display 时,我得到了一个微不足道的调色板:

black                                                     
red    
green  
yellow 
blue   
magenta
cyan   
white  

我被告知这是可能的获得265种颜色。 将 TERM 环境变量设置为 xterm-256color 不起作用。 有什么作用?

When I run emacs -nw in an X terminal window, and I ask for M-x list-colors-display, I am offered a paltry palette:

black                                                     
red    
green  
yellow 
blue   
magenta
cyan   
white  

I am told it is possible to get 265 colors. Setting the TERM environment variable to xterm-256color does not do the job. What does?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

焚却相思 2024-07-23 00:52:05

根据这个你需要除了将 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

According to this you need ncurses-term library in addition to setting TERM to xterm-256color.

Okay, this has some other things to try like :

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

and :

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
微凉 2024-07-23 00:52:05

TERM 设置为 xterm-256color 是您想要做的。 另外,Emacs 22(至少)不需要我进行任何特殊配置即可显示 256 种颜色。 请参阅此相关问题。 安装了 ncurses-term 软件包后,我可以使用我的 Ubuntu 版本附带的普通 xterm(在本例中为 Interpid,但我猜它会在 Emacs 上获得 256 种颜色)在早期版本上没问题)。 我还使用 Gnome Terminal、Konsole 和 PuTTY 获得了 256 种颜色,这是值得的。

Setting TERM to xterm-256color is what you want to do. Also, Emacs 22 (at least) didn't need any special config from me in order to display 256 colors. See this related question. With the ncurses-term package installed, I was able to get 256 colors on Emacs using the vanilla xterm that came with my version of Ubuntu (Interpid, in this case, but I'm guessing it'll be fine on earlier versions). I also got 256 colors using Gnome Terminal, Konsole, and PuTTY, for what that's worth.

清泪尽 2024-07-23 00:52:05

当我用 google 搜索这个时,我得到的印象是大多数发行版在打包的终端模拟器中都没有启用 256 色支持。

我怀疑如果你继续寻找,你可能会得出与我相同的结论。 最好的答案是下载 urxvt 并自行编译它口哨声响起。

我使用的是 vim,因此可能存在其他 emacs 特定的依赖项/陷阱,但我很确定支持 256 色的终端很重要。

When I googled this I got the impression that most distros don't enable 256 colour support in the packaged terminal emulators.

I suspect if you keep looking you may come to the same conclusion that I did. The best answer is to download urxvt and compile it yourself with all the bells and whistles turned on.

I was using vim, so there may be other dependencies/gotchas that are emacs specific, but I'm pretty sure a terminal that supports 256 colours is important.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文