MacOS – Writing a shell script (or something similar) that will execute some commands

command linemacosterminal

For my work I use an app called Sublime Text to edit website documents. To open my project in sublime text I drag the folder above the icon and it opens it up in sublime text.

My next step is to run a nodejs script, and after it's run open chrome and navigate to a local url.

My question is – how can I automate that process – meaning I will have a script that I run (command line is fine) that will open the project in sublime text, run the nodejs script (which starts a local web server), open safari to a url.

Is that possible?

Thanks

Best Answer

Yes, this is possible. The two best options for stitching together Mac applications are AppleScript and Automator.

Given your steps, consider exploring the included Automator application: Applications > Automator.app

Apple's Mac Basics: Automator support note is a good starting point.

The following Actions are likely to help:

  • Display Webpages for opening your default browser and showing a URL
  • Run Shell Script for interacting with node.js
  • Open Finder Items for opening documents in Sublime Text

Automator on OS X 10.9