问题描述
有没有一种方法可以使在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
- Add the following to your
~/.bashrc
file:export EDITOR="/Applications/TextEdit.app/Contents/MacOS/TextEdit"
- or just type the following command into your Terminal:
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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!