< Day Day Up > |
The open shell command lets you open Finder windows and launch Aqua applications. To open a directory in the Finder, use open, followed by the name of the directory. For example, to open a Finder window containing the current directory, enter the following command: open . Figure 1-8. Defining a bookmark to a new profile in iTermTo open your Public folder (~/Public) in a Finder window, use the following: open ~/Public To open the /Applications folder in a Finder window, use the following: open /Applications To open an application, you need only its name. To open Xcode (/Developer/Applications), you would use the following: open -a Xcode
You can use the -a option to open a file with something other than the application with which it's associated. For example, to open an XML file in Xcode instead of the default XML editor, the Property List Editor, enter this command: open -a Xcode data.xml To open multiple files, you can use wildcards: open *.c To force a file to be opened with TextEdit, use -e: open -e *.c The -e option directs the file to be opened in TextEdit; it cannot be used to open a file in another text editor, such as BBEdit (though BBEdit includes its own command-line application for this purpose). However, if you want to open a file using BBEdit, use the following: open -a BBEdit filename If you want to use TextEdit on a file that is owned by an administrator (or root), sudo open -e won't work. You'll need to specify the full path to the TextEdit executable, as in: $ sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit filename If you find yourself doing this often, you might want to create an alias for the path to TextEdit's executable file. For example, you could enter the following into your .bash_profile file: alias sudotext="sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit " Then the next time you want to open a text file that would otherwise require use of the sudo command, you could just use the following: $ sudotext filename When you enter that command, you'll be prompted for the admin password; once authenticated, the file you've specified is opened in TextEdit, just as you hoped it would.
|
< Day Day Up > |