3/12/2004

Using TextEdit as your EDITOR

Anyone who has used Unix for a while knows about EDITOR. It's an environment variable you set to tell applications that want you to edit stuff what your preferred editor is. It's usually set to vi by default and it's easy enough to figure out how to set it to emacs or pico. But what if you want to set it to something like TextEdit or SubEtheaEdit?

You can't set it to /Applications/TextEdit.app because to the shell, that looks like a directory. You can't set it to "open -a TextEdit.app" because open will return immediately and the program which is asking you to edit something will think you didn't make any changes. The solution is to set it to the actual executable inside of the bundle:

/Applications/TextEdit.app/Contents/MacOS/TextEdit

If you run the actual executable inside the bundle from the shell, the OS will actually fire up a new copy of that application, blocking the shell until the application quits. Pretty weird, and useful in certain situations.

Setting your editor to TextEdit gives you the benefit of spell checking, services, etc, and generally feels nicer for someone who is more used to the Mac than to Unix.

1 comment:

Steve Ivy said...

If you have BBEdit and the bbedit unix tools installed, you can also set your EDITOR to 'bbedit -w' and it will do the same thing.