True Color (24 bit) in an Emacs terminal

I'm looking for a good way to have 24-bit color in emacs when using a graphical terminal emulator. For example, Konsole supports true color escape codes as described here: https://github.com/robertknight/konsole/blob/master/user-doc/README.moreColors

My problem is I don't understand how emacs is escaping face information for the terminal. I was also unable to determine if 24-bit color support is available anywhere, or if it is even possible to implement it using emacs lisp. What I'm asking is a pointer to the appropriate Emacs documentation, or an informed opinion about whether true color is actually possible in terminal emacs.

+3


source to share


4 answers


I'm using xterm-frobs.el to get support for 256 colors (in xterm compatible terminals like konsole). I am using the TERM setting "xterm-256color". Support for 256 colors is generally more than enough for me as I don't use that many colors in my color scheme. the above file tries to poll the terminal to find out how many colors it supports. i dont know if it should (or could be adapted to it) be able to maintain true colors in konsole.



UPDATE: Please note that as of version 26.1 emacs now supports true color terminals. Please see the answer below for more details.

-2


source


This was recently included in emacs 26.1 (May 28, 2018).

With this file: terminfo-24bit.src

# Use colon separators.
xterm-24bit|xterm with 24-bit direct color mode,
  use=xterm-256color,
  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,
# Use semicolon separators.
xterm-24bits|xterm with 24-bit direct color mode,
  use=xterm-256color,
  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,

      

Run:



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

      

You can now run emacs with truecolor.

TERM=xterm-24bit emacs -nw

      

See FAQ: https://www.gnu.org/software/emacs/draft/manual/html_mono/efaq.html#Colors-on-a-TTY

+7


source


AFAIK there is no built-in support for this, since the 24-bit color space in the terminal is rather unusual (!?). However, given that Emacs is open for you to add your own terminal support , you might want to try writing a package similar to xterm-frobs.el

.

By the way, if you only want a good color theme in the terminal, you can try my package https://github.com/tungd/color-theme-approximate , which translates the color-coded GUI theme into the terminal.

+3


source


It is possible, but it cannot be done in ELisp alone.

Here is a great list of patches for different versions of emacs and tmux to make trucolor life possible:

https://gist.github.com/choppsv1

0


source







All Articles