Mac Equivalent to Windows CMD f8 In Windows if I entered several commands and built up a little history, I could execute previous commands by typing a prefix at the command line and pressing F8 (Windows Keyboard shortcuts) to cycle through all commands in my history matching that prefix. Is there any equivalent in MacOS?



By way of example If I sequentially executed these commands

dir .
echo IgnoreThis
dir /b %TEMP%
dir /s .
dir /b %USERPROFILE%
echo IgnoreThis


If I then entered

dir /bF8

I would first receive an autocompletion to

dir /b %TEMP%


and if I pressed F8 again it would autocomplete to

dir /b %USERPROFILE%


For another example if I instead entered

dirF8

For the first, second, and third times I pressed F8 I would get

dir .
dir /b %TEMP%
dir /s .
Add this to your ~/.inputrc:


# ↑
"\e[A":history-search-backward
# ↓
"\e[B":history-search-forward

# Try to stay at the same the cursor position when moving through the history.
set history-preserve-point on


The way this operation works is you first type your partial command prefix and begin pressing ↑ and ↓ arrows to begin cycling in reverse and forward respectively through the command history matches to your typed prefix.