Today I Learned - How to open a directory in Finder from terminal in macOS
Sometimes it's useful to open a Finder window from a terminal, especially when you want to do more graphical things like previewing photos etc., which are not that handy to do in the terminal itself.
In Linux distros, it's usually really simple. You will just type the file manager's command in the terminal, followed by a path you want to browse, for example, nautilus my/path/
in case of the Gnome desktop environment.
I've looked for something similar in macOS, but we don't have a finder
command there. Fortunately, there is another command we can use, it's called open
. Easy to remember!
Opening selected directory
To open the current directory in Finder use:
open .
To open another directory, just provide it's path:
open Pictures/
Opening files from the terminal using the open
command
In addition to opening directories, the open
command allows us to also open files. You can type:
open Pictures/some-image.jpg
to open some-image.jpg
using the default software selected for this extension. In my case, it's macOS Preview
app.