如何让git使用Textmate作为我的默认编辑器?

mar*_*ion 4 git bash terminal textmate osx-lion

在命令行,如果我这样做mate <filepath>,在TextMate中为我打开正确的文件.

但当我这样做时:

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

另外,当我这样做时git commit,我看到了这个:

$ 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.
Run Code Online (Sandbox Code Playgroud)

~/.bashprofile有以下几点:

#Set Textmate as my default editor from the command-line
alias mate='open -a TextMate.app'

export EDITOR="/usr/local/bin/mate -w"
Run Code Online (Sandbox Code Playgroud)

而且~/.bashrc只有这一个:

alias mate='open -a TextMate.app'
Run Code Online (Sandbox Code Playgroud)

编辑1

~/.gitconfig包括以下内容:

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

救命!

eis*_*eis 7

用于编辑提交日志消息的编辑器将从GIT_EDITOR环境变量,core.editor配置变量,VISUAL环境变量或EDITOR环境变量(按此顺序)中选择.

假设配合路径正确,可以轻松配置此方法

git config --global core.editor "/usr/local/bin/mate -w"
Run Code Online (Sandbox Code Playgroud)

当然,假设你可以跑/usr/local/bin/mate -w.通过/usr/local/bin/mate -w与本地用户一起运行来检查.如果which mate找不到它,你可以使用它来查找路径中是否存在 - 如果它不存在,我认为你需要使用别名中的表单(open -a TextMate.app -w).

编辑:将评论纳入答案.


Jam*_*urz 5

通过将以下内容添加到〜/ .gitconfig中的核心部分

[core]
    editor = mate
Run Code Online (Sandbox Code Playgroud)

更新:好的,如果它已经存在那么问题可能是textmate而不是git.

Textmate 2:

在首选项中有一个终端选项卡和一个安装按钮当你点击安装配合将在/ usr/local/bin/mate中,一切都应该工作.

Textmate 1:

您需要创建一个符号链接 http://manual.macromates.com/en/using_textmate_from_terminal.html

我有textmate 1(我现在使用vim :)

ls -l `which mate`

lrwxr-xr-x  1 jameskyburz  staff  66 Jul  1  2011 /usr/local/bin/mate -> /Applications/TextMate.app/Contents/SharedSup
Run Code Online (Sandbox Code Playgroud)

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