move Apple Terminal theme switcher to per-term function
1 file changed, 42 insertions(+), 0 deletions(-)
A user/settings/fish/per-term/set-terminal-theme.applescript
@@ -0,0 +1,42 @@ +#!/usr/bin/env osascript +use scripting additions + +to getSystemAppearance() + tell application "System Events" + set isDark to dark mode of appearance preferences + end tell + + if isDark then + return "dark" + else + return "light" + end if +end getSystemAppearance + +to setTerminalProfile(targetProfile) + tell application "Terminal" + set default settings to settings set targetProfile + set startup settings to settings set targetProfile + + repeat with existingWindow in windows + set current settings of existingWindow to settings set targetProfile + end repeat + end tell +end setTerminalProfile + +on run argv + set lightProfile to "Flexoki Light" + set darkProfile to "Flexoki Dark" + + if length of argv is 0 then + set targetMode to getSystemAppearance() + else + set targetMode to item 1 of argv + end if + + if targetMode = "dark" then + setTerminalProfile(darkProfile) + else + setTerminalProfile(lightProfile) + end if +end run