Searching your command history on macOS terminal

Aipi picture Aipi · Jan 21, 2017 · Viewed 53.3k times · Source

What is the shortcut to search my command history in macOS terminal?

For how long is the history available for searching? Where is it stored?

Answer

Inian picture Inian · Jan 21, 2017

How about using Ctrl+R for searching on the Terminal Utility in Mac for searching on the command history,

dudeOnMac: freddy$ whoami
freddy
(reverse-i-search)`who': whoami

Well for controlling how long the history would be retained that depends on a few shell environment variables, HISTFILESIZE which is nothing but number of lines of history you want to retain. Set a huge value for it in .bash_profile for it to take effect

HISTFILESIZE=10000000