重击用途GNU 阅读线。 Readline 提供了一系列键盘快捷键。但是,有一些可在 bash 上使用的快捷方式和Readline 中未记录的内容参考。一些例子是:
C-h
- 与退格键相同C-m
- 与 Enter 相同(我猜是 CR)
那么为什么这些捷径有效呢?我想这些可能与ASCII码但我不确定哪个组件将这些控制序列解释为我所指示的行为。
是 Readline 库吗?还是 bash 本身?这是我的终端模拟器吗?是内核吗? ETC...
是什么组件使这些控制序列以这种方式运行?
编辑:我的.inputrc
文件:
# To the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to the
# public domain worldwide. This software is distributed without any warranty.
# You should have received a copy of the CC0 Public Domain Dedication along
# with this software.
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
# base-files version 4.2-4
# ~/.inputrc: readline initialization file.
# The latest version as installed by the Cygwin Setup program can
# always be found at /etc/defaults/etc/skel/.inputrc
# Modifying /etc/skel/.inputrc directly will prevent
# setup from updating it.
# The copy in your home directory (~/.inputrc) is yours, please
# feel free to customise it to create a shell
# environment to your liking. If you feel a change
# would be benifitial to all, please feel free to send
# a patch to the cygwin mailing list.
# the following line is actually
# equivalent to "\C-?": delete-char
"\e[3~": delete-char
# VT
"\e[1~": beginning-of-line
"\e[4~": end-of-line
# kvt
"\e[H": beginning-of-line
"\e[F": end-of-line
# rxvt and konsole (i.e. the KDE-app...)
"\e[7~": beginning-of-line
"\e[8~": end-of-line
# VT220
"\eOH": beginning-of-line
"\eOF": end-of-line
# Allow 8-bit input/output
#set meta-flag on
#set convert-meta off
#set input-meta on
#set output-meta on
#$if Bash
# Don't ring bell on completion
#set bell-style none
# or, don't beep at me - show me
#set bell-style visible
# Filename completion/expansion
#set completion-ignore-case on
#set show-all-if-ambiguous on
# Expand homedir name
#set expand-tilde on
# Append "/" to all dirnames
#set mark-directories on
#set mark-symlinked-directories on
# Match all files
#set match-hidden-files on
# 'Magic Space'
# Insert a space character then performs
# a history expansion in the line
#Space: magic-space
#$endif
答案1
当您键入时,会出现绑定(无论它们是否出现在手册中)
bind -p
例如(部分列出):
"\C-g": abort
"\C-x\C-g": abort
"\e\C-g": abort
"\C-j": accept-line
"\C-m": accept-line
# alias-expand-line (not bound)
# arrow-key-prefix (not bound)
# backward-byte (not bound)
"\C-b": backward-char
# backward-byte (not bound)
"\C-b": backward-char
"\eOD": backward-char
"\e[D": backward-char
"\C-h": backward-delete-char
"\e[3;5~": backward-delete-char
"\C-?": backward-delete-char
"\C-x\C-?": backward-kill-line
"\e\C-h": backward-kill-word
"\e\C-?": backward-kill-word
"\eb": backward-word
"\e<": beginning-of-history
该手册记录了该-p
选项:
这
bind -p
命令显示阅读线函数名称和绑定的格式可以直接放入初始化文件中。看Bash 内置函数。
绑定(阅读源代码)取决于键盘映射。我引用的内容来自于emacs 键盘映射,它是在应用脚本之前从内置表初始化的。有一个相应的文件,其中包含表格vi 键盘映射。
所有这些都是阅读线(与 捆绑在一起bash
)。bash
启动时,它使用这些表定义绑定。根据它读取的其他文件/etc/inputrc
,~/.inputrc
它可能会添加、修改或删除其中一些内置绑定。
答案2
正如您所参考的手册的“1.3 Readline Init File”部分所指出的,readline库是可配置的。键绑定可以在/etc/inputrc
或本地~/.inputrc
.