Finder & Files

How to Open a Folder in Finder from Terminal on Mac (open .)

Published Nov 5, 2026
Tested on a real Mac. Ran open ., open with quoted and unquoted paths, open -R, open -g, open -a Finder, open -a Terminal, a symlink, a fake .app folder and open -W in a scratch folder on an M3 Mac (macOS 26.6.2, zsh 5.9); the osascript Finder-path command did not finish because it waited on the macOS Automation permission prompt, so its output is not shown. Test machine: MacBook Air (M3, 16 GB), macOS Tahoe 26.6.2, zsh 5.9.
On this page
  1. The open command, explained
  2. Open a specific folder (and why spaces break it)
  3. Reveal a file in Finder with open -R
  4. Folders that end in .app open as apps
  5. Useful flags: -g, -a Terminal and the -W trap
  6. Opening a folder writes a .DS_Store file
  7. Make a shortcut (optional)
  8. Common questions

To open the folder you are in right now in Finder, type this in Terminal:

open .

The dot means “the current directory”, and open hands it to Finder, which pops up a window for that folder. To open any other folder, give its path instead, like open ~/Downloads. To show a single file highlighted inside its folder, use open -R file.txt.

That covers most people. Below are the variations I tested on a MacBook Air M3 (macOS Tahoe 26.6.2, zsh 5.9), plus the gotchas with spaces, .app folders and a hidden file Finder quietly creates.

The open command, explained

open is a built-in macOS tool at /usr/bin/open. Nothing to install:

type open
open is /usr/bin/open

It works like double-clicking in Finder. A folder opens in Finder, a .txt file opens in TextEdit, a URL opens in your browser. If you came from Linux or Windows, this is the Mac version of xdg-open or explorer .. Those two do not exist on macOS:

xdg-open not found
explorer not found

When open succeeds, it prints nothing and exits with 0. That makes it safe to use in scripts.

Open a specific folder (and why spaces break it)

Give open a path, either relative to where you are or a full path:

open ~/Downloads
open "My Project"
open "My Project/src"

Spaces are the most common problem. Without quotes, the shell splits My Project into two words, and open looks for two separate items. This is the real error from my test:

open My Project
The files /private/var/folders/…/T/tom-tests/open-folder-in-finder-from-terminal/My and /private/var/folders/…/T/tom-tests/open-folder-in-finder-from-terminal/Project do not exist.

The exit code was 1. Fix it with quotes (open "My Project") or a backslash (open My\ Project). Pressing Tab after typing My lets zsh add the backslash for you.

The second trap is the tilde. ~ only turns into your home folder when it is outside quotes:

open "~/Desktop"     # wrong
open ~/Desktop       # right
open "$HOME/Desktop" # right, and safe with spaces

The quoted version fails with The file …/~/Desktop does not exist., because open received a literal folder named ~ inside the current directory.

A missing path gives the same kind of message and exit code 1:

The file /private/var/folders/…/nope does not exist.

Reveal a file in Finder with open -R

open somefile.txt opens the file in its app. If you want Finder to show where the file is, with the file selected, use -R (reveal):

open -R "My Project/notes.txt"

Finder opens My Project and highlights notes.txt. Exit code 0. This is handy after a command like find gives you a long path. (See how to find large files on Mac for a good source of those paths.)

You can also force Finder as the app with -a Finder. open -a Finder "My Project/notes.txt" returned 0 in my test, and Finder handled the file instead of TextEdit.

Folders that end in .app open as apps

This one surprised me. macOS treats any folder whose name ends in .app as an application bundle, even if it is just an empty folder you made. I created Fake.app/Contents in the scratch folder and ran:

open Fake.app
The application cannot be opened because its executable is missing.

Exit code 1. open tried to launch it as an app instead of showing the folder. To look inside any bundle (real apps too), use one of these. All three returned 0:

open -R Fake.app           # select it in its parent folder
open Fake.app/Contents     # open the inside as a normal folder
open -a Finder Fake.app    # tell Finder to handle it

For real apps, open /Applications/Safari.app/Contents is the quick way to browse inside.

Useful flags: -g, -a Terminal and the -W trap

A few more flags I checked:

CommandWhat it does
open -g .Opens the folder in Finder but keeps Terminal in front
open -a Terminal "My Project"The reverse: opens a new Terminal window in that folder
open ~/LibraryOpens the hidden Library folder directly
open linkFollows a symlink and opens the real folder

open -g . returned in 0.049 seconds without pulling Finder to the front. That is nice when you just want the window ready for later.

open ~/Library is the fastest way into that hidden folder. If you want hidden files visible in Finder too, see how to show hidden files on Mac.

Now the trap. -W means “wait until the app quits”. With a folder, the app is Finder, and Finder never quits. So this never returns:

open -W .   # hangs: Finder keeps running

In my test it sat there until I stopped it. Don’t use -W with folders in scripts.

Also note that open -h is not help. It means “search for header files”, and on my Mac it printed an Xcode warning before the usage text. To see the options, run man open instead.

Opening a folder writes a .DS_Store file

After I opened my scratch folder in Finder, a new file appeared in it:

ls -la
total 16
drwxr-xr-x@ 6 you  staff   192 Nov  5 10:04 .
drwxr-xr-x@ 6 you  staff   192 Nov  5 10:04 ..
-rw-r--r--@ 1 you  staff  6148 Nov  5 10:04 .DS_Store
drwxr-xr-x@ 3 you  staff    96 Nov  5 10:04 Fake.app
drwxr-xr-x@ 5 you  staff   160 Nov  5 10:04 My Project
lrwxr-xr-x@ 1 you  staff    10 Nov  5 10:04 link -> My Project

Before open ., the folder only had Fake.app, My Project and link. Finder writes .DS_Store to remember view settings. It is harmless, but if the folder is a Git repo, add .DS_Store to your .gitignore so it is never committed.

Make a shortcut (optional)

If you type this a lot, a tiny function opens the current folder by default or any path you give it:

f() { open "${1:-.}"; }

I tested it in a throwaway zsh -c session: f "My Project" opened the folder and returned 0. To keep it, you would add that line to ~/.zshrc and open a new Terminal tab. I did not edit my shell config while testing. For how ~/.zshrc works, see how to set an environment variable permanently on Mac.

Common questions

How do I open the current directory in Finder from Terminal?

Run open . from that directory. The dot is the current folder. If you are not sure where you are, run pwd first.

How do I go the other way, from Finder to Terminal?

In Finder, right-click a folder and choose Services → New Terminal at Folder (turn it on in System Settings → Keyboard → Keyboard Shortcuts → Services if you don’t see it). From Terminal, open -a Terminal "path" opens a new window already in that folder. You can also drag a folder from Finder onto the Terminal window to paste its path.

Can I get the folder of the front Finder window in Terminal?

Yes, with AppleScript:

osascript -e 'tell application "Finder" to get POSIX path of (target of front Finder window as alias)'

The first time, macOS asks whether Terminal may control Finder. In my run the command waited on that permission prompt and gave no output until I stopped it, so I can’t show its result here. If it hangs for you, look for the prompt or check System Settings → Privacy & Security → Automation.

Why does open say “does not exist” when the folder is right there?

Usually a space or a quoted ~. Put the path in double quotes and use $HOME instead of ~ inside the quotes. Pressing Tab to autocomplete the name also avoids typos.

Does open . work in iTerm2 or VS Code’s terminal?

It should. open is a normal program at /usr/bin/open, not a Terminal feature, so any terminal app on macOS can run it. I only tested it from the default zsh shell.