Mac ;9D and ;9C from alt-left and alt-right

macterminal

I am very used to using alt-left to go to the word before (if you use vim, that's 'b') and alt-right to go to the beginning of the next word.

On Mac terminal however (iterm and iterm2), I am getting ;9D and ;9C respectively. I can use fn+left to go the beginning of the line but I still find that really inconvenient.

Any ideas how to fix this?

Best Answer

If you are using the bash shell, add the following to your ~/.inputrc:

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

Press Ctrl-X, Ctrl-R or restart the shell to apply changes.


Note: Part of the escape sequences above, specifically the 1, I had to guess based on what Xterm uses.

Related Question