Sometimes I want to search for a previously executed command in my console.

So I press Ctrl + R and I enter in (reverse-i-search) mode. I start typing my command and I press Ctrl + R again and again to cycle through all previous commands that match the input text.

However after doing that, if I press the up or down keys I see the commands I executed long time ago, just before of after the command I just searched.

Looks like the command history "jumped" to the searched command.

My question: Is there a way of restoring my command history to the latest one, so when I press up I should see the latest commands I executed? I don't want my up and down keys to show me what I executed back then, but rather the latest commands I introduced.

I can keep my down key pressed for a while until I reach the last command, but I'm sure it must be a better way.

Press CtrlC to cancel input, and you'll get back to the present.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.