How to automatically switch Tmux themes between light & dark

TL;DR:

Here's how you automatically switch between catppuccin themes:

if-shell -F "#{==:#{client_theme},light}" {
    set -g @catppuccin_flavor 'latte'
} {
    set -g @catppuccin_flavor 'mocha'
}
set-hook -g client-dark-theme {
  set -g @catppuccin_flavor "mocha"
  run ~/.config/tmux/plugins/catppuccin/tmux/catppuccin.tmux
}
set-hook -g client-light-theme {
  set -g @catppuccin_flavor "latte"
  run ~/.config/tmux/plugins/catppuccin/tmux/catppuccin.tmux
}
run ~/.config/tmux/plugins/catppuccin/tmux/catppuccin.tmux

For catppuccin specifically you'll need my fork until their reset feature is implemented. If you're using a different theme, this doesn't apply.

And this is the result:

Read on to learn more about how automatic theme switching works.

Prerequisites

Many desktop environments & operating systems support both dark & light themes these days. If you switch between them, your applications can update their themes, too. Most applications support this, but the terminal space has been lagging a little bit.

We're finally here though! Adoption of CSI 2031 has been increasing and since Tmux 3.6 (released in Nov 2025) it now also supports automatic theme changes.

Here's what you'll need for this to work:

  • A terminal with support for CSI 2031 (I use Ghostty)
  • Tmux version 3.6 or higher
  • An operating system or desktop environment that supports theme/appearance switching

To test if CSI 2031 is working, you can open a command line and run this:

echo -e '\e[?2031$p'

If this displays 2031;2$y then it's supported. You can query your current mode as follows:

echo -e "\e[?996n"

This shows 997;1n for dark mode and 997;2n for light mode. So either 1 (dark) or 2 (light).

Tmux Configuration

You'll need to pick a light and a dark theme to switch between. For this post, I'll use catppuccin's tmux themes, but pick whichever light & dark themes you like.

Previously, you would configure your theme like this:

set -g @catppuccin_flavor 'mocha'
run ~/.config/tmux/plugins/catppuccin/tmux/catppuccin.tmux

Now that you want to support both themes, you'll do this instead:

if-shell -F "#{==:#{client_theme},light}" {
    set -g @catppuccin_flavor 'latte'
} {
    set -g @catppuccin_flavor 'mocha'
}
run ~/.config/tmux/plugins/catppuccin/tmux/catppuccin.tmux

This section picks the right theme on start-up based on the current operating system appearance. The variable client_theme was added as part of the same change that introduced support for CSI 2031 notifications. At this point, your tmux will start with the right theme, but it won't update if you switch appearance in your operating system settings.

Note: Tmux has its own conditional language with %if, but I could not get it to work. I suspect client_theme might not be available when the condition is evaluated, so I used if-shell to make it work.

To achieve dynamic theme updates, we need to react to this event:

set-hook -g client-dark-theme {
  set -g @catppuccin_flavor "mocha"
  run ~/.config/tmux/plugins/catppuccin/tmux/catppuccin.tmux
}
set-hook -g client-light-theme {
  set -g @catppuccin_flavor "latte"
  run ~/.config/tmux/plugins/catppuccin/tmux/catppuccin.tmux
}

The new hooks client-dark-theme and client-light-theme first set the corresponding theme variable and then reload catppuccin.

Note: It is currently not as easy with catppuccin due to how they set options. I've created a minimal fork to work around this issue. However, the catppuccin team has been working on a fix to make resetting the theme possible. Subscribe to & upvote that pull request if you're using catppuccin.

Reload your configuration or restart tmux. If you change your operating system appearance, tmux will update to use the correct theme as well!

In the past I used dark-notify on MacOS and had to manually edit my config on Linux. Now Tmux has native support for it!