I've been annoyed for some time that the extremely handy bash keyboard shortcuts Control-left arrow and Control-right arrow, which move by word in Linux, don't work in Mac OS X. Today I finally got aggravated enough to do some googling, and pieced together the answer.

First, bash normally defines both Control-left arrow and Esc,B as move left one word; likewise both Control-right arrow and Esc,F are defined as move right one word.

The fix is simply to tell Terminal to send Esc and then b when Control-left arrow is typed, and Esc then f for Control-right arrow. I could probably figure out what "[5D" means in Terminal's preferences and configure bash on my Macs to jump by word on that input, but this way I only have to configure 2 Macs, and it works on remote Solaris boxes as well.

Note that bash considers / to be a word delimiter, so these move through paths by directory.

In OS X 10.10 Yosemite I also had to uncheck Control-Left/Right shortcuts in System Preferences: Keyboard: Shortcuts: Mission Control.


Terminal preferences: before

The change

Terminal preferences: changing shortcut


Terminal preferences: after