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.

Switch Applications From The Command Line With Apple's osascript

You can open and/or swith to an application from the command line using Apple's `osascript` tool to run either javascript or apple script.

The javascript looks like this:

Code

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

And the apple script version looks like this:

Code

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

In some cases, you'll need to use the full path to the app