Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reverse-i-search back and forth? [duplicate]

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?

like image 471
m-ric Avatar asked Sep 29 '22 15:09

m-ric


People also ask

How do I reverse Ctrl R?

u : undo last change (can be repeated to undo preceding commands) Ctrl-r : Redo changes which were undone (undo the undos). Compare to . to repeat a previous change, at the current cursor position. Ctrl-r (hold down Ctrl and press r ) will redo a previously undone change, wherever the change occurred.

How do I cycle through reverse I search?

Activate reverse-i-search using Ctrl+r and then type in a query to find matches. Hit Ctrl+r again to find the next match. Demonstrating reverse-i-search.

What does Ctrl R do in Linux?

Ctrl+R – starts a reverse search, through the bash history, simply type characters that should be unique to the command you want to find in the history. Ctrl+S – launches a forward search, through the bash history. Ctrl+G – quits reverse or forward search, through the bash history.


1 Answers

There is a similar question here:

Control-r reverse-i-search in bash: how do you "reset" the search in Cygwin?

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.

like image 97
gdupont Avatar answered Oct 19 '22 07:10

gdupont