This tmux tpm plugin will change the tmux theme automatically when the system changes the light/dark mode. Configure a light and a dark theme and the plugin will take care of the rest!
For example I use a Solarized in all my programs that support it. For tmux I use seebi/tmux-colors-solarized which is locally cloned (in my dotfiles as a submodule). This tmux theme repo provides a light theme tmuxcolors-light.conf
and a dark theme tmuxcolors-dark.conf
. With this tmux plugin, I have configured so that when the system appearance mode changes, the corresponding tmux theme will be used.
Hats off to dark-notify which this plugin is built up on!
$ brew install dark-notify
Configure tmux-dark-notify in tmux.conf
set -g @plugin 'erikw/tmux-dark-notify'
set -g @dark-notify-theme-path-light '$HOME/.config/tmux/plugins/tmux-colors-solarized/tmuxcolors-light.conf'
set -g @dark-notify-theme-path-dark '$HOME/.config/tmux/plugins/tmux-colors-solarized/tmuxcolors-dark.conf'
To cover some corner cases e.g. if you use the plugin tmux-reset or another TPM plugin sets the theme itself, I recommend adding this explicit source of the theme as well as a fallback in case this plugin is not run in all scenarios. The if-shell
condition is there because the symlink won't be there the very first time until tmux-dark-notify has run. It should be placed after TPM is initialized, because the ordering of plugin initialization is not guaranteed. Remove any other source-file
for theme you have of course!
run-shell '~/.config/tmux/plugins/tpm/tpm' # Or however you source tpm.
if-shell "test -e ~/.local/state/tmux/tmux-dark-notify-theme.conf" \
"source-file ~/.local/state/tmux/tmux-dark-notify-theme.conf"
Thus in summary, the relevant section of you tmux.conf
could look like this (including the theme I use)
[...]
set -g @plugin 'seebi/tmux-colors-solarized'
set -g @plugin 'erikw/tmux-dark-notify'
set -g @dark-notify-theme-path-light '$HOME/.config/tmux/plugins/tmux-colors-solarized/tmuxcolors-light.conf'
set -g @dark-notify-theme-path-dark '$HOME/.config/tmux/plugins/tmux-colors-solarized/tmuxcolors-dark.conf'
[...]
run-shell '~/.config/tmux/plugins/tpm/tpm' # Or however you source tpm.
if-shell "test -e ~/.local/state/tmux/tmux-dark-notify-theme.conf" \
"source-file ~/.local/state/tmux/tmux-dark-notify-theme.conf"
<prefix>I
, unless you changed tpm's keybindings.ls -l ~/.local/state/tmux/tmux-dark-notify-theme.conf
to see that it is linked to the light or dark theme you configured.Quick Action
.apperance_toggle
.apperance_toggle
service we just created under the General categoryI have another tmux plugin that might interest you: