Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Run A Multiline AppleScript On The Command Line

AppleScipts are generally at least three lines. For example:

Code

tell application "Sublime Text"
    activate
  end tell

The line ending acts as he seperator. You can't use `;` like with javascript to make a single line command. Instead, you can pass each line with it's own `-e` flag.

For example:

Code

osascript -e 'tell application "Sublime Text"' -e 'activate' -e 'end tell'

Another option (and the one I generally go with) is to use javascript instead of applescript.

Code

osascript -l JavaScript -e "Application('Sublime Text').activate()"