I'm looking for a simple script that will do the following. Can anyone take a shot at it (+ if cryptic, please explain what it does), or give me some pointers so I can run this myself?
I want to start up a GUI application in the Applications directory from the command line prompt, giving it parameters if necessary:
$> launch Foobar arg1 arg2 arg3
What the launch shell script should do is:
1) Read a configuration file that looks something like this:
/Applications/$0.app
/Applications/$0
/Applications/**/$0.app
/Applications/**/$0
2) Try to match the first argument ("Foobar") in this case with each line of the configuration file, in order, with "*" representing any sequence of characters in a path segment and "**" representing any path segment, and $0
representing the program name. So in this case it's looking for Foobar.app and Foobar in the Applications directory and any of its subdirectories.
3) Execute the resulting command with the remaining arguments as specified ("arg1", "arg2", "arg3")
It sounds easy, but I'm too much of a newbie with shell scripts at the moment. I may end up using JSDB since I know how to use it. I am just not sure how to specify that a script called "launch" should require the JSDB program to run it, or whether it's compatible with doing that.
Specific use case: If I'm in a directory within the command prompt, I often want to do one of the following:
- Launch TextEdit to create a new file named X
- Launch TextEdit to open a file named X
- Launch {name your favorite program} to create or open a file named X
- Open a Finder window in this directory
In particular, I wanted to edit my Mercurial .hg/hgrc file yesterday, and it took me forever to figure out how, since .hg is a directory that's hidden from GUI file-open dialog boxes. I still don't remember how I got it to work.