Skip to content

Commit

Permalink
term: fix tmux, alacritty info
Browse files Browse the repository at this point in the history
See also d0902a8 (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]: tmux/tmux#2262 (comment)
[6]: https://superuser.com/q/1858313/990010
  • Loading branch information
benknoble committed Nov 5, 2024
1 parent f18a51b commit 780f678
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
5 changes: 5 additions & 0 deletions links/vim/vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions links/zshenv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 11 additions & 9 deletions main.zuo
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand All @@ -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)
Expand Down

0 comments on commit 780f678

Please sign in to comment.