Friday, August 28, 2015

Shell Productivity Hack

I got really sick of iTerm2 (and other terminals) not giving me an easy key-combo to move forward or backward a word at a time; having to hold down the left- or right-arrow key, for what feels like forever, to fix a typo in the middle of a really long one-liner (or a MySQL query, as was often the case) was becoming way too annoying, especially when I do it multiple times a day. So a few months ago I added this little nugget to my ~/.inputrc:

"\e[1;9C": forward-word
"\e[1;9D": backward-word

This lets me press alt-left or alt-right to move word-by-word rather than character-by-character. And now I can't live without it.