3

用于在使用命令行时快速定位位置(是的,我是 Emacs 粉丝)。在查看 Bash 的人之后,我找不到这样的提示。是否需要修改 readline 的源代码来支持这一点?

非常感谢!!

4

2 回答 2

7

我不知道直接在命令行中执行此操作的方法,但 bash 确实支持在您选择的编辑器中打开命令行的按键。从 bash 手册页:

   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  $FCEDIT,
          $EDITOR, and emacs as the editor, in that order.

因此,在 emacs 绑定模式(默认)下按 CTRL-x CTRL-e 或在 vi 绑定模式(set -o vi为此)按 ESC v 将在上述环境变量指定的编辑器中打开现有命令行。您可以编辑命令行,一旦您保存并退出编辑器,该命令将被执行。

于 2009-10-07T05:52:50.523 回答
4

CTRL-r (reverse-i-search) 将允许您搜索当前行以及历史记录中的任何内容。

如果你想跳回几个参数,你可以点击空格,然后再次 CTRL-r 以“再次查找”。Escape 将在最后一个搜索结果处用光标跳出它。

于 2010-02-07T01:26:40.540 回答