Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

True Color (24 bit) in Terminal Emacs

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

My problem is that I do not understand how emacs translates face information into escape sequences for the terminal. I also did not manage whether support for 24 bit color is present somewhere, or whether it is at all possible to implement it with emacs lisp. What I am asking for is a pointer to the relevant Emacs documentation or an informed opinion on whether having true color in terminal-emacs is feasible at the moment.

like image 606
grep Avatar asked Feb 03 '13 13:02

grep


People also ask

Does Emacs now support true color terminals?

UPDATE: Note that as of version 26.1, emacs now has support for true color terminals. Please see the answer belowfor more details. Share Improve this answer Follow edited Sep 23 '19 at 19:18

How can I test if the Terminal supports 24-bit or true color?

In a shell script, how can I test programmatically whether or not the terminal supports 24-bit or true color? This source says to check if $COLORTERM contains 24bit or truecolor. Just use tput colors. I believe testing for actual terminal capabilities is a much safer test than using $TERM or $COLORTERM

Why is Emacs so hard to read?

My original problem was that the reduction of the emacs colors to terminal colors (16 or 256 color) makes some faces extremely hard to read. And because I want to use a light and a dark color theme, manually tweaking the offending colors gets tricky.

How to check if $ColorTerm contains 24bit or truecolor?

This source says to check if $COLORTERM contains 24bit or truecolor. Just use tput colors. I believe testing for actual terminal capabilities is a much safer test than using $TERM or $COLORTERM


1 Answers

This was recently included in emacs 26.1 (28 May 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

Now you can start emacs with truecolor.

TERM=xterm-24bit emacs -nw

See the faq: https://www.gnu.org/software/emacs/manual/html_node/efaq/Colors-on-a-TTY.html

like image 103
ideasman42 Avatar answered Sep 28 '22 01:09

ideasman42