How to reverse-i-search back and forth?

LinuxBashShellSearch

Linux 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:

  1. cancel,
  2. search again and
  3. 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:

https://stackoverflow.com/questions/549810/control-r-reverse-i-search-in-cygwin-bash-how-do-you-reset-the-search

Found another similar question on Super User:

(reverse-i-search) in Bash

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionm-ricView Question on Stackoverflow
Solution 1 - LinuxgdupontView Answer on Stackoverflow
Solution 2 - LinuxBringBackCommodore64View Answer on Stackoverflow
Solution 3 - Linuxadvisor21View Answer on Stackoverflow