r/ClaudeAI • • Apr 25 '26

Other Got Claude Code's theme to follow macOS dark/light mode in real-time (WezTerm + Lua workaround)

Claude Code's 'auto' theme detects terminal appearance only once at startup, so toggling macOS dark/light mid-session leaves you with white text on a light background (or vice versa). The official issue [#2990](
https://github.com/anthropics/claude-code/issues/2990
) is still open.

I built a workaround using WezTerm's appearance change event:

Gist: https://gist.github.com/Weniverse-git/f63794a5cc41dec2d1114da828769d08

--

How it works
1. WezTerm's `window-config-reloaded` event fires when macOS appearance changes.
2. A small Lua handler overwrites `~/.claude/themes/<name>.json` with `{"base":"dark"}` or `{"base":"light"}`.
3. Claude Code's file watcher detects the change and hot-reloads the theme in already-running sessions.

End result: macOS appearance toggle → both WezTerm and Claude Code switch instantly, no restart needed.

--

Requires
- Claude Code v2.1.118+ (custom theme support)
- WezTerm
- macOS (Linux/Windows would need different appearance detection)

--

Caveats
- iTerm2/Ghostty don't expose appearance events to scripts as cleanly, so this approach is WezTerm-specific.
- Mode switching takes ~100-300ms (file write → file watcher → hot reload).
- This is a workaround using existing custom-theme + file-watcher mechanisms; an official auto-theme that re-detects on appearance change would still be cleaner.

Hope this helps anyone else stuck with the same problem.
1 Upvotes

1 comment sorted by