2008-07-23

OS X command line tools: open

The /usr/bin/open command is a command line utility deriving from NextStep, and opens a file (or a directory or URL), just as if you had double-clicked the file's icon. It is the equivalent of the freedesktop xdg-open command but has a few options making it a bit more useful:
  • -a specifies the application to use, so "open -a firefox http://osnews.com/" opens the site in firefox.
  • -e Causes the file to be opened with /Applications/TextEdit
  • -t Causes the file to be opened with the default text editor, as determined via LaunchServices
  • -f Reads input from standard input and opens the results in the default text editor. End input by sending EOF character (type Control-D). Also useful for piping output to open and having it open in the default text editor.
  • -n Open a new instance of the application(s) even if one is already running.
  • -W Causes open to wait until the applications it opens (or that were already open) have exited. Use with the -n flag to allow open to function as an appropriate app for the $EDITOR environment variable.
Note especially that you can launch applications bundles, so
open $HOME/Downloads/GLTron.app
allows you to try out http://www.gltron.org/ directly after unpacking.

1 comment:

Anonymous said...

Good brief and this enter helped me alot in my college assignement. Say thank you you as your information.