Run terminal command on startup of netbeans in mac

2019-08-26 08:06发布

问题:

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.

回答1:

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?



回答2:

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_%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.