How do I get git to use Textmate as my default editor?

江枫思渺然 提交于 2019-11-30 15:39:05

By adding the following to the core section in ~/.gitconfig

[core]
    editor = mate

Update: Ok if it's already there then the issue is probably with textmate and not git.

Textmate 2:

In preferences there is a terminal tab and an install button When you click on install mate will be in /usr/local/bin/mate and everything should work.

Textmate 1:

You need to create a symbolic link http://manual.macromates.com/en/using_textmate_from_terminal.html

I have textmate 1 (I use vim now :)

ls -l `which mate`

lrwxr-xr-x  1 jameskyburz  staff  66 Jul  1  2011 /usr/local/bin/mate -> /Applications/TextMate.app/Contents/SharedSup

ln -s /Applications/TextMate.app/Contents/Resources/mate /usr/local/bin/mate

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).

Easy way to configure this, assuming the mate path is correct, is to run

git config --global core.editor "/usr/local/bin/mate -w"

Assuming, of course, that you can run /usr/local/bin/mate -w. Check that by running /usr/local/bin/mate -w with your local user. If it isn't found, you can use which mate to find it if it exists in your path at all - if it doesn't, I'd think you need to use the form you have in your alias (open -a TextMate.app -w).

Edit: incorporated comments into the answer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!