An Even Better Way to Search Your Command Line History

[Linux / Mac] I have shown you previously how you can do a search in the terminal using the shortcut “Ctrl + r”, here is an even better way to help you search your command line history.

1. Open a text editor and paste the following lines to it:

"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on

2. Save the file as “.inputrc” (don’t forget to include the dot at the beginning) in your Home folder.

3. Now open your terminal. You can type a few characters and use the Up/Down arrow to search the history that begin with the typed character. For example, if you type “cd /” and press the Up arrow button, it will search your history for commands that start with “cd /“.

Note: If you are using zsh, this feature is already included and you can use it without any modification.

Do you like what you read here?

Receive the latest update in your inbox.

Or connect with us: