Open Terminal at a folder on a Mac
· 5 min read
macOS includes a service called New Terminal at Folder that opens a shell already sitting in the folder you right-clicked. It is switched off by default, which is why most people have never seen it. Turn it on in System Settings, Keyboard, Keyboard Shortcuts, Services, under Files and Folders.
If you would rather not change a setting, dragging a folder onto the Terminal icon in the Dock does the same thing, and typing cd then dragging the folder into an open Terminal window works everywhere.
Turn on the built-in Finder service
- Open System Settings, then Keyboard.
- Click Keyboard Shortcuts (a button, part way down the pane).
- Choose Services in the sidebar.
- Expand Files and Folders.
- Tick New Terminal at Folder and New Terminal Tab at Folder.
Now right-click any folder in Finder and look under Services at the bottom of the menu. New Terminal at Folder opens a fresh window with that folder as the working directory. New Terminal Tab at Folder adds a tab to the Terminal window you already have open, which is usually what you want after the first one.
If the window you are looking at is already the folder you mean, right-click its icon in the title bar (the proxy icon next to the window name) and the same Services menu appears.
The shell you get is your normal login shell, zsh on any current macOS, with your usual profile loaded. It is not a special environment.
Give it a keyboard shortcut
While you are in that Services list, the second half of the trick: click to the right of New Terminal at Folder where it says none, then press the combination you want.
Something like Ctrl-Option-T is safe because few applications claim it. Then the sequence becomes select a folder, press the keys, type. No menus at all.
Keep the shortcut away from Cmd combinations that Finder already uses, and test it in two or three applications before you rely on it. Services shortcuts are global, so a badly chosen one will surprise you inside a text editor.
Three ways that need no setup
Drag the folder onto Terminal’s icon. Terminal in the Dock, or Terminal.app in the Applications, Utilities folder. Dropping a folder on it opens a new window at that folder. This works on a Mac you have just sat down at and changed nothing on.
Type cd and drag the folder into the Terminal window. Terminal inserts the path, correctly escaped for spaces, at the cursor. Mind the space after cd before you drag. Press Return.
Copy the path. Right-click a folder in Finder, then hold Option: the Copy item changes to Copy “Name” as Pathname. Cmd-Option-C does it without the menu. Then in Terminal type cd ", paste, type " and press Return. The quotes matter, because a copied path is not escaped and folder names on a Mac are full of spaces.
That last one earns its keep for the folders whose real paths nobody types by hand. An iCloud Drive folder lives under ~/Library/Mobile Documents/com~apple~CloudDocs/, and copying the path is much faster than reconstructing it.
Put a button in the Finder toolbar
If you do this many times a day, a permanent target beats any menu.
- Open the Applications, Utilities folder in one window and any folder in another.
- Hold Cmd and drag Terminal.app onto the toolbar of the second window, into the empty space to the right of the existing buttons.
- Release. A Terminal icon stays there in every Finder window.
Now drag any folder onto that icon and Terminal opens at it. You can drop a file too, which opens Terminal at the file’s enclosing folder rather than at the file.
The same Cmd-drag removes it later, or Cmd-drag it off the toolbar and it disappears.
Going the other way, from Terminal to Finder
The reverse trip is one command, and it is the one people forget exists.
open .
That opens the current directory in a Finder window. To reveal a specific file with it already selected:
open -R report.pdf
And open with no flags on a file hands it to whichever application owns that type, exactly as double-clicking would. open -a Preview scan.pdf forces a particular one.
Between open . in one direction and a dragged folder in the other, you can stop thinking about which window you are in.
When the folder is a search result
The awkward case is the one where you do not know where the folder is yet. You search for a file, find it, and now you want a shell in the folder that contains it. The usual route is reveal in Finder, then right-click, then Services, which is three moves.
Finder search results shorten it a little: select a result and press Cmd-R to jump to its enclosing folder, then use the service. Finder search tips that actually narrow things down covers getting to a single result quickly.
A search app can collapse it further. In Everywhere, Cmd-T on a highlighted result opens Terminal at that file’s folder directly from the search window, alongside Cmd-Return to reveal in Finder and Cmd-C to copy the full path. If your day involves finding a project folder and then working in it from the command line, that is the shape of the shortcut worth having.
For previewing what you found before you commit to opening a shell there, Quick Look from the keyboard covers the space bar.
Questions
Why is New Terminal at Folder missing from my Services menu? Almost always because it has not been ticked in System Settings, Keyboard, Keyboard Shortcuts, Services. Services also hide themselves when the selection is the wrong type, so make sure you have right-clicked a folder rather than a file.
Does this work with a different terminal application? The built-in service is specifically for Terminal. Other terminal applications generally install their own Finder integration or their own service; check that application’s settings rather than the macOS one.
Can I open Terminal at a folder on an external drive?
Yes. External volumes are mounted under /Volumes, so a folder on a drive named Archive is /Volumes/Archive/..., and every method here works on it. The drive has to be plugged in, which is the one thing a path cannot fake.
What is the difference between the tab version and the window version? Only where the shell appears. New Terminal Tab at Folder reuses the frontmost Terminal window and adds a tab; if no Terminal window is open, it opens one. Tabs are easier to keep track of when several folders are in play at once.