Cursor 提供命令行工具,让您可以从终端打开文件和文件夹。安装 cursorcode 命令,将 Cursor 集成到您的开发工作流程中。

安装 CLI 命令

通过命令面板安装 CLI 命令:
  1. 打开命令面板 (Cmd/Ctrl + P)
  2. 输入 “Install” 来筛选安装命令
  3. 选择并运行 Install 'cursor' to shell
  4. 重复操作并选择 Install 'code' to shell

使用 CLI 命令

安装完成后,使用以下任一命令在 Cursor 中打开文件或文件夹:
# 使用 cursor 命令
cursor path/to/file.js
cursor path/to/folder/

# 使用 code 命令(与 VS Code 兼容)
code path/to/file.js
code path/to/folder/

命令选项

两个命令都支持以下选项:
  • 打开文件:cursor file.js
  • 打开文件夹:cursor ./my-project
  • 打开多个项目:cursor file1.js file2.js folder1/
  • 在新窗口中打开:cursor -ncursor --new-window
  • 等待窗口关闭:cursor -wcursor --wait

常见问题