- history | grep command-name
- Press ctrl + r -> type the command.
I hope everyone is aware that hitting the arrow keys helps us navigate to recently executed commands but what if you forgot a command you used months before and want to use it now or view all the commands you used relating to git or docker. We will see three commands I often use to achieve this.
Using this will list all the commands you have executed.
Execute a command from History
To execute any one of the commands from the list type
history | grep
This is just the previous one but we are using the grep to filter the list.
Example, if you want to see only the commands related to docker, you would type
history | grep docker
ctrl + r ->
Press ctrl + r and start typing the command you knew you have executed months before. The terminal will autocomplete the command.
Example if you haven't used
ssh for sometime and feel lazy about looking the history, you could press ctrl + R and type ssh The terminal will autocomplete with your recent ssh command.
I have used ctrl + r then typed heroku. The terminal autocompleted with my most recent heroku command
Top comments (1)
The evolution of
reverse lookupis FZF (works with regex and more):
FZF - Command Line Fuzzy Finder