问题描述
有没有办法让在终端中打开进行编辑的文件改为在 Textedit 中打开?
Is there a way to make files opened for editing in the terminal open in Textedit instead?
例如,一个命令可能会打开一个文件进行编辑(如 git commit
),而不是在 vim 或 emacs 中打开该文件,它会在 Textedit(或者可能是另一个文本编辑应用程序)中打开您选择的,例如 Coda 或 Sublime).
For example, where a command might open a file for editing (like git commit
), instead of opening that file in vim or emacs, it would open in Textedit (or perhaps another text editing application of your choosing, such as Coda or Sublime).
作为一个额外的问题,有没有什么方法可以专门配置 git 以自动打开在应用程序目录中的编辑器中运行 git commit
后创建的文件?
And as a bonus question, is there any way to specifically configure git to automatically open the file created after running git commit
in an editor from the applications directory?
推荐答案
大多数程序都会检查 $EDITOR
环境变量,因此您可以将其设置为 bashrc 中 TextEdit 的路径.Git 也会使用它.
Most programs will check the $EDITOR
environment variable, so you can set that to the path of TextEdit in your bashrc. Git will use this as well.
- 将以下内容添加到您的
~/.bashrc
文件中:export EDITOR="/Applications/TextEdit.app/Contents/MacOS/TextEdit"
- 或者只需在终端中输入以下命令:
echo "export EDITOR="/Applications/TextEdit.app/Contents/MacOS/TextEdit"";>>~/.bashrc
如果您使用的是 zsh,请使用 ~/.zshrc
而不是 ~/.bashrc
.
If you are using zsh, use ~/.zshrc
instead of ~/.bashrc
.
这篇关于更改在终端中打开的文件的默认编辑器?(例如将其设置为 TextEdit/Coda/Textmate)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!