Open Terminal in a Folder on Mac: 5 Ways
Nemo · · 4 min read
One reliable way to open Terminal in a folder on a Mac is to Control-click the folder in Finder and choose Services › New Terminal at Folder. If you don’t see it, turn it on in System Settings. You can also drag the folder onto Terminal’s icon in the Dock, or type cd in Terminal and drop the folder into the window. Here are all five ways, and how to go the other direction.
What are the ways to open Terminal in a folder?
| Way | How | Needs setup |
|---|---|---|
| New Terminal at Folder | Control-click a folder › Services › New Terminal at Folder | Turn on once |
| Drag to the Dock | Drop the folder on Terminal’s Dock icon | No |
cd and drop |
Type cd , drag the folder into the Terminal window, press Return |
No |
| Copy the path | Option+Cmd+C copies the folder’s path in Finder; paste it after cd |
No |
open -a Terminal |
open -a Terminal ~/code/site from any shell or script |
No |
How do you turn on New Terminal at Folder?
- Open System Settings › Keyboard › Keyboard Shortcuts.
- Choose Services, then the Files and Folders group.
- Tick New Terminal at Folder (and New Terminal Tab at Folder if you prefer tabs).
From then on, Control-click any folder in Finder and the command is in the Services submenu. You can give it a keyboard shortcut in the same pane.
How does the drag and drop trick work?
Terminal turns a dropped file or folder into its full path, with spaces escaped. So cd (with a space), then a drag from Finder, then Return takes you there. It works with any folder you can see, including ones on external drives, so you never type a long path by hand. It is also handy for commands that take a path: type open -a Preview and drop an image.
Which way should you use?
If you open folders from Finder all day, set up the service once and give it a shortcut. If you mostly work in the terminal already, cd and a drop is quicker, because the window is already there. Scripts and aliases should use open -a Terminal with a path.
How do you open the current folder in Finder?
Going back is one command: open . opens the current folder in a Finder window. open .. opens the parent. To reveal a file, open -R file.txt selects it in Finder.
How do you get the path of a Finder folder?
Select it and press Option+Cmd+C to copy its path, or turn on the path bar with Option+Cmd+P. Our Mac terminal commands guide covers cd, ls and pwd if you are new to the shell, and how to open Terminal on a Mac covers getting there in the first place.
How does Monok open a terminal in a folder?
Monok is a small Mac browser with a native terminal built in. A terminal is a pane, so it opens next to the page you are working on instead of in another window.
- File › Open Folder in Terminal (Shift+Cmd+O) asks for a folder and starts a terminal pane there.
- Ctrl+` splits a terminal pane in below the page, running your own login shell with your rc files.
>commandin an empty pane’s Magic Bar turns that pane into a terminal running the command, once you press Return.
All three ship today. What it doesn’t have is a Services entry: it doesn’t add itself to Finder’s Control-click menu, so from Finder, the tricks above still apply. Since version 0.1.1, the Files pane puts a file manager in the same window. Type / in the Magic Bar to open it at your home folder, /~/path to complete a path, and split it next to a terminal with Cmd+D. Like the terminal, it is native only; no web page or JavaScript can reach either one. Read more in a browser with a built-in terminal.
Download Monok from the download page and the next folder you open in a terminal sits next to the page you are working on.
FAQ
Why don’t I see New Terminal at Folder?
It may be turned off. Turn it on in System Settings › Keyboard › Keyboard Shortcuts › Services › Files and Folders.
How do I check which folder I am in?
Run pwd in the terminal. It prints the full path of the current folder.
Can I open iTerm2 in a folder the same way?
The cd and drop trick works the same there, and iTerm2’s profiles can set the folder a new window starts in. See iTerm2 vs Terminal for how the two compare.
How do I open a terminal in the folder of the current Finder window?
Press Cmd+Up to select it in its enclosing folder, then Control-click it and use Services › New Terminal at Folder. Or drag the folder’s icon from the window’s title bar onto Terminal in the Dock.