In order to redeem myself for neglecting my blog, here’s a quick productivity tip for Bash. I’ve been using this for the past few months, and every time I log on to a server that doesn’t have this, I wonder how I ever functioned on the command line.
It’s 6 simple lines in ~/.inputrc:
# change up/down arrows to be search "\e[A": history-search-backward "\e[B": history-search-forward "\e[C": forward-char "\e[D": backward-char set show-all-if-ambiguous on set completion-ignore-case on
All it does is change the arrow keys to become command history search. So now, if I type se and hit up, instead of getting the previous command I had run, I get service httpd restart. Or svn c which gets me svn commit -F ../whatidid.txt.
This is especially helpful for toggling back and forth between commands. Usually when toggling between two or three commands, they inevitably get out of sync – hitting the up arrow twice brings you to the wrong command, and you have to consciously look for it. Now, the first character of each command guarantees you the right one.
Could I use aliases for all of these? I most certainly could. But with this simple .inputrc change, I don't even think about aliases anymore. Like all .inputrc directives, it also works for the MySQL command line client and other readline-derived prompts.
If you use the command line like I do, this will likely save what feels like hours of your life.
Recent Comments