Skip to content

Instantly share code, notes, and snippets.

@andrewculver
Last active April 4, 2019 11:27
Show Gist options
  • Save andrewculver/43fe9718bd73fcaad05e4f03a65a2321 to your computer and use it in GitHub Desktop.
Save andrewculver/43fe9718bd73fcaad05e4f03a65a2321 to your computer and use it in GitHub Desktop.
Change Mac OS X Terminal.app background color in a shell script using AppleScript.
#!/usr/bin/env ruby
# NOTE: this requires actually setting up a terminal profile called "Prod".
# TODO i have no idea if this is good enough, sorry.
def escape_for_applescript(string)
string.gsub("\"", "\\\"")
end
def execute_applescript(applescript)
puts `osascript -e \"#{escape_for_applescript(applescript)}\"`
end
execute_applescript <<-AS
tell application "Terminal"
set current settings of window 1 to settings set "Prod"
end tell
AS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment