Open any folder from the Terminal app in a Finder on macOS

Published on Jul 21, 2022

2 min read

TOOLS

Often, I struggle or want to open the current directory I am working from the Terminal app to the Finder window on macOS.

I have been a macOS user for almost eight years now, and it never occurred to me that I couldn't open the current location from the Terminal app. Until recently, a frustration point led me to find the solution. Again, though, I am surprised by its simplicity.

To open the current working directory in the Finder window, use the following command:

open .

The open command opens a file or a folder. It exists on the macOS.

You can do more with this command. The / argument opens the root directory.

open /

A specific directory is also allowed:

open ~/Desktop

Using the option R, you can locate a specific file or folder in the Finder:

open -R /blog

Opening files

🔗

There are more things that the open command can do. It can open files. For example, to open a markdown file in the default editor or IDE:

open ./blog/mm-yy/your-file-name.md

The above command opens the markdown file in the Xcode. You can pass the -t option to open in the file in a text editor.

open -t ./blog/mm-yy/your-file-name.md

Opening URLs

🔗

It can do more than open files and folders. It can also open a URL in the default web browser set up on your machine:

open https://www.google.com

Use the option a to override the default web browser and specify a different one.

open -a Safari https://www.google.com

It also be used with other flags to override a browser's default behavior. For example, I recently learned that when testing locally, the CORS can be bypassed to fetch files from the localhost.

open -a "Google Chrome Canary" --args --user-data-dir="/tmp/chrome_dev_test" --disable-web-security

More Posts

Browse all posts

Aman Mittal author

I'm a software developer and a technical writer. In this blog, I write about Technical writing, Node.js, React Native and Expo.

Currently, working at Expo. Previously, I've worked as a Developer Advocate, and Senior Content Developer with companies like Draftbit, Vercel and Crowdbotics.


Copyright ©  2019-2022 Aman Mittal · All Rights Reserved.