# 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.

Source: https://www.jpkc.com/db/en/cheatsheets/macos/open/

<!-- PROSE:intro -->
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.
<!-- PROSE:intro:end -->

## Open Files & Directories

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

```bash
open document.pdf
```

`open .` — Open the current directory in Finder.

```bash
open .
```

`open <directory>` — Open a directory in Finder.

```bash
open ~/Downloads
```

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

```bash
open -R ~/Documents/report.pdf
```

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

```bash
open image1.png image2.png image3.png
```

## Open with Specific App

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

```bash
open -a 'Visual Studio Code' project/
```

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

```bash
open -a 'Safari'
```

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

```bash
open -e notes.txt
```

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

```bash
open -t config.yaml
```

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

```bash
open -b com.microsoft.VSCode .
```

## Open URLs

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

```bash
open https://example.com
```

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

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

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

```bash
open mailto:user@example.com
```

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

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

## Options

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

```bash
open -n -a 'Safari'
```

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

```bash
open -g document.pdf
```

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

```bash
open -W document.txt
```

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

```bash
open -F -a 'Safari'
```

<!-- PROSE:outro -->
## 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

- [open – ss64.com](https://ss64.com/mac/open.html) – detailed reference of every option
- [open(1) – macOS Man Page](https://keith.github.io/xcode-man-pages/open.1.html) – official man page description
<!-- PROSE:outro:end -->

## Related Commands

- [caffeinate](https://www.jpkc.com/db/en/cheatsheets/macos/caffeinate/) – prevent the Mac from going to sleep
- [defaults](https://www.jpkc.com/db/en/cheatsheets/macos/defaults/) – read and write macOS user preferences
- [diskutil](https://www.jpkc.com/db/en/cheatsheets/macos/diskutil/) – manage disks, partitions and volumes

