
重擊用途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
.