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

On the command line, if I do a mate <filepath> , it opens the correct file for me in TextMate.

But when I do this:

 $ mate -v open: invalid option -- v Usage: open [-e] [-t] [-f] [-W] [-R] [-n] [-g] [-h] [-b <bundle identifier>] [-a <application>] [filenames] [--args arguments] 

Also, when I do git commit , I see the following:

 $ git commit error: cannot run mate: No such file or directory error: There was a problem with the editor 'mate'. Please supply the message using either -m or -F option. 

My ~/.bashprofile has the following lines:

 #Set Textmate as my default editor from the command-line alias mate='open -a TextMate.app' export EDITOR="/usr/local/bin/mate -w" 

And ~/.bashrc only has this:

 alias mate='open -a TextMate.app' 

Change 1

My ~/.gitconfig includes the following:

 [user] name = My Name email = myemail@address.com [core] editor = mate [github] user = marcamillion token = 50e3iuaidsgadjkhwkjegakjhbsdkjb30432 (don't worry, this is fake) 

Help!

+4
source share
2 answers

By adding to the main section in ~ / .gitconfig

following:
 [core] editor = mate 

Update: Well, if it already exists, the problem is probably related to textmate, not git.

Textmate 2:

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

Text 1:

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

I have textmate 1 (now i am using vim :)

 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

+5
source

The editor used to edit the commit log message will be selected from the GIT_EDITOR environment variable, the core.editor configuration variable, the VISUAL environment variable, or the EDITOR environment variable (in that order).

An easy way to configure this, assuming the pairing path is correct, is to run

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

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

Edit: added comments in response.

+7
source

All Articles