7

在命令行中,如果我这样做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]

另外,当我这样做时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.

我的~/.bashprofile有以下几行:

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

export EDITOR="/usr/local/bin/mate -w"

~/.bashrc只有这个:

alias mate='open -a TextMate.app'

编辑 1

我的~/.gitconfig包括以下内容:

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

帮助!

4

2 回答 2

11

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

假设配对路径正确,配置它的简单方法是运行

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

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

编辑:将评论合并到答案中。

于 2012-08-31T08:09:47.177 回答
6

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

[core]
    editor = mate

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

同学2:

在首选项中,有一个终端选项卡和一个安装按钮 当您单击安装时,伴侣将位于 /usr/local/bin/mate 中,并且一切正常。

同学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

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

于 2012-08-31T08:12:39.797 回答