git - 如何防止在 VS Code 终端中使用标准的 git 合并编辑器?
问题描述
我喜欢尽可能多地使用命令行来发出 git 命令,但是当发生合并时,emacs
会根据我的设置启动。如果这发生在 VS Code 终端中,键绑定将无法正常工作。有没有办法配置 VS Code 终端,以便将 VS Code 本身用作合并编辑器(但仅在git
从 VS Code 终端调用时)?
解决方案
您可以根据您的外壳检测到TERM_PROGRAM
您的~/.bashrc
或就此而言:~/.zshrc
if [ "$TERM_PROGRAM" = "vscode" ]
then
export GIT_EDITOR="code"
else
export GIT_EDITOR="emacs"
fi
看着man git-commit
你可以看到 git 如何选择合适的编辑器,你可能想简单地设置EDITOR
环境变量,而不是GIT_EDITOR
其他程序也会从中受益:
$ man git-commit | awk '/core.editor/' RS=
ENVIRONMENT AND CONFIGURATION VARIABLES
The editor used to edit the commit log message will be chosen from the
GIT_EDITOR environment variable, the core.editor configuration
variable, the VISUAL environment variable, or the EDITOR environment
variable (in that order). See git-var(1) for details.
推荐阅读
- php - php搜索框结果显示不正确?
- graph - 使用边缘数据计算下游的最佳方法
- awk - 当其中一个是管道字符时使用多个分隔符
- node.js - NodeJS rest api在使用参数时发送状态404怎么办?
- tensorflow - 专用 GPU 内存无法清除
- php - 通过 PHP 的 sql 查询总是跳过第一行
- java - 如果没有附加自定义目标,Maven 验证阶段是否会作为生命周期的一部分执行?
- javascript - request.body 回来了 undefined
- python - 在这个 TensorFlow 模型中,哪些模型参数从一个时期到下一个时期发生了变化?
- java - Getter 和 Setter 仅适用于创建的最后一个对象