TASIOMIND.DEV — OPERATIONAL▸▸▸FULL STACK DEVELOPER @ GWQ SERVICEPLUS AG▸▸▸FOUNDER — K8SGPT.AI▸▸▸OPEN SOURCE: ACTIVE▸▸▸DISTRIBUTED SYSTEMS / KUBERNETES / AI▸▸▸RUST + GO + PYTHON▸▸▸FIELD TESTED / STATUS — NOMINAL▸▸▸LOCATION: EUROPE/BERLIN▸▸▸TASIOMIND.DEV — OPERATIONAL▸▸▸FULL STACK DEVELOPER @ GWQ SERVICEPLUS AG▸▸▸FOUNDER — K8SGPT.AI▸▸▸OPEN SOURCE: ACTIVE▸▸▸DISTRIBUTED SYSTEMS / KUBERNETES / AI▸▸▸RUST + GO + PYTHON▸▸▸FIELD TESTED / STATUS — NOMINAL▸▸▸LOCATION: EUROPE/BERLIN▸▸▸

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

July 21, 2022

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:

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

code
open /

A specific directory is also allowed:

code
open ~/Desktop

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

code
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:

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

code
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:

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

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