How to reverse-i-search back and forth?
LinuxBashShellSearchLinux Problem Overview
I use reverse-i-search
often, and that's cool. Sometime though when pressing CTRL+r multiple times, I pass the command I am actually looking for. Because CTRL+r searches backward in history, from newest to oldest, I have to:
- 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+g but this is not what I am expecting here. Anyone has an idea?
Linux Solutions
Solution 1 - Linux
There is a similar question here:
Found another similar question on Super User:
Apparently, both mention Ctrl+s, which may do the trick.
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.
Solution 2 - Linux
CTRL + S
...solved it for me AFTER using...
stty -ixon
If CTRL+S doesn't work for you is because according to Vincenzo Pii's accepted answer in another related thread:
> 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
contains ixon
withouth the -
sign in front), you cannot use CTRL+S in the context of reverse-i-search.
> To disable it, use the following command:
> stty -ixon
> And CTRL+S will give you a (i-search)
(non reverse).
Solution 3 - Linux
Try delete
, magically worked.
Others point to CTRL+s, but it doesn't work for me.