From a0dcb258c9abf9657b6795fabba0868840b682f8 Mon Sep 17 00:00:00 2001 From: Emma Thorpe Date: Wed, 10 Jun 2026 14:04:45 +0100 Subject: [PATCH] fix(tmux): use tmux-256color (not tmux-direct); add NO_TMUX hatch tmux-direct as default-terminal desyncs zsh's line redraw on some terminals (iTerm2: duplicated characters on Tab, stray newlines). Switch to the standard tmux-256color and advertise truecolor per outer terminal via terminal-features (add xterm-256color:RGB alongside the foot ones). Also add a NO_TMUX escape hatch to the auto-start guard, so `NO_TMUX=1 ` opens a bare shell. Co-Authored-By: Claude Opus 4.8 (1M context) --- lyrathorpe/home/shell.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lyrathorpe/home/shell.nix b/lyrathorpe/home/shell.nix index 83e4396..8d4bd9f 100644 --- a/lyrathorpe/home/shell.nix +++ b/lyrathorpe/home/shell.nix @@ -66,9 +66,11 @@ # not SSH -> don't force inbound SSH logins into a server tmux # not VS Code -> its integrated terminal manages itself # tmux on PATH -> a failed exec would otherwise kill the login shell + # $NO_TMUX unset -> escape hatch: `NO_TMUX=1 ` opens a bare shell (lib.mkOrder 200 '' if [[ $- == *i* ]] \ && [[ -z "$TMUX" ]] \ + && [[ -z "$NO_TMUX" ]] \ && [[ -z "$SSH_CONNECTION" && -z "$SSH_TTY" ]] \ && [[ "$TERM_PROGRAM" != "vscode" ]] \ && command -v tmux >/dev/null 2>&1; then @@ -139,7 +141,11 @@ programs.tmux = { enable = true; reverseSplit = true; - terminal = "tmux-direct"; + # tmux-256color (not tmux-direct): the standard inside-tmux terminfo. + # tmux-direct's capabilities desync zsh's line redraw on some terminals + # (e.g. iTerm2 -> duplicated chars on Tab, stray newlines). Truecolor is + # advertised per outer terminal via the RGB terminal-features below. + terminal = "tmux-256color"; newSession = true; keyMode = "vi"; historyLimit = 500000; @@ -187,6 +193,10 @@ bind -n M-Up select-pane -U bind -n M-Down select-pane -D + # Truecolor for the outer terminals (foot reports xterm-ish too; iTerm2 is + # xterm-256color). Without this, with tmux-256color as default-terminal, + # 24-bit colour would be quantised to 256. + set -as terminal-features ",xterm-256color:RGB" # Tell tmux which capabilities the foot terminal supports, so truecolor, # synchronised output, the system clipboard (OSC 52), window titles and # cursor styling all pass through.