views:

619

answers:

2

Hey, does anybody know of a good way to run a command in the terminal when you startup netbeans in mac osx? Either as an option in netbeans or as a feature of mac osx? I'd like automatically sync my local files with a remote folder on startup of netbeans, so I'd like to run an rsync command when netbeans starts up. Otherwise I forget and I wind up with conflicts.

A: 

Why not just rename the original "netbeans" in your path to something else, and write a sciprt named "netbeans", which first runs the desired command, and then runs the original netbeans executable?

ivan_ivanovich_ivanoff
That sounds like a great idea. Though I'm having trouble finding out how to write that script... what format, and where to put it... how to associate a new icon with it. My googling skills are failing me. Do you mind offering a little more direction?
Bob Ralian
Sorry, no experience with MacOS.
ivan_ivanovich_ivanoff
A: 

There are a billion ways to do this. The two ways I would try are either writing a bash script, or making an Automator script.

For a bash script:

#!/usr/bin/bash

script_you_want_to_run.sh

open -a NetBeans.app  # or this doesn't work, you can run /Applications/NetBeans/NetBeans.app/MacOS/Contents/NetBeans

Then, save this as myNetBeans.term and you can double click the .term file and it will run.

Or, open up Automator, http://en.wikipedia.org/wiki/Automator%5F%28software%29, and link together the commands you want to run. It's pretty easy to use, and you can string a chain of commands together really easy (and even pipe info from one application to the next!). From the wiki page, each action is preformed before moving to the next action.

You could also use Applescript, but I recommend using Automator instead, as Applescript has a syntax that looks easy but will trip you up.

Stanza