The contents of the command history file using history | less
is:
555 ls
556 ls -a
557 echo "hello"
558 echo "hello again"
559 cd
560 pwd
561 echo "hello hello"
562 ls
563 echo "hello hello hello"
564 cd
565 pwd
I want to use reverse i search (reverse-i-search)`echo':
to cycle through only commands in the command history file matching the pattern (i.e. in this case `echo') entered on the command line prompt, preferably until a specified line number in the command history file so that I only select previously used echo
commands that I want to run again not all echo
commands in the command history file
Using reverse i search finds the most recent usage of the command echo
(hence the name reverse i search i.e. reverse searching for a command). However when scrolling forward in reverse order (i.e. reverse searching) bash scrolls through each line of the command history file starting from the line returned by the reverse i search, thus including commands I don't want to search for.
- The reverse i search prompt
(reverse-i-search)`echo':
disappears once you start scrolling through the history list. How do you prevent the reverse i search prompt from disappearing during scrolling so that when you scroll forward in a reverse i search only the commands matching the pattern are shown? - If 1 is possible then how do you temporarily limit the reverse i search to a specific line number in the command history file in order to only select commands from a section of the command history file?
Note: a solution to this question would also be useful for those times when you have several instances of the same command line arguments and reverse i search does not find the one you're looking for