Control-arrow CLI navigation in iTerm2

Every time I set up a new Mac, I always forget how to make control-left and control-right work in remote Linux shells opened via iTerm2. If you don’t care about the built-in Mission Control shortcuts “Move left a space” and “Move right a space”, here’s how you do it. These instructions are for Sierra (10.12).

Open System Preferences and select “Keyboard”. Click on the “Shortcuts” button. Make sure “Mission Control” is selected in the left-hand pane. In the right-hand pane, uncheck “Move left a space” and “Move right a space”.

At this point, control-left and control-right should work in your remote sessions should work. But it won’t work for local shells. You’ll see “;5D” or “;5C” when you hit those key combinations. So you need to take one more step. Add this to ~/.inputrc:

Close all your iTerm2 windows. When you open new ones, control-left and control-right should work as expected.

Leave a Reply

Your email address will not be published. Required fields are marked *