Recently someone asked (on IRC) how to move from word to word. This is ⌥← and ⌥→ in all the Mac applications I use, except Terminal.
This prompted me to figure out how to make Terminal do it using those keys.
I have abandoned
bindkey and the likes, as I work with different shells on different servers (via
ssh), and even for my local
zsh I wasn't able to achieve all I wanted with
bindkey (and I'm an all or nothing kind of guy :) ).
The de facto standard in shells is meta b (backward) and meta f (forward) for word movement. Terminal has a Keyboard page in the Terminal Inspector, which can be reached from Terminal → Window Settings… and is depicted below.
To make option left (⌥←) move to previous word you only need to add a new key binding entry like the following:
\033b you need to hit the escape key (which inserts
\033) and then press
You want to do the same for option cursor right. You can also bind control left/right to begin/end of paragraph. The shell keys for these two actions are ⌃A and ⌃E. In the key bindings editor you press ⌃A (control A) and it will insert
\001 as the string value:
Remember to hit the Use Settings as Defaults button when you are done.
Unfortunately there are pretty clear limits to what can be done. E.g. no way to make ⌥⇧← select previous word, and no way to bind actions to the backward delete key (⌫).