Skip to content

open command in MacOS

The MacOS open command is a useful tool for opening files, folders, and applications directly from the terminal. With open, you can quickly access documents, images, videos, and more without having to navigate through the Finder. This command provides a convenient way to streamline your workflow and access files with just a few keystrokes.

Terminal window
open [option] [parameter]
OptionDescription
-aOpens the specified application.
-eOpens the specified application for editing.
-tOpens the file(s) with the default text editor.
-RReveals the specified file(s) in the Finder.
-nOpens a new instance of the application even if one is already running.
-bOpens the specified application bundle identifier.
ParameterDescription
fileSpecifies the file to open.
directorySpecifies the directory to open.
applicationSpecifies the application to open.
bundle identifierSpecifies the bundle identifier of the application to open.
urlSpecifies the URL to open.
Terminal window
open file.txt

Opens the file.txt using its default application.

Open a specific file with a selected application

Section titled “Open a specific file with a selected application”
Terminal window
open -a "TextEdit" document.txt

Opens the document.txt file using TextEdit application.

Terminal window
open /Users/username/Documents/

Opens the Documents directory in the Finder.

Terminal window
open https://www.example.com

Opens the specified URL in the default web browser.

Terminal window
open file1.txt file2.txt file3.txt

Opens multiple files simultaneously using their default applications.

Terminal window
open -a "Visual Studio Code" script.js

Opens the script.js file in Visual Studio Code editor.

Open a file with a specific application and wait for it to close

Section titled “Open a file with a specific application and wait for it to close”
Terminal window
open -W -a "Preview" image.png

Opens the image.png file using Preview application and waits for the application to be closed before returning to the shell.

Open a file in the background without bringing the application to the foreground

Section titled “Open a file in the background without bringing the application to the foreground”
Terminal window
open -g -a "TextEdit" notes.txt

Opens the notes.txt file using TextEdit application in the background without focusing on it.

To use the open command in MacOS, execute the following command:

Terminal window
open filename.txt

How do I open a directory with open in bash?

Section titled “How do I open a directory with open in bash?”

To open a directory using the open command in bash, use the following syntax:

Terminal window
open foldername

How can I open a specific file using a non-default application in MacOS?

Section titled “How can I open a specific file using a non-default application in MacOS?”

To open a specific file using a non-default application in MacOS, use the -a flag followed by the application name like this:

Terminal window
open -a "TextEdit" filename.txt

How can I open multiple files simultaneously with open in MacOS?

Section titled “How can I open multiple files simultaneously with open in MacOS?”

To open multiple files simultaneously using the open command in MacOS, simply list the file names separated by spaces:

Terminal window
open file1.txt file2.txt

What options can I use with the open command in MacOS?

Section titled “What options can I use with the open command in MacOS?”

There are several options you can use with the open command in MacOS, such as:

  • -a to specify the application to use
  • --hide to open the file but not bring the application to the foreground
  • --reveal to open the file’s location in Finder

How do I open a URL using the open command in MacOS?

Section titled “How do I open a URL using the open command in MacOS?”

To open a URL using the open command in MacOS, simply pass the URL as an argument like this:

Terminal window
open https://www.example.com

How can I open a file with its default application in MacOS?

Section titled “How can I open a file with its default application in MacOS?”

To open a file with its default application in MacOS, you can simply use the open command followed by the file name:

Terminal window
open document.docx

Can I open a file in a new window of the default application using open in MacOS?

Section titled “Can I open a file in a new window of the default application using open in MacOS?”

Yes, you can open a file in a new window of the default application by using the -n flag like this:

Terminal window
open -n document.docx
  • Launching applications
  • Opening files
  • Opening URLs
  • Opening folders
  • Executing shell scripts