Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reset bash history search position

In a terminal the Bash history can be searched easily with Ctrl+r. But what if I cannot find what I am looking for? I am stuck in the middle of my history. What if a want to search again from the beginning?

Is there another shortcut to reset the history search?

like image 727
NaN Avatar asked Jan 14 '16 15:01

NaN


2 Answers

There is Meta + >, which is bound to end-of-history and useful if you're in the middle of your history. The meta key is usually the Alt key.

If you see that your incremental history search isn't successful, you can use Ctrl + G, which is bound to abort and restores the previous line and history position.

Check the manual for more commands like these.

like image 92
Benjamin W. Avatar answered Oct 25 '22 13:10

Benjamin W.


This may be a somewhat indirect answer, but I usually use Ctrl+c to exit the history search. This cancels your entire line entry, leaving you on a fresh prompt with no input on the line, and back at the end of the history list.

like image 36
user3035772 Avatar answered Oct 25 '22 12:10

user3035772