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.
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
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
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With