在 $EDITOR 中打开命令的 bash 功能在哪里记录?

Kar*_*tik 31 bash line-editor

我最近发现,如果我们按Ctrl+ X Ctrl+ E,bash 会在编辑器中打开当前命令(在$VISUAL或 中设置$EDITOR)并在编辑器关闭时执行它。但它似乎没有记录在man页面中。

Kar*_*tik 41

我现在已经发现了。在问这个之前,我应该更仔细地阅读它。

man页面说:

edit-and-execute-command (C-xC-e)
          Invoke  an  editor  on the current command line, and execute the
          result as shell commands.   Bash  attempts  to  invoke  $VISUAL,
          $EDITOR, and emacs as the editor, in that order.
Run Code Online (Sandbox Code Playgroud)

  • 使用此功能时要非常小心。如果取消编辑,将立即执行原来的命令行。因此,如果您正在编辑 rm -rf / 并调用编辑器并意识到您遇到危险并因此取消编辑,则您的 rootfs 将被删除,而不会再问任何问题。 (13认同)
  • @marlar 如果你的编辑器是 vim,你可以使用 `:cq`,它使它以非零代码退出,并阻止命令执行 (9认同)
  • @marlar [ctrl-xe而不立即执行命令](https://superuser.com/q/1601543/432690)。 (2认同)