【发布时间】:2016-01-23 18:54:33
【问题描述】:
我正在尝试将我的 Mac Book Pro (OSX El Capitan 10.11.1) 配置为使用 Visual Studio Code 作为其默认编辑器。我创建了一个~/.bash_profile 文件,其中包含以下两行
vscode () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
export VISUAL=open\ -n\ -b\ "com.microsoft.VSCode"
这适用于某些事情:我可以在 bash 终端输入 vscode test.txt,然后在 Visual Studio Code 中弹出 test.txt,如果我运行命令 env,我会在列表中看到 VISUAL=open -n -b com.microsoft.VSCode。我什至可以只输入$VISUAL,Visual Studio Code 就会在一个新的空文件上打开。
但如果我输入 git commit 我会收到以下错误
错误:无法运行 com.microsoft.vscode:没有这样的文件或目录
错误:无法启动编辑器“com.microsoft.vscode”请提供
使用 -m 或 -F 选项的消息。
所以我成功了,因为 git 试图打开 Visual Studio Code 让我编辑我的提交消息,但它随后失败了。
我应该在~/.bash_profile 文件的export VISUAL=X 行中使用什么X 以使git 能够打开Visual Studio Code 以获取提交消息?
(注:How to use Visual Studio Code as Default Editor for Git 不是重复的,因为 Gary 使用的是 Windows PC。)
【问题讨论】:
标签: git macos visual-studio-code