Launching Apps and Files with Open on macOS Tahoe
The open command is one of the most useful tools in the macOS terminal. It bridges the gap between the command line and the graphical user interface (GUI), effectively simulating a double-click on a file, folder, or application.
Basic Usage
To open a file using its default application (just like double-clicking it in Finder):
open filename.txt
To open the current directory in a Finder window:
open .
Opening Applications
You can launch any installed application by name using the -a flag.
open -a "Google Chrome"
You can also use this to open a specific file with a specific application, overriding the default.
open -a "Visual Studio Code" index.html
Opening URLs
If you pass a URL to the open command, it will launch in your default web browser.
open https://www.apple.com
Revealing Files in Finder
Sometimes you don't want to open a file, but just want to see where it is located. The -R flag reveals the file in a Finder window.
open -R /Library/Preferences/com.apple.dock.plist
Piping Output to a Text Editor
The -f flag reads input from standard input and opens it in the default text editor. This is great for viewing the output of long commands.
ls -la | open -f
For more on general terminal usage, refer to Getting Started with macOS Tahoe.