Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question

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 >

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

share|improve this answer

You can write a bash script. Bash script is like windows batch file.

Here is a little example. Open sublime text and type in:

open -a "Sublime Text 2"
node scriptname.js
open -a "Safari" http://localhost

Save it as

Then open the terminal and navigate to script folder. Type in next command and hit enter:

chmod u+x

then run it:


More at bash scripts here and here.

share|improve this answer

Something like this should be fine:

open -a /Applications/Sublime\ Folder/ && node script.js && open http://localhost:80

Replace Folder/ with folder path and script to the nodejs script path.

share|improve this answer
how do I run this? is there some batch file for mac? – developer82 Feb 14 '14 at 18:50
Simply paste it in Terminal, or as already explained in the other answer save it in a .sh file. – gattol Feb 15 '14 at 13:41

You can save the script with a .command extension: this gives you a file you can "double-click" to open it as an application.

Both way's (use .sh or .command as an extension), you have to make the script executable with chmod in Terminal: chmod u+x ~/

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.