shortcutsguide

Reverse Search Command History (Ctrl+R)

Press Ctrl+R and start typing to search backwards through your command history; press Ctrl+R again to cycle older matches. Works the same in bash and zsh on Mac, Linux and WSL.

ActionMacWindows
Reverse history search Ctrl+R Ctrl+R
Next (older) match Ctrl+R again Ctrl+R again
Forward history search Ctrl+S Ctrl+S
Accept and run match Enter Enter
Accept match to edit → / Esc → / Esc
Cancel search Ctrl+G Ctrl+G

Search what you typed before

Press Ctrl+R in a readline shell and type a few letters of an old command — the most recent match appears inline. Press Ctrl+R again to step to the next-older match. Hit Enter to run it, or → / Esc to drop it onto the prompt for editing. This is identical on macOS Terminal, Linux and Windows WSL / Git Bash.

Forward search and cancel

Forward search is Ctrl+S, but it is often swallowed by terminal flow-control (XOFF). Run stty -ixon in your shell profile to free it up. To bail out of a search without running anything, press Ctrl+G — the prompt returns untouched.

Better history in zsh and fzf

In zsh the same Ctrl+R works. If you install fzf, it rebinds Ctrl+R to a fuzzy, full-screen history picker — the key stays the same, only the UI improves.

FAQ

How do I search my command history in the terminal?

Press Ctrl+R and type part of an old command. The newest match appears; press Ctrl+R again for older matches, Enter to run it.

How do I exit Ctrl+R search without running the command?

Press Ctrl+G to cancel the reverse search and return to an empty prompt, or Ctrl+C.

Why doesn't Ctrl+S forward-search work?

Ctrl+S is often captured by terminal flow control. Add stty -ixon to your shell profile to enable forward history search.

Does Ctrl+R work the same on Mac and Windows?

Yes. In bash/zsh on macOS Terminal and in WSL/Git Bash on Windows, Ctrl+R is the readline reverse-history search.