Wednesday, July 9, 2008

Searching your command line history (ctrl+r)

Recently, Warren showed me a trick that has saved me a ton of time. I frequently use Unix/Linux/Mac Terminal and there are some commands that I execute frequently - ssh connections to various servers, etc. I usually just hit the up arrow on my keyboard until the command that I want appears. Sometimes this is completely nonsensical because I find myself pressing the up key more times then there are characters in the command I want to execute!

But, Warren recently told me about using the Ctrl+R key combination to search my command history. It does a "reverse search" of the commands you have recently executed. So, for example, let's say you have recently executed the command "ssh" If, at the prompt, you hit ctrl+r and start typing "ssh...," it will auto-complete the rest of the command and you can just hit enter to execute it.

Anyway, if you use the command prompt a lot, I highly recommend this shortcut.


No comments: