简体   繁体   中英

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. How does this work without Emacs present?

I tried to search the Bash source code, but still can't understand. Does Bash integrate Emacs within itself?

$ 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).

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 .


(1) Yes, the same GNU that's responsible for the emacs editor.

The reference to emacs has little to do with the emacs editor itself. It refers to the 'style' of key bindings used by the GNU readline library which bash uses. Readline supports two key binding modes - emacs style and vi style. The default is usually emacs style. 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).

Read the section on readline in the bash manual for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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