Wednesday, November 28, 2012

ctrl+left/right arrow by inputrc

Suddenly my Ctrl+left arrow and Ctrl+right arrow stopped working for navigating word-by-word and it had become eally annoying. I still dont know the root cause. But I found following :

1. On your console, press Ctrl + v - Ctrl + RightArraow.  It should either print ^[0D or ^[[D.
2. Replace initial "^[" by "\e" and put it in ~/.inputrc as follows

  "\e[D": forward-word

3. Restart session or press Ctrl x - Ctrl r . Confirm binding by

  bind -P

Make sure your "env" has TERM=linux. (Putty -> Connection -> Data -> terminal-type string= linux)

Final ~/.inputrc should look like :

set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
"\e[1~": beginning-of-line # Home key
"\e[4~": end-of-line # End key
"\e[5~": beginning-of-history # PageUp key
"\e[6~": end-of-history # PageDown key
"\e[3~": delete-char # Delete key
"\e[2~": quoted-insert # Insert key
"\eOD": backward-word # Ctrl + Left Arrow key
"\eOC": forward-word # Ctrl + Right Arrow key