Sunday February 26, 2017
At work, I use Mac OS' Script Editor to create and compile AppleScript scripts to quickly configure my desktop depending on the programming task at hand. Each compiled script, or application, I place in the desktop folder so it appears on my desktop and can be activated with a simple double-click.
Three tasks I commonly have that I include and adjust as needed depending on the task:
#!/usr/bin/osascript
tell application "Terminal"
activate
do script
do script "cd /Users/gmazza/mydir1" in tab 1 of front window
my makeTab()
do script "cd /Users/gmazza/mydir2" in tab 1 of front window
my makeTab()
do script "cd /Users/gmazza/mydir3" in tab 1 of front window
end tell
on makeTab()
tell application "System Events" to keystroke "t" using {command down}
delay 0.2
end makeTab
activate application "IntelliJ IDEA" activate application "Visual Studio Code"
tell application "Google Chrome" open location "http://www.websiteone.com/onpage" open location "http://www.websitetwo.com/anotherpage" open location "http://www.websitethree.com" end tell
Script editor has a "run" button allowing me to test the scripts as I develop them. Once done, I save the script both standalone (so I can edit it later if desired), but also export it as an application. Exporting it allows for a simple double-click to directly run the task, rather than bringing up the Script Editor and requiring the script to be run via the "run" button.
The #!/usr/bin/osascript line added to the top of the script allows for alternatively running the script as a simple shell script from a terminal window.
Posted by Glen Mazza in Programming at 07:00AM Feb 26, 2017 | Comments[0]