Last active
April 4, 2019 11:27
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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