Skip to content

Instantly share code, notes, and snippets.

@saitonakamura
Created November 20, 2020 16:44
Show Gist options
  • Save saitonakamura/a8254da13523b120055c414b33094dd6 to your computer and use it in GitHub Desktop.
Save saitonakamura/a8254da13523b120055c414b33094dd6 to your computer and use it in GitHub Desktop.
Sets iTerm2 color preset based on MacOS setting
# Paste in your .bashrc/.zshrc
# Change to your color presets
ITERM2_DARK_PRESET='OneHalfDark'
ITERM2_LIGHT_PRESET='OneHalfLight'
theme=`defaults read -g AppleInterfaceStyle` &>/dev/null
if [ "$theme" = 'Dark' ] ; then
theme='dark'
else
theme='light'
fi
if [ "$theme" = 'dark' ] ; then
echo -e "\033]1337;SetColors=preset=$ITERM2_DARK_PRESET\a"
else
echo -e "\033]1337;SetColors=preset=$ITERM2_LIGHT_PRESET\a"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment