Last Updated: February 25, 2016
·
1.97K
· eallam

Reverse search your bash history

You know in your shell how you can hit the up arrow and cycle back through your old submitted commands? You can also get a list of your shell history using the history command, like so:

$ history
1  gs
..snip a bunch of lines..
814  heroku ps
815  heroku ps:scale worker=1
816  gs
817  history

Combine that with grep to search for past commands:

history | grep heroku

Or you can just hit CTRL-r and start typing to search and then hit Return to run the intended command:

Picture

1 Response
Add your response

Alternatively you could place in your ~/.inputrc the lines

"\e[A": history-search-backward

"\e[B": history-search-forward

This way you can type a partial command and press arrow keys to go through your history.

over 1 year ago ·