From 02cd1b51ebbfe65d973f64d6135b908989f6f6c4 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sun, 2 Feb 2020 23:43:47 +0000 Subject: [PATCH] Enable 24bit color support for Emacs in Terminal --- bin/emacsclient-wrapper | 2 +- playbooks/macos_terminfo.yml | 31 +++++++++++++++++++++++++++++++ terminfo/screen-24bit.terminfo | 11 +++++++++++ tmux.conf | 1 + zsh/emacs.zsh | 4 ++-- 5 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 playbooks/macos_terminfo.yml create mode 100644 terminfo/screen-24bit.terminfo diff --git a/bin/emacsclient-wrapper b/bin/emacsclient-wrapper index adadf5d..9bfe2b4 100755 --- a/bin/emacsclient-wrapper +++ b/bin/emacsclient-wrapper @@ -6,7 +6,7 @@ ALTERNATE_EDITOR="nano" # Set to binary bundled in Emacs.app if it exists if [ -f "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" ]; then - EMACSCLIENT="/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" + EMACSCLIENT="env TERM=screen-24bit /Applications/Emacs.app/Contents/MacOS/bin/emacsclient" fi # Execute emacsclient diff --git a/playbooks/macos_terminfo.yml b/playbooks/macos_terminfo.yml new file mode 100644 index 0000000..fed79ce --- /dev/null +++ b/playbooks/macos_terminfo.yml @@ -0,0 +1,31 @@ +--- +- hosts: localhost + tasks: + - name: Ensure ~/.terminfo directory exists + file: + path: "{{ ansible_facts.env.HOME }}/.terminfo" + state: directory + - name: Create temporary file to store terminfo source + tempfile: + register: tempfile + - name: Populate temporary file with terminfo source + copy: + dest: "{{ tempfile.path }}" + content: | + # From [[info:efaq#Colors%20on%20a%20TTY][Colors on a TTY]] + # Use colon separators. + screen-24bit|screen with 24-bit direct color mode, + use=screen-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. + screen-24bits|screen with 24-bit direct color mode, + use=screen-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, + - name: Compile terminfo with system tic + command: tic -x {{ tempfile.path }} + - name: Remove temporary file + file: + state: absent + path: "{{ tempfile.path }}" diff --git a/terminfo/screen-24bit.terminfo b/terminfo/screen-24bit.terminfo new file mode 100644 index 0000000..5e639dd --- /dev/null +++ b/terminfo/screen-24bit.terminfo @@ -0,0 +1,11 @@ +# From [[info:efaq#Colors%20on%20a%20TTY][Colors on a TTY]] +# Use colon separators. +screen-24bit|screen with 24-bit direct color mode, + use=screen-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. +screen-24bits|screen with 24-bit direct color mode, + use=screen-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, diff --git a/tmux.conf b/tmux.conf index 80ad449..3847513 100644 --- a/tmux.conf +++ b/tmux.conf @@ -5,6 +5,7 @@ bind C-q send-prefix # Settings set -g default-terminal "screen-256color" +set -ga terminal-overrides ",*256col*:Tc" set -g detach-on-destroy on set -g history-limit 50000 set -g display-time 3000 diff --git a/zsh/emacs.zsh b/zsh/emacs.zsh index 31dcb51..5160b6f 100644 --- a/zsh/emacs.zsh +++ b/zsh/emacs.zsh @@ -4,11 +4,11 @@ # OS X systems. if [ -f "/Applications/Emacs.app/Contents/MacOS/Emacs" ]; then - alias emacs="/Applications/Emacs.app/Contents/MacOS/Emacs -nw" + alias emacs="env TERM=screen-24bit /Applications/Emacs.app/Contents/MacOS/Emacs -nw" fi if [ -f "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" ]; then - alias emacsclient="/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" + alias emacsclient="env TERM=screen-24bit /Applications/Emacs.app/Contents/MacOS/bin/emacsclient" fi # *nix systems.