From 780f6783a929293cb47096a0d00bda8f5bd1e3c2 Mon Sep 17 00:00:00 2001 From: "D. Ben Knoble" Date: Tue, 5 Nov 2024 17:35:16 -0500 Subject: [PATCH] term: fix tmux, alacritty info See also d0902a82 (switch from plink to zuo, 2024-10-18): after that switch led to [1], there have continued to be problems (such as htop not showing colors because the `pairs` attribute was interpreted as `0`). While upgrading to macOS Sonoma or beyond should come with new curses that makes things work again ([2], [3]), at the moment my current hardware is stuck on Monterey (and I don't relish trying OpenCore Legacy Patcher [4] right now). Instead, try _yet another hack_ [3]: decompile the tmux-256color entry with a modern curses, patch it, and recompile with the system curses. This appears to be completely working for tmux-256color, though does require the interesting workaround of using TERMINFO_DIRS (see `man infocmp` and compare with `man $(brew --prefix ncurses)/share/man/man1/infocmp.1m`). The post [3] also explains most of the details, but comes with another warning [5]. Finally, I noticed that somewhere in the process my alacritty terminfo had broken: `infocmp -x` produces similarly odd byte sequence [6] that turns on strikethrough (part of a `| xxd` dump): 000000a0: 206e 7063 2c20 7865 6e6c 2c20 1b5b 396d npc, xenl, .[9m The primary effect seems to be that italics were disabled. I can't find a way to compile the GitHub-provided entry that doesn't have this bug, but I can fix the italic sequences in Vim. [1]: https://superuser.com/a/1859217/990010 [2]: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/t/tmux.rb#L59C6-L59C62 [3]: https://gpanders.com/blog/the-definitive-guide-to-using-tmux-256color-on-macos/ [4]: https://dortania.github.io/OpenCore-Legacy-Patcher/ [5]: https://github.com/tmux/tmux/issues/2262#issuecomment-785385140 [6]: https://superuser.com/q/1858313/990010 --- links/vim/vimrc | 5 +++++ links/zshenv | 2 ++ main.zuo | 20 +++++++++++--------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/links/vim/vimrc b/links/vim/vimrc index 736a584..264c9aa 100644 --- a/links/vim/vimrc +++ b/links/vim/vimrc @@ -512,6 +512,11 @@ if ! exists('g:colors_name') endif let s:italic_default = 1 elseif $TERM ==# 'alacritty' + " for some reason, the alacritty profile isn't correct on my machine at the + " moment; probably because I'm stuck on macOS Monterey before the curses + " upgrade in Sonoma. + let &t_ZH = "\e[3m" + let &t_ZR = "\e[23m" let s:italic_default = 1 endif diff --git a/links/zshenv b/links/zshenv index f030133..dbb9757 100644 --- a/links/zshenv +++ b/links/zshenv @@ -29,6 +29,8 @@ export RIPGREP_CONFIG_PATH=~/.rgrc export RACO_TEST_ARGS='-j $$(nproc)' +export TERMINFO_DIRS=$TERMINFO_DIRS:$HOME/.local/share/terminfo + # personal vars {{{ # OS test diff --git a/main.zuo b/main.zuo index b70dfa2..7be1344 100644 --- a/main.zuo +++ b/main.zuo @@ -35,10 +35,10 @@ (define brew-url "https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh") + (define terminfo + (at-home ".local" "share" "terminfo")) (define tmux-terminfo - (at-home ".terminfo" "74" "tmux-256color")) - (define xterm-terminfo - (at-home ".terminfo" "78" "xterm-256color")) + (build-path terminfo "74" "tmux-256color")) (define targets `([:target default () @@ -61,14 +61,16 @@ [:target ,brewfile () ,(lambda (dest token) (shell/wait "brew bundle dump --force" (~a "--file=" (string->shell dest))))] - [:target (,tmux-terminfo ,xterm-terminfo) () + [:target ,tmux-terminfo () ,(lambda (dest token) + (rm* dest) (shell/wait - "curl -LO https://invisible-island.net/datafiles/current/terminfo.src.gz &&" - "gunzip terminfo.src.gz &&" - "tic -xe tmux-256color terminfo.src &&" - "tic -xe xterm-256color terminfo.src &&" - "rm terminfo.src"))] + "zsh -c" + (string->shell + (build-shell + `("/usr/bin/tic -x -o" ,(string->shell terminfo) + "=($(brew --prefix ncurses)/bin/infocmp -x tmux-256color |" + " sed -E 's/pairs#(0x10000|65536)/pairs#32767/')")))))] [:target dirs () ,(lambda (token) (for-each mkdir-p dirs)