How to Use the macOS open Command to Launch Applications from the Terminal

When working deeply within the macOS terminal, transitioning between the command-line interface and the graphical Finder can break your workflow. If you are navigating a complex directory structure in the terminal and suddenly need to open a PDF in Preview, view an image, or launch a specific application, you do not need to grab the mouse and dig through the Applications folder. Instead, you can bridge the gap between the terminal and the graphical OS using the powerful macOS open command.

Why Use the open Command?

The open command acts exactly as if you double-clicked an item in the graphical Finder. It reads the file extension and automatically launches the file using the default associated application. Furthermore, it can be used to launch applications themselves, open specific URLs in your default browser, or reveal hidden terminal directories directly inside a graphical Finder window. It is an essential tool for maintaining momentum when switching between command-line operations and visual tasks.

Step 1: Open Files with Default Applications

The most basic usage is opening a file.

  1. Open the macOS Terminal.
  2. Navigate to the folder containing your file.
  3. Type open followed by the filename:
open budget_report.pdf

macOS will instantly launch the Preview application (or Adobe Acrobat, if you changed the default) and load the document, exactly as if you had double-clicked it.

Step 2: Force a File to Open in a Specific Application

Sometimes you do not want to use the default app. For example, you may want to open an HTML file in a text editor rather than in a web browser.

  1. Use the -a (application) flag to specify the exact app to use:
open -a \"TextEdit\" index.html

This forces the file to open inside TextEdit, allowing you to edit the code rather than view the rendered page.

Step 3: Open the Current Terminal Directory in the Finder

If you are deep in a hidden system directory (e.g., /usr/local/bin/) and need to manipulate the files visually, navigating there via the graphical Finder is tedious. The open command can instantly launch a Finder window set to your exact terminal location.

  1. Type the following command (a single period represents the current directory):
open .

A new Finder window will immediately pop up, displaying the contents of your current terminal working directory.

Step 4: Launch Applications and URLs

The open command is not restricted to local files.

  1. To launch a graphical application without clicking its icon in the Dock or Launchpad, use the -a flag without a target file:
open -a \"Google Chrome\"
  1. To instantly open a specific website in your default web browser, simply pass the URL:
open https://digitash.com

By integrating the open command into your daily habits, you can seamlessly blend the speed of the macOS terminal with the visual convenience of the graphical operating system.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.