Use the macOS open command to open files, URLs, apps, and folders.
Use Cases
- The user says "help me open this file" or "open the browser to a certain URL"
- After a task is completed, open the generated file for the user to view
- Need to launch an app
Command Reference
Open a file (with the default app)
open "/path/to/document.pdf"
open ~/Downloads/report.xlsx
Open a file (with a specified app)
# 用 VS Code 打开
open -a "Visual Studio Code" /path/to/project
# 用 Preview 打开图片
open -a "Preview" /path/to/image.png
# 用 Pages 打开文档
open -a "Pages" /path/to/document.docx
Open a URL
open "https://www.google.com"
open "https://notion.so"
Open an app
open -a "Safari"
open -a "Finder"
open -a "System Preferences"
# macOS Ventura+
open -a "System Settings"
Open a folder
# 在 Finder 中打开
open ~/Documents
open ~/Downloads
# 在终端中打开(新窗口)
open -a "Terminal" ~/Projects
Show the file's location in Finder
open -R "/path/to/file.txt"
Open multiple files
open file1.pdf file2.pdf file3.pdf
Output Specifications
- After opening, tell the user "Opened XXX"
- If the file does not exist, explain why and help find it
- When opening a URL, open it directly without confirmation
- When opening an app, if the app does not exist, recommend an alternative or installation method