open — Open Files, Folders and Apps from the Terminal

macOS command to open files, folders, URLs and apps from the terminal with the default or a specified app – the bridge between terminal and Finder/GUI.

With open you launch files, folders, apps and URLs straight from the terminal – each through the default association that macOS would otherwise use on a double-click in Finder. The command is the bridge between terminal and GUI: you type a command and macOS opens the matching program, exactly as if you had clicked the item in Finder. Options like -a, -R and -b let you control which app launches and how it behaves. This guide walks you through the calls you reach for daily.

Open Files & Directories

open <file> — Open a file with its default application.

open document.pdf

open . — Open the current directory in Finder.

open .

open <directory> — Open a directory in Finder.

open ~/Downloads

open -R <file> — Reveal a file in Finder (highlight it).

open -R ~/Documents/report.pdf

open <file1> <file2> — Open multiple files.

open image1.png image2.png image3.png

Open with Specific App

open -a '<app>' <file> — Open a file with a specific application.

open -a 'Visual Studio Code' project/

open -a '<app>' — Launch an application.

open -a 'Safari'

open -e <file> — Open a file in TextEdit.

open -e notes.txt

open -t <file> — Open a file in the default text editor.

open -t config.yaml

open -b <bundle-id> <file> — Open with an app specified by bundle identifier.

open -b com.microsoft.VSCode .

Open URLs

open <url> — Open a URL in the default browser.

open https://example.com

open -a '<browser>' <url> — Open a URL in a specific browser.

open -a 'Firefox' https://example.com

open mailto:<email> — Compose an email in the default mail app.

open mailto:user@example.com

open 'x-apple.systempreferences:<pane>' — Open a specific System Settings pane.

open 'x-apple.systempreferences:com.apple.Network-Settings.extension'

Options

open -n -a '<app>' — Open a new instance of an application.

open -n -a 'Safari'

open -g <file> — Open without bringing the app to the foreground.

open -g document.pdf

open -W <file> — Wait for the application to close before returning.

open -W document.txt

open -F -a '<app>' — Open app fresh (don't restore windows).

open -F -a 'Safari'

Conclusion

open is the small connective tissue that joins terminal workflows with the macOS graphical interface: open . jumps from the current directory straight into Finder, open -R highlights a file there, and open -a launches any app you like – ideal in scripts and aliases. Because open understands schemes like https:, mailto: and x-apple.systempreferences:, you can drive browsers, mail and System Settings from a single line as well. The command exists only on macOS – on Linux its counterpart is xdg-open, on Windows start.

Further Reading

  • caffeinate – prevent the Mac from going to sleep
  • defaults – read and write macOS user preferences
  • diskutil – manage disks, partitions and volumes