Linux 如何来回反向搜索?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12373586/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to reverse-i-search back and forth?
提问by m-ric
I use reverse-i-search
often, and that's cool. Sometime though when pressing CTRL+rmultiple times, I passthe command I am actually looking for. Because CTRL+rsearches backward in history, from newest to oldest, I have to:
我reverse-i-search
经常使用,这很酷。有时虽然多次按下CTRL+ r,但我传递了我实际正在寻找的命令。因为CTRL+r在历史中向后搜索,从最新到最旧,我必须:
- cancel,
- search again and
- stop exactly at the command, without passing it.
- 取消,
- 再次搜索并
- 完全停在命令处,而不是通过它。
While in reverse-i-search
prompt, is it possible to search forward, i.e. from where I stand to newest. I naively tried CTRL+Shift+r, no luck. I heard about CTRL+gbut this is not what I am expecting here. Anyone has an idea?
在reverse-i-search
提示时,是否可以向前搜索,即从我站到最新的位置。我天真地尝试了CTRL+ Shift+ r,没有运气。我听说过CTRL+g但这不是我在这里所期望的。有人有想法吗?
采纳答案by gdupont
There is a similar question here:
这里有一个类似的问题:
Control-r reverse-i-search in bash: how do you "reset" the search in Cygwin?
bash 中的 Control-r reverse-i-search:如何在 Cygwin 中“重置”搜索?
Found another similar question on Super User:
在超级用户上发现了另一个类似的问题:
Apparently, both mention Ctrl+s, which may do the trick.
显然,两者都提到了Ctrl+ s,这可能会起作用。
Hope that helps. I myself am trying to find a piece of code that does the reverse-i-search
in order to check how it has been implemented exactly.
希望有帮助。我自己试图找到一段代码reverse-i-search
来检查它是如何实现的。
回答by advisor21
Try delete
, magically worked.
尝试delete
,神奇地工作。
Others point to CTRL+s, but it doesn't work for me.
其他人指向CTRL+ s,但它对我不起作用。
回答by BringBackCommodore64
CTRL+ S
CTRL+ S
...solved it for me AFTER using...
...使用后为我解决了...
stty -ixon
If CTRL+S doesn't work for you is because according to Vincenzo Pii'saccepted answer in another related thread:
如果 CTRL+S 对您不起作用是因为根据Vincenzo Pii在另一个相关线程中接受的答案:
The problem is that this binding, in many terminals, is used by default to send the pause transmission code (
XOF
).As in
man stty
:[-]ixon enable XON/XOFF flow control
So, if you have this option enabled on your terminal (the output of
stty -a
containsixon
withouth the-
sign in front), you cannot use CTRL+Sin the context of reverse-i-search.To disable it, use the following command:
stty -ixon
And CTRL+Swill give you a
(i-search)
(non reverse).
问题是这个绑定,在很多终端中,默认是用来发送暂停传输码(
XOF
)的。如
man stty
:[-]ixon enable XON/XOFF flow control
所以,如果你有你的终端上启用这个选项(输出
stty -a
包含ixon
withouth的在-
前面的标志),您不能使用CTRL+S的背景下逆我搜索。要禁用它,请使用以下命令:
stty -ixon
而CTRL+S会给你一个
(i-search)
(非反向)。