简体   繁体   English

没有Emacs,Bash命令行编辑如何在Emacs模式下工作?

[英]Without Emacs, how does Bash command line editing work in Emacs mode?

Without Emacs installed on my Linux system, Bash command line editing default mode is still Emacs. 在我的Linux系统上未安装Emacs的情况下,Bash命令行编辑默认模式仍然是Emacs。 How does this work without Emacs present? 没有Emacs的情况下如何工作?

I tried to search the Bash source code, but still can't understand. 我试图搜索Bash源代码,但仍然无法理解。 Does Bash integrate Emacs within itself? Bash是否在自己内部集成了Emacs?

$ set -o
allexport       off
braceexpand     on
emacs           on
: :
vi              off
xtrace          off

The GNU (1) readline library is what does the heavy lifting for bash (and any other interactive input systems that choose to use it). GNU (1) readline库是对bash (以及选择使用它的任何其他交互式输入系统)的繁重工作。

That's the source code you should be looking at, if you want to understand how it works. 如果您想了解其工作原理,那么这就是您应该查看的源代码。

The readline packages are hosted alongside bash . readline软件包 bash 一起托管


(1) Yes, the same GNU that's responsible for the emacs editor. (1)是的, emacs编辑器相同的 GNU。

The reference to emacs has little to do with the emacs editor itself. 对emacs的引用与emacs编辑器本身无关。 It refers to the 'style' of key bindings used by the GNU readline library which bash uses. 它指的是bash使用的GNU readline库使用的键绑定的“样式”。 Readline supports two key binding modes - emacs style and vi style. Readline支持两种键绑定模式-emacs样式和vi样式。 The default is usually emacs style. 默认通常是emacs样式。 The readline library is very powerful, but to be honest, in 25 years of Linux use, I've never bothered with most of the advanced features and have never even tried the vi mode (even when VI was my default editor). readline库非常强大,但是老实说,在Linux使用25年的时间里,我从来没有为大多数高级功能而烦恼,甚至从未尝试过vi模式(即使VI是我的默认编辑器)。

Read the section on readline in the bash manual for more details. 阅读bash手册中readline上的部分以获取更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM