Instantly search your terminal history with a keyboard shortcut

Anyone who regularly uses the command line has at least one long string of characters that they periodically enter. Instead of typing all of that over and over, quickly search your history to find the full command.

Here’s how to use your bash history in the Linux or macOS terminal

Even if you know how to use your bash history in the Linux or macOS terminal, you might not be aware of the built-in search feature that can help you quickly find the latest command you’ve entered with any string of characters. And it’s easy to use: just open your terminal on macOS or Linux.

Now press Ctrl + R; you’ll see (reverse-i-search).

Just start typing: the final command to insert the characters you typed will appear.

Add as much detail as necessary until exactly what you are looking for comes up. If so, press Enter and the command is executed immediately.

Yes, I could have found a more useful one examplebut you get the idea: press Ctrl + R, tap until you see a match, then press Enter.

Screenshots don’t make it clear how fast it all works, so here’s a GIF from me in which I call up a common command with just a few keystrokes:

Keep this keyboard shortcut handy if you type a few long commands on a regular basis as it is a huge time saver.

How to delete terminal history on Linux or macOS

Oh, and if you’re worried about someone stumbling over embarrassing commands, you can clear your terminal history. I won’t tell anyone.

Related Posts