Dark Mode Kitty and Neovim Using OSX's Toggle

I’ve been seeking a good toggle for dark/light terminals for a long time.

I have been using a dodgy environment variable… and after fooling around with the OSX dark/light toggle using an Alfred workflow I realized that I pretty much either want the high contrast light or a lower contrast dark across the whole computer.

After googling some stack overflow questions, I found a quick snippet that checks to see whether dark mode is enabled… later I found a better way using defaults read -g AppleInterfaceStyle, but it returns either “Dark” or an error… some more googling revealed that I can use 2>/dev/null to dump the error to nothingness and just match on “Dark”. It’s much faster than the javascript method I was using.

I just put an alias in a .zshenv file so that it’s loaded and usable by non-interactive shells. I then check it in my .zshrc and send a message to Kitty (my terminal of choice at the moment) to load the right theme.

It doesn’t update automatically, but it’s close enough.

You can see the changes here.


Changelog
  • 2019-07-30 12:06:04 -0500

    Update check method

  • 2019-07-30 10:21:50 -0500

    New Post: Kitty/Neovim dark mode