Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to change macOS Terminal's theme/profile based on the system dark/light mode?

In macOS's Terminal app, the default theme (Basic) adapts dynamically to system settings, but as soon as I customize the Basic theme from the preferences menu, it stops adapting. Is there a way to manually configure Terminal to look at the system mode and choose a theme appropriately?

like image 716
Parth Shimpi Avatar asked Dec 17 '22 12:12

Parth Shimpi


2 Answers

macOS's Terminal app doesn't have a setting to dynamically pick a theme. However, when customizing a theme (or creating your own), you can pick colors that dynamically adapt to the OS.

When choosing colors, go to the third tab and, from the drop-down at the top, choose Developer. These colors will adapt automatically to the current system theme.

⚠️ Caveat: If you modify these colors in any way (even only their alpha transparency), they will stop adapting to the system theme.

screenshot

like image 85
Marlon Richert Avatar answered Jan 29 '23 15:01

Marlon Richert


For those who end up here looking for a way to change the terminal theme if your system is in Dark Mode, I did find this solution dark-mode-macos-safari-iterm-vim, you can default to a light theme and this will override with a dark theme when you launch Terminal in dark mode.

# Switch to Solarized Dark if we are currently in dark mode
if [[ "$(uname -s)" == "Darwin" ]]; then
  val=$(defaults read -g AppleInterfaceStyle 2>/dev/null)
  if [[ $val == "Dark" ]]; then
    osascript -e 'tell application "Terminal"
      set current settings of tabs of windows to settings set "Solarized Dark" # Theme name
    end tell'
  else
  fi
fi
like image 34
Jimmy Bosse Avatar answered Jan 29 '23 16:01

Jimmy Bosse