Ubuntu用户,你们能用"Ctrl+Shift+R"搜索命令行历史?(Bash可以如此绑定?)

最大的社区版本,Ubuntu的发源地
回复
科学之子
帖子: 2284
注册时间: 2013-05-26 6:58
系统: Debian 9

Ubuntu用户,你们能用"Ctrl+Shift+R"搜索命令行历史?(Bash可以如此绑定?)

#1

帖子 科学之子 » 2016-09-21 21:35

Ubuntu用户,你们能用"Ctrl+Shift+R"搜索命令行历史?(Bash可以如此绑定?)
顺便求你们如下命令的结果:

代码: 全选

bind -P | grep  '^forward-search-history'
bash有办法能设置键盘绑定为"ctrl+shift+R"的形式?
http://stackoverflow.com/questions/1237 ... -and-forth
On Ubuntu it's definitely Ctrl+Shift+R
我尝试了搜索,但没有发现如何能设置"Ctrl+Shift+R"这样的"Ctrl+Shift"前缀的绑定
我下载了LiveCD运行,没有发现可以这么用
没有安装,只是LiveCD的试用模式
头像
vickycq
帖子: 4507
注册时间: 2011-03-20 13:12
系统: Debian
来自: 山东省寿光县
联系:

Re: Ubuntu用户,你们能用"Ctrl+Shift+R"搜索命令行历史?(Bash可以如此绑定?)

#2

帖子 vickycq » 2016-09-21 22:43

Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
onlylove
论坛版主
帖子: 5230
注册时间: 2007-01-14 16:23

Re: Ubuntu用户,你们能用"Ctrl+Shift+R"搜索命令行历史?(Bash可以如此绑定?)

#3

帖子 onlylove » 2016-09-21 22:54

你要找的是这个?http://www.hypexr.org/bash_tutorial.php
Modifying the Bash Shell with the set Command

Two options that can be set using the set command that will be of some interest to the common user are "-o vi" and "-o emacs". As with all of the environment modifying commands these can be typed at the command prompt or inserted into the appropriate file mentioned above.

Set Emacs Mode in Bash
$ set -o emacs

This is usually the default editing mode when in the bash environment and means that you are able to use commands like those in Emacs (defined in the Readline library) to move the cursor, cut and paste text, or undo editing.

Commands to take advantage of bash's Emacs Mode:
ctrl-a Move cursor to beginning of line
ctrl-e Move cursor to end of line
meta-b Move cursor back one word
meta-f Move cursor forward one word
ctrl-w Cut the last word
ctrl-u Cut everything before the cursor
ctrl-k Cut everything after the cursor
ctrl-y Paste the last thing to be cut
ctrl-_ Undo

NOTE: ctrl- = hold control, meta- = hold meta (where meta is usually the alt or escape key).

A combination of ctrl-u to cut the line combined with ctrl-y can be very helpful. If you are in middle of typing a command and need to return to the prompt to retrieve more information you can use ctrl-u to save what you have typed in and after you retrieve the needed information ctrl-y will recover what was cut.
Set Vi Mode in Bash
$ set -o vi

Vi mode allows for the use of vi like commands when at the bash prompt. When set to this mode initially you will be in insert mode (be able to type at the prompt unlike when you enter vi). Hitting the escape key takes you into command mode.

Commands to take advantage of bash's Vi Mode:
h Move cursor left
l Move cursor right
A Move cursor to end of line and put in insert mode
0 (zero) Move cursor to beginning of line (doesn't put in insert mode)
i Put into insert mode at current position
a Put into insert mode after current position
dd Delete line (saved for pasting)
D Delete text after current cursor position (saved for pasting)
p Paste text that was deleted
j Move up through history commands
k Move down through history commands
u Undo
科学之子
帖子: 2284
注册时间: 2013-05-26 6:58
系统: Debian 9

Re: Ubuntu用户,你们能用"Ctrl+Shift+R"搜索命令行历史?(Bash可以如此绑定?)

#5

帖子 科学之子 » 2016-09-22 0:01

onlylove 写了:你要找的是这个?http://www.hypexr.org/bash_tutorial.php
Modifying the Bash Shell with the set Command

Two options that can be set using the set command that will be of some interest to the common user are "-o vi" and "-o emacs". As with all of the environment modifying commands these can be typed at the command prompt or inserted into the appropriate file mentioned above.

Set Emacs Mode in Bash
$ set -o emacs

This is usually the default editing mode when in the bash environment and means that you are able to use commands like those in Emacs (defined in the Readline library) to move the cursor, cut and paste text, or undo editing.

Commands to take advantage of bash's Emacs Mode:
ctrl-a Move cursor to beginning of line
ctrl-e Move cursor to end of line
meta-b Move cursor back one word
meta-f Move cursor forward one word
ctrl-w Cut the last word
ctrl-u Cut everything before the cursor
ctrl-k Cut everything after the cursor
ctrl-y Paste the last thing to be cut
ctrl-_ Undo

NOTE: ctrl- = hold control, meta- = hold meta (where meta is usually the alt or escape key).

A combination of ctrl-u to cut the line combined with ctrl-y can be very helpful. If you are in middle of typing a command and need to return to the prompt to retrieve more information you can use ctrl-u to save what you have typed in and after you retrieve the needed information ctrl-y will recover what was cut.
Set Vi Mode in Bash
$ set -o vi

Vi mode allows for the use of vi like commands when at the bash prompt. When set to this mode initially you will be in insert mode (be able to type at the prompt unlike when you enter vi). Hitting the escape key takes you into command mode.

Commands to take advantage of bash's Vi Mode:
h Move cursor left
l Move cursor right
A Move cursor to end of line and put in insert mode
0 (zero) Move cursor to beginning of line (doesn't put in insert mode)
i Put into insert mode at current position
a Put into insert mode after current position
dd Delete line (saved for pasting)
D Delete text after current cursor position (saved for pasting)
p Paste text that was deleted
j Move up through history commands
k Move down through history commands
u Undo
viewtopic.php?f=165&t=480629
我的意思是想在这个需求中用"Ctrl+Shift+R"代替"Ctrl+S"
Thu Sep 22 00:55:53 CST 2016补充:
但我没有找到"Ctrl+Shift"前缀的绑定方法
头像
vickycq
帖子: 4507
注册时间: 2011-03-20 13:12
系统: Debian
来自: 山东省寿光县
联系:

Re: Ubuntu用户,你们能用"Ctrl+Shift+R"搜索命令行历史?(Bash可以如此绑定?)

#6

帖子 vickycq » 2016-09-22 11:08

科学之子 写了:这意思就是根本没法用"Ctrl+Shift+R"?
在 Ubuntu GNOME 的 gnome-terminal 中测试 C-r 和 C-S-r 均发送 ^R
科学之子 写了:那个说Ubuntu能用的是怎么回事呢?
在 Ubuntu GNOME 中 i-search 默认绑定为 C-s
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
回复