Writing a shell script (or something similar) that will execute some commands
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
You can write a bash script. Bash script is like windows batch file.
Here is a little example. Open sublime text and type in:
#!/bin/bash
open -a "Sublime Text 2"
node scriptname.js
open -a "Safari" http://localhost
Save it as script.sh
Then open the terminal and navigate to script folder. Type in next command and hit enter:
chmod u+x script.sh
then run it:
./script.sh
More at bash scripts here and here.
Something like this should be fine:
open -a /Applications/Sublime\ Text.app/ Folder/ && node script.js && open http://localhost:80
Replace Folder/ with folder path and script to the nodejs script path.
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 ~/MyScript.sh
.