I spend a lot of my time in command line and analyzing what I am doing, I realized I could gain a lot if I could spend less time ‘driving’ cursor arround. Unlike other productivity enhancements I did, this one turned out to be a little more challenging, which is why I am writing this post.
First, to my surprise, there was not obvious and easy way to just go word back and forth. If you look at what is available for command line, aside from ctrl-a, ctrl-e, there is not much more. Since terminal is OSX is using emacs style bindings, I went to look for how would I do this in emacs. Unfortunatelly specific one that would let you quickly jump from word to word is not working. There is really awkward Esc – b, Esc – f, to go back and forward a word.
So my first glimpse on a solution was to do:
set -o vi
and convert command line to vi bindings. This works not surprisingly well, command line is treated like in edit mode, you just have to hit esc and then you can back and forth all you want. Problem for me with this is that, while I will configure my machine, this will just make hard for me to work on other people machines, like when we pair. So, even though I am still considering this solution, I kept researching.
What I found as solution, which probably works out of the box on Linux, is that you can remap alt to simulate hitting Esc, so that you can use alt – b and alt – f to go back and forth. Setting for this is a little burried in preferences, which is why I included screenshot.