【问题标题】:How do i add a command line prompt as the $EDITOR when committing in svn and git在 svn 和 git 中提交时如何添加命令行提示符作为 $EDITOR
【发布时间】:2011-08-19 22:15:48
【问题描述】:

是否可以有一个小的 shell 脚本来替换 git 和 svn 的 $EDTIOR

所以当一个不熟悉 vi 或 emacs 的人提交并忘记添加 -m "fixed the foo bug" 参数它不会打开他们不知道如何退出的编辑器,而是只会提示

请证明此提交包含的内容:

用户只需写一个小句子,按回车键,然后就走了。

【问题讨论】:

  • 将他们的$VISUAL 配置为他们知道如何使用的东西不是更好吗?

标签: svn git editor prompt pre-commit


【解决方案1】:

对于 git,您可以编辑您的 config 文件。将editor 添加到core 部分,并指向您选择的编辑器。比如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 "$*"`

【讨论】:

    【解决方案2】:

    我们拥有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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-01
      • 1970-01-01
      • 2013-03-30
      • 2020-12-24
      • 1970-01-01
      • 2010-12-30
      相关资源
      最近更新 更多