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

常见问题