从编程的观点来看,当通过

设置bash外壳使用vi或emacs的
set -o vi

set -o emacs

什么是真正回事?我已经阅读一本书,其中它声称bash外壳使用任一这些编辑器用于将输入到所述壳体本身,但我认为它可能已经readline的使用。

有帮助吗?

解决方案

击仍在使用readline的。 readline的使用任一的emacs或vi模式和设置各种编辑模式之间的模式切换。可以检查的lib / readline的文件夹中的碱源代码,以查看各种键绑定。

其他提示

按照手册页BASH_BUILTINS(1)(在Fedora 8):

   set [--abefhkmnptuvxBCHP] [-o option] [arg ...]

...(跳过所有的单字母选项)

         -o option-name
            The option-name can be one of the following:

...

            emacs   Use  an  emacs-style  command  line  editing interface.  This is
                    enabled by default when the shell  is  interactive,  unless  the
                    shell is started with the --noediting option.
...
            vi      Use a vi-style command line editing interface.
我解释这意味着庆典直接口译行编辑的命令。此选项会将其命令设置为使用。见的readline(3)的手册页。

它使用所熟悉的那些编辑之一的用户的击键来编辑命令行。

的Readline是,其提供功能来击和其他程序的设施。

man bash

READLINE
       This is the library that handles reading input when using  an  interac‐
       tive shell, unless the --noediting option is given at shell invocation.
       Line editing is also used when using the -e option to the read builtin.
       By default, the line editing commands are similar to those of emacs.  A
       vi-style line editing interface is also available.  Line editing can be
       enabled  at  any  time  using  the -o emacs or -o vi options to the set
       builtin (see SHELL BUILTIN COMMANDS below).  To turn off  line  editing
       after  the  shell  is running, use the +o emacs or +o vi options to the
       set builtin.

据我所知,readline是什么提供对于bash线路编辑功能。

一个条件:当您按下v在vi命令模式下,可以完全成熟的vi编辑器来编辑你的命令行

man bash

  

READLINE结果   这是处理使用交互式shell时,除非--noediting选项在shell调用给出读取输入的库。默认情况下,行编辑命令类似于emacs的的。一个VI风格的行编辑界面也可以。要关闭壳运行之后行编辑,使用+o emacs+o vi选项给set内置

当壳您呈现一个提示(除非在非编辑模式是),你的已经使用readline。你要么是emacs模式或vi插入模式(这就是为什么你可以使用ESC,回到vi命令模式)。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top