Quick article on how to search the OSX terminal history
Interactive Search
Start search
Use ctrl
+r
to start the history search and start typing your search term (in my example git
)
(reverse-i-search)`git': git push origin develop |
(reverse-i-search)
indicates that the search mode is activatedgit
is the search termgit push origin develop
is the result
Circle through results
If the first result is not the one you are looking for, continuously press ctrl
+r
Execute the command
Press Enter
to execute the command
or
Press right arrow
to insert the command in the current line
Display search history
In some cases, you might want to display an history of commands containing your search term
You can do this with the following command
$ history | grep 'git' |
Will display of all the previous commands that contain git
.
Note:
The history
command displays the full history of executed commands. In this example, we are piping the result into a grep command in order to filter the results we want.