【问题标题】:How to edit a commit message in emacs inside a terminal?如何在终端内的 emacs 中编辑提交消息?
【发布时间】:2018-10-10 12:25:01
【问题描述】:

我使用 macOS、Emacs 进行文本编辑,使用 git 进行版本控制。如果我在提交消息中出错,我会输入

git commit --amend

默认打开vim。我可以将其设置为 Emacs:

 git config --global core.editor "emacs"

这会打开 Emacs GUI 以及已经运行的 GUI,并运行所有初始化脚本。

如何在终端中使用 Emacs 编辑提交消息?

【问题讨论】:

    标签: git emacs


    【解决方案1】:

    Emacs 的选项是here。您希望 -nw--no-window-system 在终端中加载 Emacs,并希望 -q--no-init-file 绕过初始化脚本。

    所以将你的 git 选项设置为:

    git config --global core.editor "emacs -nw -q"
    

    您也可以在没有文本编辑器的情况下修改提交消息(请参阅this thread):

    git commit --amend -m "My message"
    

    【讨论】:

    • 我也可以设置成emacsclient吗?
    • @alper 是的,请参阅 Evgenii emacsclient 的另一个答案。事先,您需要从 Emacs 内部启动服务器,例如M-x server-start,否则你会看到emacsclient: can't find socket; have you started the server?
    【解决方案2】:

    除了mmorin的评论:

    1. 无需每次都启动另一个 emacs 实例,使用 emacsclient 即可。见https://www.emacswiki.org/emacs/EmacsAsDaemon
    2. 如果您的工作流程包含 Linux,您可以将环境变量 EDITOR 设置为 emacs/emacsclient 以使用 emacsclient(或基于 Debian 的发行版中的“编辑器”替代方案)编辑所有内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-23
      • 2011-04-25
      • 1970-01-01
      • 2017-07-25
      • 2010-09-23
      • 2015-07-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多