用途:使用 cursor CLI 在命令行控制 Cursor(基于 VS Code 的 AI 代码编辑器),可打开文件与文件夹、定位行号、进行文件对比、管理扩展等,便于脚本化或与 git 等工具集成。
CLI 位置:/usr/local/bin/cursor
主要能力与用法: 打开当前目录:cursor . 打开指定文件:cursor /path/to/file.ts 定位到行:cursor /path/to/file.ts:42;定位到行列:cursor /path/to/file.ts:42:10 打开文件夹:cursor /path/to/project 一次打开多个文件:cursor file1.ts file2.ts file3.ts
窗口选项: 新窗口:cursor -n /path/to/project(别名 --new-window) 复用现有窗口:cursor -r /path/to/file(别名 --reuse-window)
对比模式: cursor -d file1.ts file2.ts(别名 --diff)
等待模式(适合脚本): cursor --wait /path/to/file,短写 cursor -w /path/to/file 作为 git 编辑器:git config --global core.editor "cursor --wait"
工作区: 添加文件夹到当前工作区:cursor --add /path/to/folder
扩展管理: 列出已安装:cursor --list-extensions 安装:cursor --install-extension <extension-id> 卸载:cursor --uninstall-extension <extension-id> 禁用全部:cursor --disable-extensions
版本与调试: cursor --version;cursor --help;cursor --verbose /path/to/file;cursor --inspect-extensions
设置与配置: 用户设置:~/Library/Application Support/Cursor/User/settings.json 快捷键:~/Library/Application Support/Cursor/User/keybindings.json 便携/配置目录:cursor --user-data-dir /path/to/data;cursor --extensions-dir /path/to/extensions
管道输入: echo "console.log('hello')" | cursor -
远程开发:与 VS Code 类似,SSH 远程在 ~/.ssh/config 中配置,然后在图形界面使用命令面板或远程资源管理器
限制:资料仅提供上述 CLI 用法与配置路径;未提供收费、价格、支持平台版本、性能与效果等信息。