Invoking OS X apps from the command line.

Often I've been working inside the shell, and have wanted to edit or view a file in some non-terminal based application. I recently came across the open command, which allows the terminal to invoke OS X Finder Open commands.

For example, to start up iChat, entering open -a /Applications/iChat.app in a Terminal window will either launch the iChat application or bring it into focus if it's already running.

While this is useful, it can be a bit awkward to type everytime you want to launch an application. Developing a quick shell script is easy enough:


Safari.sh
#!/bin/sh
open -a /Applications/Safari.app $1

. . . and by placing it in my path, launching Safari is as easy as typing Safari at the prompt.