Juicy lil' bytes

Open the Current Working Directory in the Mac OSX Finder From the Command Line

Here is a simple command line one-liner that opens the current working directory in your Mac OSX finder.

Open the Current Working Directory in the OSX Finder

The open command is your ticket:

1
open .

Enter open with a period symbol (i.e. the current directory) and the finder will open in your current working directory.

open is an extremely flexible and useful executable. Here is the manual page for OSX version 10.9 from the Mac Developer Library:

The open Manual Page
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
OPEN(1)                   BSD General Commands Manual                  OPEN(1)

NAME
     open -- open files and directories

SYNOPSIS
     open [-e] [-t] [-f] [-F] [-W] [-R] [-n] [-g] [-h] [-b bundle_identifier] [-a application] file ...
          [--args arg1 ...]

DESCRIPTION
     The open command opens a file (or a directory or URL), just as if you had double-clicked the file's
     icon. If no application name is specified, the default application as determined via LaunchServices is
     used to open the specified files.

     If the file is in the form of a URL, the file will be opened as a URL.

     You can specify one or more file names (or pathnames), which are interpreted relative to the shell or
     Terminal window's current working directory. For example, the following command would open all Word
     files in the current working directory:

     open *.doc

     Opened applications inherit environment variables just as if you had launched the application directly
     through its full path.  This behavior was also present in Tiger.

     The options are as follows:

     -a application
         Specifies the application to use for opening the file

     -b bundle_indentifier
         Specifies the bundle identifier for the application to use when opening the file

     -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.

     -F  Opens the application "fresh," that is, without restoring windows. Saved persistent state is lost,
         except for Untitled documents.

     -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 vari-able. variable.
         able.

     -R  Reveals the file(s) in the Finder instead of opening them.

     -n  Open a new instance of the application(s) even if one is already running.

     -g  Do not bring the application to the foreground.

     -h  Searches header locations for a header whose name matches the given string and then opens it.  Pass
         a full header name (such as NSView.h) for increased performance.

     --args
         All remaining arguments are passed to the opened application in the argv parameter to main().
         These arguments are not opened or interpreted by the open tool.

EXAMPLES
     "open '/Volumes/Macintosh HD/foo.txt'" opens the document in the default application for its type (as
     determined by LaunchServices).

     "open '/Volumes/Macintosh HD/Applications/'" opens that directory in the Finder.

     "open -a /Applications/TextEdit.app '/Volumes/Macintosh HD/foo.txt'" opens the document in the applica-tion application
     tion specified (in this case, TextEdit).

     "open -b com.apple.TextEdit '/Volumes/Macintosh HD/foo.txt'" opens the document in the application
     specified (in this case, TextEdit).

     "open -e '/Volumes/Macintosh HD/foo.txt'" opens the document in TextEdit.

     "ls | open -f" writes the output of the 'ls' command to a file in /tmp and opens the file in the
     default text editor (as determined by LaunchServices).

     "open http://www.apple.com/" opens the URL in the default browser.

     "open 'file://localhost/Volumes/Macintosh HD/foo.txt'" opens the document in the default application
     for its type (as determined by LaunchServices).

     "open 'file://localhost/Volumes/Macintosh HD/Applications/'" opens that directory in the Finder.

     "open -h NSView" lists headers whose names contain NSView and allows you to choose which ones to open.

     "open -a Xcode -h NSString.h" quickly opens /System/Library/Frameworks/Foundation.framework/Head-ers/NSString.h /System/Library/Frameworks/Foundation.framework/Headers/NSString.h
     ers/NSString.h in Xcode.

HISTORY
     First appeared in NextStep.