True color (24-bit) in terminal

相关的 patch/fork 早就有了,我试过几次都没成功(可能跟当时使用的终端和终端配置有关),于是放弃了治疗。

刚才看到这个回复:https://github.com/bbatsov/solarized-emacs/issues/18#issuecomment-294374266

here’s how i went around the problem. code supporting 24bit colors is already in emacs’ development version: e463e57 on osx this can easily be installed via the emacs-plus brew formula, using the --HEAD option.

this version of emacs requires a custom terminfo description xterm-24bit, which needs to be compiled manually:


$ cat terminfo-24bit.src

# Use semicolon separators.
xterm-24bits|xterm with 24-bit direct color mode,
        use=xterm-256color,
        Tc,
        setb24=\E[48;2;%p1%{65536}%/%d;%p1%{256}%/%{255}%&%d;%p1%{255}%&%dm,
        setf24=\E[38;2;%p1%{65536}%/%d;%p1%{256}%/%{255}%&%d;%p1%{255}%&%dm,

$ tic -x -o ~/.terminfo terminfo-24bit.src

this will also work for tmux, provided that true color is also setup tmux side. source: Re: Black and white emacs -nw (WAS: Re: [PATCH v3 0/4] Support 24-bit te more on how to setup tmux true color here.

TERM=xterm-24bits emacs -nw and the theme works flawlessly. :ok_hand:

跟着试了一下,果然在终端下看到了平滑过度的灰色:


  • macOS 10.11.6
  • iTerm2 v3.0.15 + Solarized-dark
1 个赞

字都认识,但是读的懵懵懂懂 http://lists.gnu.org/archive/html/emacs-devel/2017-02/msg00635.html 这个链接说是要重新编译tmux,然后tmux下运行emacs,但是实在看不懂这段代码怎么用

$ cat terminfo-24bit.src

    # Use semicolon separators.
    xterm-24bits|xterm with 24-bit direct color mode,
            use=xterm-256color,
            Tc,
            setb24=\E[48;2;%p1%{65536}%/%d;%p1%{256}%/%{255}%&%d;%p1%{255}%&%dm,
            setf24=\E[38;2;%p1%{65536}%/%d;%p1%{256}%/%{255}%&%d;%p1%{255}%&%dm,

    $ tic -x -o ~/.terminfo terminfo-24bit.src

就是创建一个名为 terminfo-24bit.src,内容为中间那一段,然后用最后一行的命令去执行。这是常用的表达方式,要习惯。代码比文字描述更清晰、准确、可靠

你不着急编译/配置 tmux,先在 iTerm2 下实验成功再说。

emacs-plus 在没打补丁的 tmux ( stable v2.3) 下是这样的,明显看到灰色过渡不连贯。我平时没在 tmux 里运行 emacs,暂时不管它。

我用的linux,solarized这个主题在终端显示不正常,所以一直但是放弃的,

Tmux 2.4 发布了,支持 True Color,不过它的 vi 模式有点问题,影响不大。

另外要说明一下,Emacs 支持终端真彩的 patch 早就进 master 分支了,跟前面提到的 Emacs Plus 没关系。

终端 emacs 的烦恼事又少了一件,可喜可贺,现在就剩下快捷键了。

看了一下,需要安装emacs-snapshot,我来试试看是否支持solarized

终端与emacs带的gui颜色显示已经没区别了,然而突然发现不怎么喜欢solarized

一定要在tmux里面启动emacs么