假设我想通过 bash 输入一个多行命令,我知道我可以在该行的末尾附加\以输入一个新行
然而,是否有可能进入合法的“文本编辑器模式”,您甚至不必输入\而只需按 enter 就足够了
例如..你在命令行中输入命令然后在输入参数之前你按下一些魔法按钮允许你进入类似vi的模式然后你输入东西进入“vi模式”然后你退出然后你在“vi模式”下输入的文本变成命令的参数然后你回车然后命令执行
是否可以在 bash 命令行中执行此操作?如果是这样,我该怎么做?
最佳答案
参见 man 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 $VISUAL,
$EDITOR, and emacs as the editor, in that order.
默认情况下 bash 配置为 emacs 模式,因此 emacs 喜欢 C-xC-e 命令。
如果你真的喜欢 vi,你也可以将你的 bash 设置为 vi 模式:set -o vi
。这允许您在不调用显式编辑器的情况下以 vi 方式进行正常的行编辑。
关于linux - 用于调用 bash 命令的文本编辑器模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18437396/