Things I Learned #8: Open and the Mac Terminal

1 minute read til learning   mac   terminal   finder Comments

I think in previous posts I've made it abundantly clear that I spend a lot of time in a terminal window. I do use the command line a lot, but whenever I've needed a graphical program, I've resorted to either using Alfred or clicking a shortcut in my Dock. Sometimes, as with MacVim, it may already be in my path, so I can just execute the program.

I've used a Mac since 2014. One of the first things I was told is that Finder is terrible and that it is really nothing like Windows Explorer. After many years of using a Mac, I can wholeheartedly agree, and rarely use Finder, although it does take a spot in my Dock for those times I want it.

For example, this morning I wanted to browse some images I use for this blog and the simplest way was to open Finder and change it to gallery view so I could click through them and see previews.

I'm not sure why, but it was at that point I realized that I have no idea how to open Finder from the command line. Well, today is the day I decided to find out.


I learned that you can open Finder from the command line using the open command.

Open? Really? It's that simple?

open .

Ahh, but guess what? That open command can do a lot more! It turns out it simply opens the default application for what you're trying to open SO that means if I'm trying to open a folder, it will open the default app for that, which will most likely be Finder.

open /
opens the root folder in Finder.

If I want to edit a text file with the default text editor, it would be

open -t foo.txt
If you use the -e switch, it'll open with TextEdit.

If you want to open Finder with a specific file selected, try

open -R foo.txt
By the way, if the file doesn't exist, you'll see a message telling you as much.

On my machine,

open image.jpg
opens the image in the Preview application.

Want to open a website in the default browser directly from the command line?

open "url"

There are many more options to the open command, so check out

open --help