Skip to content

Instantly share code, notes, and snippets.

@chaidhat
Created July 7, 2021 08:25
Show Gist options
  • Save chaidhat/78d45a4c345f0a9e9e985fb69cccc26d to your computer and use it in GitHub Desktop.
Save chaidhat/78d45a4c345f0a9e9e985fb69cccc26d to your computer and use it in GitHub Desktop.
Mac OS Terminal which changes theme based on dark mode
DARKMODE=$(defaults read -g AppleInterfaceStyle)
# actually an || or && function could've worked as Light mode throws an error. but i wanted to show off
if [ "$DARKMODE" = "Dark" ]; then
osascript -e '
tell application "Terminal"
set current settings of selected tab of window 1 to settings set "Basic Dark"
end tell
' `pwd`
else
osascript -e '
tell application "Terminal"
set current settings of selected tab of window 1 to settings set "Basic Light"
end tell
' `pwd`
fi
@chaidhat
Copy link
Author

chaidhat commented Jul 7, 2021

Please replace "Basic Dark" and "Basic Light" with the NAME of your respective theme. Please leave a star, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment