ZSH - Advanced History
I have been using oh my zsh for a few years now and did not know about the advanced history feature provided by zsh. I found out about this handy little tip via Command Line Power User by Wes Bos, a free video series about using the command line.
down arrow keys are used in order to cycle through recent commands in the terminal. This is handy but what if you are looking for a specific command that was entered an hour ago perhaps? In this case you would have to press the
up key multiple times until the command you are looking for is found.
For example, lets say an hour ago we fetched some data via the command line from SWAPI using HTTPPie as follows...
An hour passes and you would like to run the same command(s) again, but in the intervening time you may have entered 20 other commands. Instead of pressing the
up key 20 times, you can type part of the command you are looking for and then hit the
up key. For example, type...
Now press the
up key and notice that the last command beginning with
http is loaded for you. Keep pressing
up/down to cycle through recent
Note that you do not have to type the full command
http, you can shorten that to
ht or even
h to get recent commands beginning with those characters.
How did I not accidentally discover that feature? I will be saving myself a few seconds per day now.