Skip to content

Instantly share code, notes, and snippets.

@hovsater
Last active June 6, 2023 18:41
Show Gist options
  • Save hovsater/4cc5ef1b6a35e6543c02456cd94e2ffa to your computer and use it in GitHub Desktop.
Save hovsater/4cc5ef1b6a35e6543c02456cd94e2ffa to your computer and use it in GitHub Desktop.
Change Zed theme automatically based on macOS appearance
#!/usr/bin/env sh
set -e
dark_theme="Andromeda"
light_theme="Solarized Light"
while true; do
if defaults read -g AppleInterfaceStyle &>/dev/null; then
if [ $(< $HOME/.current-theme) = "dark" ]; then
continue;
fi
echo "dark" >| $HOME/.current-theme
sed -I .bk 's/^\([[:space:]]*\)"theme":\([[:space:]]*\)"[^"]*"/\1"theme":\2"'"${dark_theme}"'"/' ~/.config/zed/settings.json
else
if [ $(< $HOME/.current-theme) = "light" ]; then
continue;
fi
echo "light" >| $HOME/.current-theme
sed -I .bk 's/^\([[:space:]]*\)"theme":\([[:space:]]*\)"[^"]*"/\1"theme":\2"'"${light_theme}"'"/' ~/.config/zed/settings.json
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment