I’m trying to write a bash script to automate switching between the day/night versions of my favorite text editing themes. For instance, in Apple’s Terminal.app, I can
osascript -e "tell application \"Terminal\"" -e "set theSettingsSet to settings set named \"Pro\"" -e "set current settings of (every tab whose current settings is default settings of application \"Terminal\") of (every window whose visible is true) to theSettingsSet" -e "set default settings to theSettingsSet" -e "end tell"
to (1) switch every default-themed window to a new theme, and (2) change the default for subsequently created tabs.
In Sublime 2, I can
subl --command "set_setting {\"setting\":\"color_scheme\",\"value\":\"Packages/Color Scheme - Default/Amy.tmTheme\"}"
which changes the theme of the frontmost view, but doesn’t touch other views or Packages/User/Preferences.sublime-settings. According to Commands — Sublime Text Unofficial Documentation, this is as intended:
[quote]set_setting
Set the value of a setting. This value is view-specific.[/quote]
However, the GUI command Preferences > Color Scheme does exactly what I want. So while I suppose I could call
osascript -e "tell application \"System Events\"" -e "tell menu item \"Amy\" of menu \"Color Scheme\" of menu item \"Color Scheme\" of menu \"Preferences\" of menu item \"Preferences\" of menu \"Sublime Text 2\" of menu bar item \"Sublime Text 2\" of menu bar 1 of process \"Sublime Text 2\" to click" -e "end tell"
, this is is totally brittle (breaks in different localizations or if UI labels change between versions, requires user opt-in to Accessibility controls) and completely useless on Windows and Linux. Is there a native way to access and alter this setting?
Thanks for reading!