Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

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.

share|improve this answer
    
Thx! This works! Thought Ctrl-x Ctrl-e doesn't really do anything – disappearedng Aug 18 '11 at 20:32
    
@disappearedng: Oh, it's Ctrl-X Ctrl-R in fact. :/ – grawity Aug 18 '11 at 20:37

In Terminal in OS X Lion, this works as expected. Otherwise, you might try M-b and M-f (the Meta key might be option or escape depending on your terminal program).

share|improve this answer

You can map Option-Left/Right Arrow to Esc-b/f in Terminal preferences. These will work with bash (the default shell) and any program with Emacs-compatible key bindings.

Terminal > Preferences > Settings > [profile] > Keyboard

Click the plus button to add a new mapping:

Key: cursor left
Modifier: option
Action: send string to shell
String: \033b

(Type the Esc key to enter "\033".)

Then add another mapping for "cursor right" to "\033f".

As of Mac OS X Lion 10.7, Terminal's default keyboard map includes these two entries so there's no need to do this.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .