Bash shell trick: searching interactively through command history

Mon, Dec 9

Although the up/down arrow are nice to move through commands in a Bash shell, searching takes the command history to a whole new level.

To start a search within Bash, enter Control-R, the prompt will then change to look as follows:


As you type, matches will be shown, with the cursor directly on the character where the match occurs.

– Hit enter to run the command as is
– Hit Command-R to find more matches
– Type (or delete) characters to refine search
– Type left or right arrow key to edit command (before running)