7

At the command-line, if I do mate <filepath> it opens up the right file for me in TextMate.

But when I do:

$ 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 this:

$ 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 these 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 has just this one:

alias mate='open -a TextMate.app'

Edit 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!

marcamillion
  • 32,933
  • 55
  • 189
  • 380
  • And with export `EDITOR="mate"`, is this any better? – VonC Aug 31 '12 at 07:53
  • @VonC huh? Not sure I understand what you mean? What file should I be editing and what should I be writing/replacing? – marcamillion Aug 31 '12 at 08:00
  • @VonC if you mean if I try adding `export EDITOR="mate"` to my `.bashprofile`, then yes I just tried it and it hasn't worked. Do I have to close Terminal all together, or can I just close that Terminal session and re-open it? I have Rails server running in another Term session, so I would hate to have to close it. But if I need to, I can do that. – marcamillion Aug 31 '12 at 08:02
  • @marcamillion: opening a new session is sufficient – CharlesB Aug 31 '12 at 08:14
  • Yes, I meant that, but the answers below are likely to be more accurate anyway. – VonC Aug 31 '12 at 08:15

2 Answers2

12

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.

eis
  • 51,991
  • 13
  • 150
  • 199
  • Hrmm....great suggestion. So I tried running `/usr/local/bin/mate -w` and it returned a `-bash: /usr/local/bin/mate: No such file or directory`. Where else might TextMate be? How can I find it? – marcamillion Aug 31 '12 at 08:28
  • 1
    @marcamillion so that's your problem. try "which mate" to find it if it exists in your path. – eis Aug 31 '12 at 09:14
  • @marcamillion if it doesn't, i'd think you need to use "open -a TextMate.app" that you have in your alias. – eis Aug 31 '12 at 09:15
  • That was it! If you want to modify your answer, I will accept it. – marcamillion Aug 31 '12 at 09:46
6

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

James Kyburz
  • 13,775
  • 1
  • 32
  • 33