The Most Useful Command Line Tool


2013-06-09

Many would argue that there is no command line tool to rule them all, but I disagree. There is one that will make using the command line orders of magnitude easier to use, and that is the bash shell's reverse history search. To use it, just press ctrl+r and start typing a part of any command you have used before:

(reverse-i-search)`comm': git commit -am "daily" && git push

In the example above, I have pressed ctrl+r and typed comm. The reverse search utility has populated my line with the last command I entered that had comm in it. This means once you have entered a command, you don't have to remember exactly what it was, but just a part of it. Then you can use reverse history search to find it.

If I wanted to use this command again as-is, I could press enter. If I want to edit the command before using it, I can use the horizontal arrow keys or the escape key to exit the history search while keeping the command ready for changing or hitting enter.

You can also press ctrl+r multiple times to continue back through your history to earlier commands containing what you the string for which you are searching.

This is the one utility that has saved me more time than any other when it comes to working with the command line.