Home > Mac administration, Mac OS X > Opening Finder windows from the Terminal

Opening Finder windows from the Terminal

While working on the command line in Terminal, I occasionally need to open up a new Finder window so that I can take a look at something in the Finder. When this happens, the open command provides a useful shortcut to do so.

To open a new Finder window from the current directory in the Terminal, you would run the following command:

open .

For example, if you have navigated to the Pictures directory in your home folder, running this command would cause the Pictures directory to open in a new Finder window.

Screen Shot 2013-03-01 at 10.28.33 AM

Screen Shot 2013-03-01 at 10.26.25 AM

If you want to open a Finder window using Terminal for an alternate directory, you would run the following command:

open /path/to/directory

For example, if you wanted to access the XProtect.meta.plist file stored in the /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources directory, you could run this command to open the /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources directory in a new Finder window:

open /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources

Screen Shot 2013-03-01 at 10.27.41 AM

Screen Shot 2013-03-01 at 10.28.06 AM

  1. Conor Schutzman
    March 1, 2013 at 4:36 pm

    You can also use “find” to open a Findoer window with a specific application highlighted. This is my usual “presentation” step at the end of postflight for my installers, rather than adding the icon to the dock (as I hate messing with people’s docks).

    For example, if you wanted to open the Applications folder, with “Mail” selected (and thus front and center of the Finder window) the code would be:

    find “/Applications” -name “Mail.app” -maxdepth 1 -exec open -R {} \;

  2. jfw
    March 13, 2013 at 11:07 pm

    You can also command-click on the Terminal title bar, just as you can with other MacOS documents, to reveal the enclosing folder. (That would help you in your first example but not your second.)

    Also note that you can save time the other way: drop a file or folder into a Terminal window, and you’ll get the path to the item (properly escaped for the shell). And in Mountain Lion, you can also hold down the command key when you do that and you’ll cd straight to that dir (for a folder) or to the enclosing dir (for a file).

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 148 other followers

%d bloggers like this: