Instantly search your terminal history with a keyboard shortcut

Contents

Everyone who uses the command line regularly has at least one long string that they write regularly. Instead of entering all of that over and over again, quickly search your history to find the complete command.

RELATED: 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 may not know regarding the built-in search functionality, which enables you to quickly find the last command you typed using any character string. And it is 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 most recent command will appear to include the characters you typed.

Include as much detail as necessary until what you are looking for appears. When i do, press Enter and the command will run instantly.

Yes, could have found a more useful example, but you already have the idea: presiona Ctrl + R, type until you see a match then hit Enter.

Screenshots don't show how fast this all works, therefore here is a GIF in which I appear a common command with only a few keys:

Keep this keyboard shortcut handy if there are some long commands that you type regularly, because it is a huge time saver.

RELATED: How to delete terminal history on Linux or macOS

Ah, And if you are concerned that someone else will stumble upon some embarrassing command, you can delete your Terminal history. I will not tell anybody.

Subscribe to our Newsletter

We will not send you SPAM mail. We hate it as much as you.