如何在提交svn和git时将命令行提示符设置为$EDITOR?

5
有没有可能编写一个小的shell脚本来替换git和svn中的$EDITOR
这样,当不熟悉vi或emacs的人提交时忘记添加-m“fixed the foo bug”参数时,它不会打开一个他们不知道如何退出的编辑器,而是会提示:

请提供有关此提交包含什么的句子:

用户只需写一个简短的句子,按下回车,就可以提交了。

他们是否将他们的 "$VISUAL" 配置为熟悉的东西会更好呢? - Jan Hudec
2个回答

2

对于git,您可以编辑config文件。在core部分中添加editor,并指向您选择的编辑器。例如,在cygwin下使用notepad++和git:

[core]
    editor = git-core-editor.sh

git-core-editor.sh的内容(将其放置在cygwin/bin目录中):

#!/bin/sh
"C:/Program Files (x86)/Notepad++/notepad++.exe" -multiInst -notabbar -nosession `cygpath -w -a "$*"`

1

我们有 nano 的原因。

但你可以使用一个小的bash脚本:

#!/bin/sh
set -e
# Show the message template so the user knows what's up
cat $1
echo "Type your message, or press return to abort:"
head -n1 > $1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接