Automatically select light/dark theme based on color-palette-update-notifications #4366
Description
Is your feature request related to a problem? Please describe.
Most modern operating systems and desktop environments do support Dark and Light themes, this includes at least MacOS, Windows, KDE Plasma, Gnome, and probably others.
Some even support switching from dark to light and light to dark mode based on sun rise / sun set.
In order to not make the terminal emulator look bad after such switch, we must enable the applications inside the terminal to detect when the terminal has updated the color palette. This may happen either due to the operating system having changed the current theme or simply because the user has explicitly requested to reconfigure the currently used theme (e.g. because the user requested to change the terminal profile, also containing a different color scheme).
Describe the solution you'd like
Adopt the color-palette-update-notifications standard.
Describe alternatives you've considered
All other solutions are kinda bad. It's good that we finally have a standard for this.
Additional context
Already supported by Ghostty, Kitty, Neovim, Tmux.
WezTerm, Zellij, and Helix are adding support at the moment.
Activity
stefanhaller commentedon Mar 6, 2025
Lazygit doesn't have a concept of light or dark themes; it is your terminal emulator that does. And as you say, many of them have support for this already or are adding support for it, so I'm not sure what you think is left for lazygit to do here.
cor commentedon Mar 6, 2025
Currently, lazygit only allows you to have one theme configured:
lazygit/docs/Config.md
Line 112 in 19ac926
You can however override this theme by doing something like this on startup:
lazygit/docs/Config.md
Line 746 in 19ac926
but that is an inferior solution, as it means that if you launch Lazygit with your "light theme configuration", and then switch your OS to dark mode, any instance of lazygit that was spawned before the switch will be stuck in the wrong theme.
The ideal solution would be to have two themes in the config, a dark_theme and a light_theme, and implement the
color-palette-update-notificationsprotocol such that currently running instances automatically change on OS theme switchstefanhaller commentedon Mar 6, 2025
I see. So the main feature request is not so much to support automatic switching of light/dark themes, but to add a distinction between light and dark themes in the first place; that's probably the bigger challenge, because it involves some design work (for example, to make it so that the distinction is only relevant for people who care about it, but keep it convenient for those who don't. Personally I don't, and I would like to keep setting my colors unconditionally without having to care about putting them in the right sub-theme).
Once we have that, adding the automatic switching shouldn't be a big deal.
Dom324 commentedon Mar 11, 2025
Another quirk is that the theme information should be ideally passed down to the diff engine, e.g.
pager: delta --darkvspager: delta --light.(though ideally the diff engine itself would also have support for CSI 2031, and then this isn't needed)
rbhanot4739 commentedon Jun 25, 2025
I think
deltadoes support detecting the terminal colors and adjusting its light/dark color presets based on them and it seems to work as expected when used as a native pager for git. However, when used as a pager forlazygitthe delta color preset does not seem to be applied correctly which means when system switches from dark to light mode or vice-versa I have to manually update the lazygit config to add--darkor--lightto the pager settings.Not sure if there is a better way to handle that.
pricci1 commentedon Oct 29, 2025
Related: #4550
pelletencate commentedon Nov 6, 2025
I did this as a workaround on macOS - This may not check my actual terminal setup, but it will automatically explicitly add --dark or --light to the delta pager based on whether my macOS system is currently in dark mode or not.
And then use it:
pricci1 commentedon Nov 11, 2025
Good idea. This works for me in KDE Plasma
t40mas commentedon Nov 14, 2025
Another workaround:
Since delta respects bat theme, you can set themes via env variables.
dive commentedon Jan 18, 2026
If you are on macOS, I use this little workaround with a Zsh alias. Here is what I have in my
.zshrc:light-mode.ymldark-mode.ymlalberti42 commentedon Feb 8, 2026
Maybe you already solved all the problems, but if you are still searching for a solution to synchronize TUI apps and your zsh when the OS system switches, I wrote a zsh plugin for that: https://github.com/alberti42/zsh-appearance-control. I found this thread because I was searching on Google for who else was troubled like me not having the terminal properly synced to the OS look. I tested syncing of tmux, Emacs, and Neovim in macOS and Gnome, and it works well.
Disclaimer: I did not try with lazygit. However, from what I understand, it would fit your case because you have a callback function that you can personalize, and when the OS theme switches, it automatically resyncs env variables and aliases that are relevant to styling your shell. With apps like Neovim and Emacs, the README in zsh-appearance-repo also shows you how, without installing any extra packages, you get immediate theme-syncing with the OS.
I think, in the long term, the solution based on CSI and DSR communication is the cleanest, but it will take some time before everybody adopts it (could be years for a widespread adoption). So, meanwhile, the plugin
zsh-appearance-repomay be helpful in the transition.stefanhaller commentedon Sep 26, 2026
Separate dark/light themes are added in #6065; allowing to pass
--darkor--lightto delta is done in #6063.Add gui.darkTheme and gui.lightTheme
Add gui.darkTheme and gui.lightTheme
Add gui.darkTheme and gui.lightTheme