Last active
June 6, 2023 18:41
-
-
Save hovsater/4cc5ef1b6a35e6543c02456cd94e2ffa to your computer and use it in GitHub Desktop.
Change Zed theme automatically based on macOS appearance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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