on master help sign in
Fix TUI glitches by forwarding real TERM and resolving to matching terminfo entry
commite39e63ff2ba107fba9474ee7c025806cd620a743 authoriko <mail@iko.soy> dateSun 28 Jun 2026, 03:55 (3 months ago) parenta91f97d
2 files changed+24−7
c+4−1 flake.nix+20−6
c+4−1
@@ -55,7 +55,10 @@ switch $argv[1]
5555 # Replace any existing container of the same name. The image's cmd is
5656 # /bin/fish, so no command is passed.
5757 container rm --force $name 2>/dev/null
58− container create --name $name --ssh -it --memory 8g --cwd /workspace $mounts $argv $image
58+ # Forward the host terminal type: the runtime strips $TERM down to a
59+ # bare "xterm", so pass the real value as HOST_TERM for the fish init to
60+ # recover (see prompt.fish) — TUIs need the matching terminfo entry.
61+ container create --name $name --ssh -it -e "HOST_TERM=$TERM" --memory 8g --cwd /workspace $mounts $argv $image
5962 case start
6063 container start -ai $name
6164 case '*'
flake.nix+20−6
@@ -84,12 +84,21 @@
8484 # No welcome banner.
8585 set -g fish_greeting
8686
87− # The container runtime hands fish a bare TERM=xterm (8 colors) and
88− # no COLORTERM, washing out colors. The bundled terminfo DB (via
89− # ncurses) has the 256-color entry, so promote xterm→xterm-256color
90− # and advertise truecolor for 24-bit-aware tools.
91− if test "$TERM" = xterm; or test -z "$TERM"
92− set -gx TERM xterm-256color
87+ # Pick a TERM whose terminfo entry actually exists in the bundled
88+ # database, so TUIs render with the right capabilities (otherwise
89+ # they glitch on redraw). The container runtime strips the host TERM
90+ # down to a bare "xterm"; `c` forwards the real value as HOST_TERM.
91+ # Ghostty reports "xterm-ghostty", but ncurses ships that entry under
92+ # the name "ghostty", so map it. Prefer HOST_TERM over the runtime's
93+ # bare "xterm" placeholder, falling back to xterm-256color.
94+ for term_candidate in $HOST_TERM $TERM xterm-256color
95+ test "$term_candidate" = xterm; and continue
96+ set -l entry $term_candidate
97+ test "$entry" = xterm-ghostty; and set entry ghostty
98+ if infocmp $entry >/dev/null 2>&1
99+ set -gx TERM $entry
100+ break
101+ end
93102 end
94103 set -q COLORTERM; or set -gx COLORTERM truecolor
95104
@@ -156,6 +165,11 @@
156165 # /etc/services. Without these, hostname resolution fails.
157166 pkgsLinux.fakeNss
158167 pkgsLinux.iana-etc
168+ # Terminfo tools (infocmp/tput/clear/reset). The terminfo DB
169+ # itself already ships via fish's ncurses dependency; this
170+ # puts the lookup tools on PATH so the prompt init can pick a
171+ # TERM entry that exists, and TUIs get correct capabilities.
172+ pkgsLinux.ncurses
159173 ];
160174 # Link all of /etc so the above files (nsswitch.conf, protocols,
161175 # services, passwd, group, ssl certs, fish prompt) are present.