With emacs bindings:
Meta-B moves back a word and Meta-F moves forward a word.
Ctrl-B moved back a character and Ctrl-F moves forward a character.
So B vs F is backwards vs forward and Meta vs Ctrl is word vs character.
The exact mapping of Meta may vary between keyboards. Try holding down Alt while pressing the other key; if that doesn't work, press and release Esc and then press the other key.
OS X uses emacs key binding my default. This is true is virtually every application on OS X, it's rather nice. It means things like C-a and C-e are beginning/end of line. You also get the nifty backward-word-kill with M-backspace, oh, and kill-line with C-k.
This should mean that in your terminal forward/backward-word are bound to M-f and M-b, respectively (M = Meta = alt/option), however that is not the case. On OS X forward/backword-word are bound to M-→ and M-← by default.
You can alter this behavior by changing how the GNU Readline Library is configured for your account. This takes place in your ~/.inputrc
file. You can get a big list of bindable commands with man readline
as well as in the online documentation like this here..
So to answer your question, you want to remap what Readline does when it sees C-→ and C-← to do what it does on your linux server.
The syntax for a ~/.inputrc
file is pretty simple for what you want to do: key-sequence: action
.
This should be what you need to get the desired behavior:
"\e[5C": forward-word
"\e[5D": backward-word
Here's another page with additional useful bindings.
(You could probably get away with copying /etc/inputrc from your linux box to your OS X ~/.inputrc)
Best Answer
Add these two lines to your
~/.inputrc
file on the destination machine:To make sure that they are the correct sequences, at a Bash prompt, type Ctrl-V Ctrl-LeftArrow and Ctrl-V Ctrl-RightArrow, you should see:
When you start a new session, the keys will be available or you can press Ctrl-xCtrl-r to re-read the
~/.inputrc
file for the current session.