Wednesday, November 6, 2013

My Favorite Shell Productivity Hack

This is, by far, my favorite productivity hack for Linux shells, which I stole from a guy I used to work with. In ~/.inputrc :

"\e[A": history-search-backward
"\e[B": history-search-forward

That's it.

What does it do? Well, remember a few hours ago when you scp'd a file from/to some server, but either can't remember or just can't be bothered typing out the full command again? Type, 'scp ' in your shell and start pressing your up arrow and it'll go through all of your past uses of scp. You could just type 'history | grep scp', but when you get used to this hack, you'll start using it all the time.

As a bonus, it also works in, for example, your command-line MySQL client too. And anything else that keeps a command history.