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

标签 git bash terminal osx-lion textmate

在命令行中,如果我执行 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)

帮助!

最佳答案

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

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

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

编辑:将评论 merge 到答案中。

关于git - 我如何让 git 使用 Textmate 作为我的默认编辑器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12210998/

相关文章:

git - 推送后回滚远程 repo

java - 如何从 Bash shell 脚本优雅地关闭 Java 服务?

linux - 如何捕获变量中文件的最后修改日期

shell - 错误 : EACCES, 取消链接...

linux - 在 Linux 终端中运行文件

linux - 如何在Linux中比较两个mp4文件

git - 为什么 sqlite3 不能在我的 homestead/Laravel 设置中工作?

Ubuntu 升级后 Git 误报

git - git 是否允许 "bare"子模块?

linux - 无法使用curl从Linux服务器上的firebase存储下载文件会出现段错误