Linux 列表bash“;绑定-x";绑定
我搜索了Linux 列表bash“;绑定-x";绑定,linux,bash,shell,Linux,Bash,Shell,我搜索了manbash,但没有找到列出所有当前bind-x键绑定的任何内容。我有办法做到吗?我尝试了以下方法: $ bind -x '"\C-`":"echo hello"' # test binding: press CTRL+` hello # Binding works! $ bind -p | grep 'hello' # no output $ bind -S # no output 那么,我有没有办法看到所有当前活动的bind-x列表?似乎可以使用bind-x(Bash中新增的4.
manbash
,但没有找到列出所有当前bind-x
键绑定的任何内容。我有办法做到吗?我尝试了以下方法:
$ bind -x '"\C-`":"echo hello"'
# test binding: press CTRL+`
hello
# Binding works!
$ bind -p | grep 'hello'
# no output
$ bind -S
# no output
那么,我有没有办法看到所有当前活动的
bind-x
列表?似乎可以使用bind-x
(Bash中新增的4.3):
上面的回答在bash
4.3.48
上为我返回了空输出。但大写字母“P”确实起作用:
绑定-显示所有函数名(和绑定)
解释
-P List current readline function names and bindings.
-p Display readline function names and bindings in such a
way that they can be re-read.
样本输出
set-mark can be found on "\C-@", "\e ".
shell-expand-line can be found on "\e\C-e".
start-kbd-macro can be found on "\C-x(".
tilde-expand can be found on "\e&".
transpose-chars can be found on "\C-t".
transpose-words can be found on "\et".
undo can be found on "\C-x\C-u", "\C-_".
unix-line-discard can be found on "\C-u".
unix-word-rubout can be found on "\C-w".
upcase-word can be found on "\eu".
yank can be found on "\C-y".
yank-last-arg can be found on "\e.", "\e_".
yank-nth-arg can be found on "\e\C-y".
yank-pop can be found on "\ey".
参考页
由于很难找到它的手册页,这里是:
bind [-m keymap] [-lpsvPSVX]
bind [-m keymap] [-q function] [-u function] [-r keyseq]
bind [-m keymap] -f filename
bind [-m keymap] -x keyseq:shell-command
bind [-m keymap] keyseq:function-name
bind readline-command
Display current readline key and function bindings, bind a key
sequence to a readline function or macro, or set a readline
variable. Each non-option argument is a command as it would
appear in .inputrc, but each binding or command must be passed
as a separate argument; e.g., '"\C-x\C-r": re-read-init-file'.
Options, if supplied, have the following meanings:
-m keymap
Use keymap as the keymap to be affected by the subsequent
bindings. Acceptable keymap names are emacs,
emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move,
vi-command, and vi-insert. vi is equivalent to
vi-command; emacs is equivalent to emacs-standard.
-l List the names of all readline functions.
-p Display readline function names and bindings in such a
way that they can be re-read.
-P List current readline function names and bindings.
-s Display readline key sequences bound to macros and the
strings they output in such a way that they can be re-
read.
-S Display readline key sequences bound to macros and the
strings they output.
-v Display readline variable names and values in such a way
that they can be re-read.
-V List current readline variable names and values.
-f filename
Read key bindings from filename.
-q function
Query about which keys invoke the named function.
-u function
Unbind all keys bound to the named function.
-r keyseq
Remove any current binding for keyseq.
-x keyseq:shell-command
Cause shell-command to be executed whenever keyseq is
entered. When shell-command is executed, the shell sets
the READLINE_LINE variable to the contents of the
readline line buffer and the READLINE_POINT variable to
the current location of the insertion point. If the
executed command changes the value of READLINE_LINE or
READLINE_POINT, those new values will be reflected in the
editing state.
-X List all key sequences bound to shell commands and the
associated commands in a format that can be reused as
input.
The return value is 0 unless an unrecognized option is given or
an error occurred.
我不知道您使用的是哪个版本的bash,但对我来说,
bind-X
返回无效选项
。实际上,help bind
并没有为我列出-X
。在我的机器上,bash--version
生成version 4.2.45(1)-发行版(x86_64-pc-linux-gnu)
我使用的是4.3(beta版)。我不知道这是新增加的功能。:)呵呵!所以,我想我会坚持到底:-P你知道他们4.2的发布时间表/解决方案吗?不知道确切的时间表。@Savui:Bash 4.3两周前刚刚发布。我应该使用什么命令来查看手册页?每当我运行manbind
时,它都会显示用于将名称绑定到socketI的手册页。我只能通过基于web的手册页访问此信息。从命令行我含糊不清;你记得这个信息很难找到,可能不太可能。但是我很久以前就发现:)bind
不是一个独立的程序,它是bash内置的。使用help bind
获取帮助(也适用于其他内置程序,如if
或cd
)。
set-mark can be found on "\C-@", "\e ".
shell-expand-line can be found on "\e\C-e".
start-kbd-macro can be found on "\C-x(".
tilde-expand can be found on "\e&".
transpose-chars can be found on "\C-t".
transpose-words can be found on "\et".
undo can be found on "\C-x\C-u", "\C-_".
unix-line-discard can be found on "\C-u".
unix-word-rubout can be found on "\C-w".
upcase-word can be found on "\eu".
yank can be found on "\C-y".
yank-last-arg can be found on "\e.", "\e_".
yank-nth-arg can be found on "\e\C-y".
yank-pop can be found on "\ey".
bind [-m keymap] [-lpsvPSVX]
bind [-m keymap] [-q function] [-u function] [-r keyseq]
bind [-m keymap] -f filename
bind [-m keymap] -x keyseq:shell-command
bind [-m keymap] keyseq:function-name
bind readline-command
Display current readline key and function bindings, bind a key
sequence to a readline function or macro, or set a readline
variable. Each non-option argument is a command as it would
appear in .inputrc, but each binding or command must be passed
as a separate argument; e.g., '"\C-x\C-r": re-read-init-file'.
Options, if supplied, have the following meanings:
-m keymap
Use keymap as the keymap to be affected by the subsequent
bindings. Acceptable keymap names are emacs,
emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move,
vi-command, and vi-insert. vi is equivalent to
vi-command; emacs is equivalent to emacs-standard.
-l List the names of all readline functions.
-p Display readline function names and bindings in such a
way that they can be re-read.
-P List current readline function names and bindings.
-s Display readline key sequences bound to macros and the
strings they output in such a way that they can be re-
read.
-S Display readline key sequences bound to macros and the
strings they output.
-v Display readline variable names and values in such a way
that they can be re-read.
-V List current readline variable names and values.
-f filename
Read key bindings from filename.
-q function
Query about which keys invoke the named function.
-u function
Unbind all keys bound to the named function.
-r keyseq
Remove any current binding for keyseq.
-x keyseq:shell-command
Cause shell-command to be executed whenever keyseq is
entered. When shell-command is executed, the shell sets
the READLINE_LINE variable to the contents of the
readline line buffer and the READLINE_POINT variable to
the current location of the insertion point. If the
executed command changes the value of READLINE_LINE or
READLINE_POINT, those new values will be reflected in the
editing state.
-X List all key sequences bound to shell commands and the
associated commands in a format that can be reused as
input.
The return value is 0 unless an unrecognized option is given or
an error occurred.