The macOS open command hands a file, folder, or URL to whatever app the system would use if you double-clicked it. The whole point is that it bridges the Terminal and the GUI: you stay in the shell, but the thing you are opening lands in the right Mac app. The shortest useful version:
open report.pdfThat opens report.pdf in your default PDF app (usually Preview), exactly as a double-click in Finder would. No flags, no app name, no path gymnastics. The rest of this page is the variations I actually reach for: a specific app, the current folder, a URL in a chosen browser, and the one zsh gotcha that silently breaks URLs. It ends with the reverse bridge, from Finder back to the shell: a right-click Quick Action that runs your own script on the files you select.
Open a file in its default app
Pass open a path and it asks LaunchServices which app owns that file type, then launches it:
open notes.md # opens in your default Markdown/text app
open photo.heic # opens in Preview (or whatever you set)
open archive.zip # hands it to Archive Utility, which unzips itThis is the everyday case. The file extension drives the choice, so the same open data.csv lands in Numbers on one Mac and in Excel on another, depending on what each machine has set as the default for that type.
Open the current folder in Finder
open . opens the current working directory in a Finder window. This is the one I use most:
open . # current directory in Finder
open ~/Downloads # any folder
open .. # parent directoryIt is the fastest way to jump from a deep terminal path into a Finder window without re-navigating by hand. A bare open with a directory argument opens that directory; open . is just the special case for "right here."
Open with a specific app: open -a
To force a particular app instead of the default, use -a with the app name. The name is case-insensitive and you do not include .app:
open -a "Visual Studio Code" server.js
open -a Preview diagram.png
open -a "Sublime Text" .If the app name has a space, quote it. open -a "Google Chrome" works, open -a Google Chrome tries to open an app called Google and then a file called Chrome. When the named app is not installed, open fails with Unable to find application named '...', which is the usual sign of a typo or a wrong name (it is "Visual Studio Code", not "VS Code").
There is also -b, which targets an app by its bundle identifier rather than its display name. That is steadier in scripts because a bundle ID does not change when Apple renames an app:
open -b com.apple.TextEdit notes.txtOpen a file in TextEdit or the default editor
Two shortcuts skip the app-name dance for editing plain text. -e always uses TextEdit; -t uses whatever app is registered as the default editor for that file type:
open -e config.txt # always TextEdit
open -t config.txt # default text editor (could be BBEdit, VS Code, etc.)I reach for -e when I want a quick, no-surprises text window and do not care what my default editor happens to be set to.
Open a URL in the default browser
Give open an http or https URL and it opens in your default browser:
open https://techearl.comThis is handy at the end of a script ("build done, open the local preview") or just to fling a link from the terminal into a browser tab.
Open a URL in a specific (non-default) browser
This is the combination people search for and miss: -a plus a URL opens that URL in the named browser, regardless of which browser is your system default.
open -a "Safari" https://techearl.com
open -a "Firefox" https://techearl.com
open -a "Google Chrome" https://techearl.comSo if Safari is your default but you want to check a page in Firefox, open -a Firefox <url> does it without changing any settings. To pass command-line flags through to the browser itself, use --args (everything after it goes to the app, not to open). For example, telling Chrome to make itself the default browser:
open -a "Google Chrome" --args --make-default-browserThere is no general "set default browser from the command line" command on macOS; that Chrome-specific flag is the closest thing, and it only works because Chrome itself understands --make-default-browser. On recent macOS it does not flip the default silently either: it triggers the system "Use Chrome as your default browser?" confirmation dialog, which you still have to approve by hand.
The zsh quoting gotcha (quote your URLs)
This one bites people on every modern Mac. Since Catalina, the default shell is zsh, and zsh treats ?, &, and # as special characters. An unquoted URL with a query string gets mangled before open ever sees it:
open https://example.com/search?q=mac&page=2 # zsh breaks this
open 'https://example.com/search?q=mac&page=2' # quote it, worksWithout quotes, zsh tries to glob the ? and treats & as "run in background," so you get a no matches found error or a half-eaten URL. Always single-quote a URL that contains ?, &, or #. It is a good habit even in bash; in zsh it is mandatory.
Reveal a file in Finder instead of opening it
-R selects and highlights a file in a Finder window rather than opening it. Useful when you want to see a file in context, not launch it:
open -R ~/Projects/site/dist/index.htmlThe Finder window opens at the enclosing folder with the file selected, ready to drag, rename, or look at alongside its neighbors.
Other flags worth knowing
A few more from the open(1) man page that earn their keep:
open -n -a Safari # force a NEW instance even if Safari is running
open -g -a Music song.m4a # open in the background, do not steal focus
open -W -a Preview scan.pdf # wait until that app quits before the shell continues-n matters when you genuinely want a second copy of an app running. -g is nice in scripts that should not yank you out of the terminal. -W (wait) lets you script "open this, and do the next step only after I close it." You can also pass several files at once: open *.png opens every PNG in the folder in the default image app.
Add a right-click Quick Action to Finder
open takes you from the shell into a Mac app. The reverse bridge is a Quick Action: a custom entry in Finder's right-click menu that runs a shell script on whatever files you select. You build it in Automator: choose New Document > Quick Action, set it to receive files or folders in Finder, add a Run Shell Script action, switch its input to as arguments, write a loop over "$@", and save it. It then appears in Finder's right-click Quick Actions submenu.
If you searched for how to add a "Service" to the Finder menu, that is the same feature. Apple renamed Services to Quick Actions in macOS Mojave (10.14, 2018). The Automator document type is still labelled "Quick Action," and the result still saves into ~/Library/Services, so old "create a Finder Service" tutorials work; only the name changed.
Build it in Automator
- Open Automator (it ships with macOS, in
/Applications). - File > New, pick Quick Action, click Choose.
- At the top of the workflow area, set Workflow receives current to files or folders, and in to Finder.app. This is what makes the action show up on a right-click in Finder and hands it the selected items.
- In the left-hand library, find Run Shell Script (it is under Utilities) and drag it onto the canvas.
- In the Run Shell Script action, set Shell to
/bin/bash(or/bin/zsh) and, critically, set Pass input to as arguments. - Replace the default script with your own (the example below).
- File > Save, give it a name like "Convert to PNG." That name is exactly what shows up in the right-click menu.
Pass input: as arguments is the part people get wrong. The other option, to stdin, dumps every selected path into the script's standard input as one newline-separated blob, which you then have to read and split by hand. "As arguments" hands each selected file to your script as a normal positional argument, so you can loop over them the way you would in any shell script.
With input passed as arguments, the selected files arrive in "$@". Always loop over them. Finder lets the user select more than one file, and a Quick Action that only handles $1 quietly ignores everything after the first item:
for f in "$@"; do
# "$f" is one selected file's full path
echo "$f"
doneQuote "$f" and "$@". Mac filenames are full of spaces ("Screen Shot 2026-06-01 at 9.00.00 AM.png" is a real default), and an unquoted loop variable splits that into five broken arguments. This is the single most common reason a Quick Action works on your test file and breaks on a real one.
Example: convert selected images to PNG
This complete action converts every selected image to PNG with ImageMagick's magick tool, writing the result next to the original. Install the tool first with brew install imagemagick, then drop this into the Run Shell Script box:
# Full path to the brew-installed binary, not a bare `magick`.
MAGICK="/opt/homebrew/bin/magick" # Apple Silicon
# MAGICK="/usr/local/bin/magick" # Intel Mac
for f in "$@"; do
out="${f%.*}.png"
"$MAGICK" "$f" "$out"
doneAnd because open accepts several files at once, a Quick Action that opens the selection in a specific app is a one-liner built from the -a flag above: open -a Preview "$@".
Why a Quick Action silently does nothing (PATH)
The number-one reason a Quick Action runs and produces no result is PATH. The shell that Automator spawns does not load your .zshrc or .bash_profile, so it does not inherit the PATH you see in Terminal. It runs with a minimal, sanitized environment, typically only /usr/bin:/bin:/usr/sbin:/sbin. Anything you installed with Homebrew is not on that PATH.
So a script that calls a bare magick, ffmpeg, unrar, pngquant, or python3 works perfectly when you paste it into Terminal, then does nothing as a Quick Action, with no visible error, because the binary cannot be found. Call the tool by its full path:
- Apple Silicon (M1 and later): Homebrew installs to
/opt/homebrew/bin, so the binary is/opt/homebrew/bin/magick. - Intel Macs: Homebrew installs to
/usr/local/bin, so it is/usr/local/bin/magick.
Run which magick (or brew --prefix) in Terminal once to confirm the path on your machine, then hardcode it. To make the script work on both architectures without editing, prepend both directories to PATH at the top instead:
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"Manage, disable, or remove Quick Actions
A saved Quick Action is just a .workflow bundle in ~/Library/Services. Delete the file there to remove the action, rename it to rename the menu item, or copy it to another Mac's ~/Library/Services to share it.
To turn actions on and off without deleting them, open System Settings > General > Login Items & Extensions, scroll to the Finder entry, and click the i (info) button next to it. That panel lists every Quick Action; tick or untick each one to show or hide it in the right-click menu, and drag to reorder. Apple moved this in macOS Sequoia (15): on Ventura and Sonoma the same list is under System Settings > Privacy & Security > Extensions > Finder, and on macOS before Ventura it was System Preferences > Extensions > Finder. The list and the toggles are identical at every version; only the location of the panel changed.
Quick Actions also appear in the Finder preview pane (turn it on with View > Show Preview, then Show Quick Actions at the bottom). Single-file actions like Rotate and Markup show up there as buttons, alongside any custom ones you add.
The Shortcuts app alternative
Automator still works and is the right tool for a "run this shell script on these files" action. But Apple's newer Shortcuts app (built into macOS since Monterey, 2021) is where Apple is putting its effort, and it can also produce Finder Quick Actions. Build a shortcut, double-click it to open it, click Details in the right-hand inspector, and tick Use as Quick Action, then Finder. Shortcuts has a Run Shell Script action too (with the same PATH caveat), it syncs across your devices via iCloud, and it is far easier to edit later. For a brand-new action today, I reach for Shortcuts; for the existing .workflow files people already have, Automator is still fully supported.
Linux and Windows equivalents
open is macOS only. On Linux the equivalent is xdg-open file-or-url (from xdg-utils), which hands the target to your desktop environment's default handler. On Windows the rough equivalent is start file-or-url in cmd (note start opens a URL or document with the registered handler). If you write cross-platform scripts, those are the two names to branch on.
FAQ
Use -a with the app name: open -a "Visual Studio Code" file.js. The name is case-insensitive and you leave off the .app extension. Quote any name that contains a space.
The app name does not match an installed app. Check spelling and use the real display name (it is "Visual Studio Code", not "VS Code"). For more stability in scripts, target the app by bundle identifier with -b, for example open -b com.apple.TextEdit notes.txt.
Combine -a with the URL: open -a "Firefox" https://example.com. That opens the page in the named browser without changing your system default. Single-quote the URL if it contains ?, &, or #.
You are almost certainly on zsh (the default shell since Catalina), which treats ?, &, and # as special. Wrap the URL in single quotes: open 'https://example.com/search?q=mac&page=2'.
-e always opens the file in TextEdit. -t opens it in whatever app is registered as the default editor for that file type, which might be BBEdit, VS Code, or something else.
Linux uses xdg-open file-or-url (from xdg-utils) and Windows uses start file-or-url in cmd. Both hand the target to the system's default handler, the same idea as macOS open.
Almost always a PATH problem. Automator runs the script with a minimal environment that does not include Homebrew's directory, so a bare magick or ffmpeg is "not found" and fails silently. Call the binary by its full path: /opt/homebrew/bin/... on Apple Silicon, /usr/local/bin/... on Intel.
Apple renamed Services to Quick Actions in macOS Mojave (10.14, 2018). It is the same feature, the same Automator workflow type, and the same ~/Library/Services location. Older tutorials that say "create a Service" still apply.
On macOS Sequoia (15) and later, open System Settings, go to General, click Login Items and Extensions, find the Finder entry, click its info button, and untick the action. On Ventura and Sonoma the same list is under Privacy and Security, Extensions, Finder. On macOS before Ventura it is under System Preferences, Extensions, Finder.
See also
- Copy to the clipboard from the command line with pbcopy and pbpaste: the other macOS-only Terminal-to-GUI bridge, with the Linux and Windows equivalents.
- Set the date and time from the macOS command line: the BSD vs GNU divergence that trips up Mac sysadmins, in the same vein as the zsh quoting gotcha here.
- Get a saved Wi-Fi password from the Mac Terminal: another built-in macOS command that does a job people reach for a third-party tool to do.
- View your calendar from the macOS command line:
calandicalBuddyfor checking dates and your actual events without leaving the shell. - Convert an image to grayscale from the command line: the kind of one-line conversion that makes a good right-click Quick Action.
Sources
Authoritative references this article was fact-checked against.
- open command reference (ss64, mirrors the open(1) man page)ss64.com
- The macOS open command (Scripting OS X)scriptingosx.com
- open(1): macOS manual pageunix.com
- Perform quick actions in the Finder on Mac (Apple Support)support.apple.com
- Automator User Guide (Apple Support)support.apple.com
- Shortcuts User Guide for Mac (Apple Support)support.apple.com
- Change Login Items & Extensions settings on Mac (Apple Support)support.apple.com
- Run a shortcut while working on your Mac (Apple Support)support.apple.com




![Set the Date and Time From the macOS Command Line (BSD date) Set the macOS clock from Terminal with the BSD date command: MMDDhhmm[[CC]YY], not date -I (an ISO 8601 output flag that sets nothing). Turn off network time first or macOS resyncs.](https://images.techearl.com/mac-set-date-command-line/mac-set-date-command-line-1536.webp?v=2026-11-25T10%3A00%3A00-05%3A00)
