Follow light/dark appearance in the tmux status bar

The status bar was five hardcoded tangere-dark colours, so in light mode the
pale #fdfdd9 text landed on a white background and became unreadable. That was
the real reason Auto appearance "never worked with the terminal setup" — ghostty
was switching correctly all along.

Split the colours into tmux-light.conf and tmux-dark.conf. The dark file is
extracted byte-exact from the previous config; the light file is the same layout
with each colour swapped for the tangere-light palette entry at the same index,
so roles are preserved (text on an accent uses the theme background, which
inverts from #1a2938 to #fdfdfa).

tmux 3.6+ learns the terminal's theme over OSC 2031, so this keys off the
appearance change itself rather than a schedule, and behaves identically whether
that came from Auto at sunrise/sunset or a manual toggle. Three hooks: the two
theme hooks react to a change, and client-attached covers a client attaching
mid-way, since those two only fire on a change. Sourcing is idempotent so the
overlap is harmless.

This replaces the dark-mode-notify launchd agent removed in 59d5622, which could
not have worked: it re-sourced .zshrc inside each shell, but the status bar
belongs to the tmux server.

Verified by round trip: flipping to Light switched #{client_theme} and applied
the light palette, and returning to Dark restored it. A running nvim does not
follow a live change (docs: the TUI sets 'background' on startup); noted in the
README.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonny Barnes 2026-08-09 12:38:16 +01:00
commit 6b3ab420ad
No known key found for this signature in database
5 changed files with 73 additions and 17 deletions

View file

@ -68,12 +68,24 @@ Most of this is now handled natively and needs no configuration:
- **bat** picks a theme per invocation from `BAT_THEME_LIGHT` / `BAT_THEME_DARK`.
- **delta** and **nvim** detect the terminal background themselves.
Still outstanding: the tmux status bar is hardcoded to dark-tuned colours, so it
is unreadable in light mode. tmux has `client-light-theme` and
`client-dark-theme` hooks for exactly this — not yet wired up.
The tmux status bar needs help, because its colours are set explicitly. They live
in `tmux-light.conf` and `tmux-dark.conf` — the same layout, with each colour
taken from the matching tangere palette index — and `tmux` sources one of them
from three hooks:
Both machines currently run pinned Dark, so the delta and nvim behaviour above is
documented-but-untested here. Worth re-checking when Auto goes back on.
- `client-light-theme` / `client-dark-theme` react to a change,
- `client-attached` picks the right one for a client that attaches mid-way, since
the two above only fire on a change.
Because this keys off the terminal's reported theme rather than a schedule, it
behaves identically whether the change came from Auto at sunrise/sunset or from
toggling Light/Dark by hand — nothing in the chain knows why it changed.
> [!NOTE]
> A running nvim will not follow a live change: the docs are explicit that the
> TUI sets `background` *on startup* if it can detect it. New instances are
> fine; existing ones need `:set background=light` or a restart. delta is
> per-invocation so should be fine, but that is untested here.
> [!NOTE]
> This previously used [`dark-mode-notify`](https://github.com/bouk/dark-mode-notify)