Ctrl-R is one of the most useful commands on the terminal and it allows to browse through command history and re-use it again.
On bash shell there is a much simpler way to search through your command history on terminal. Basically you can start typing the initial letter and then use up and down arrow keys to search the history and re-use the command.
histrory-search-* commands enable this fast search of command history. Two of the commands that lets you search command history are
history-search-forward ()
Search forward through the history for the string of characters between the start of the current line and the point. The search string must match at the beginning of a history line. This is a non-incremental search. By default, this command is unbound.history-search-backward ()
Search backward through the history for the string of characters between the start of the current line and the point. The search string must match at the beginning of a history line. This is a non-incremental search. By default, this command is unbound.
Add the following two statements to .inputrc file in your home directory
“\e[A”: history-search-backward # arrow up
“\e[B”: history-search-forward # arrow down
Then you can simply start typing the first few characters of command and then use the up and down arrow keys to go through your previous commands stored in
in your .bash_history that begin with that characters you typed.