Just type something (optional), then press up/down arrow key to search through history for commands that begin with what you typed. inputrc to bind the up/down arrow key to history-search-backward and history-search-forward: # Key bindings, up/down arrow searches through history "\e[A": history-search-backward "\e[B": history-search-forward "\eOA": history-search-backward "\eOB": history-search-forward If you like to be super lazy you can bind the up/down arrow keys to perform this search, I have the following in my. By pressing ctrl+ R again (and again) you can cycle through the history. Now start typing your command, this will give the first match. Pressing ctrl+ R will open the history-search-backward. Migrating an answer to SO from this answer on the Unix and Linux Stack Exchange: PS: This answer is same as suggested by Inian, just giving more details for easy usage. If you want to exit without running any command, press Ctrl + G Once you found your command press Return to execute it. If that is not the command you were searching for, keep pressing Ctrl + R for next match until you find your command. It will return the latest command that matches your input. grep (reverse-i-search)`grep': grep "XYZ" abc.txt Type any substring of the command you want to search e.g. Use Ctrl + R for searching a command from history in Terminal. bash_profile for it to take effect HISTFILESIZE=10000000 ctrl+ Rshows the last, but hitting ctrl+ Rmultiple times will give you the matches before it. 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.
#Mac terminal commands history mac#
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 What is the shortcut to search my command history in macOS terminal?įor how long is the history available for searching? Where is it stored?