Open a file with a chosen app using open -a

open -a overrides the default application association for a single launch, letting you route a file to any installed app by name without changing the file's default handler.

macOSopenapplicationsLow risk
Run `open -a "Visual Studio Code" main.py` to open the file in VS Code regardless of what .py files are associated with.

01Command

Command
$ open -a "Visual Studio Code" main.py
open -a TextEdit readme.md

02What it does

The -a argument accepts an app's display name or, with -b, its bundle identifier, and macOS resolves it against installed applications. The flag also works alone: `open -a "Google Chrome"` just launches the app, and passing multiple files opens them all in the target app.

03Risk

RiskLow risk
!Warning: App names must match the installed app's display name (or use -b with a bundle ID) or open fails with 'Unable to find application'.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-17 · Category: Files & Folders