Frequently I'm working from the command line in my Mac OS X box, and I want to open a file in my editor. With my file-type associations set, this is as easy as
$ open ./source/ca/odell/centricclient/Contact.java`</pre>The only problem is that I'm a [lazy](#) programmer and that's a lot to type. Plus I need to get the directories right.
With my new 1-line _fopen_ script, I can open the file easier:<pre>`$ fopen Contact.java`</pre>This works as long as Contact.java is in a subdirectory of the current working directory. It will open all files that contain "Contact.java" in their name. If I wanted to open all of my decorator files, I might call<pre>`$ fopen Decorator`</pre>This would open TableModelDecorator.java, ButtonDecorator.java, and even Decorator Invoice.pdf.
Here's the script:<pre>`#!/bin/bash
find . -name "*$1*" -exec bash -c "echo {} && open {}" \;