Search code examples
bashkeyboard-shortcutsputty

Putty / Bash alt + left/right arrow key to move cursor by word


I can't get this putty to handle alt + left/right properly.

(Edit: By "properly", I obviously mean the way I have grown used to moving the cursor about;-)

Usually I can do:

cat > /dev/null
..<hold alt and left arrow>..

to get the proper key. In this case I get: ^[^[[D

I then proceed to do:

bind '^[^[[D:backward-word'

I've also tried:

bind '\e\e[D:backward-word'

Please note that this problem is the same in screen (with TERM=screen) and outside of screen (with TERM=xterm).

Any tips on what I should try next? Any putty options that need to be enabled/disabled?


Solution

  • This format of bind doesn't work for me either for some reason, but I've had success with bind -f.

    ~/.bashrc:

    if [ -f ~/.readline-bindings ] ; then
        bind -f ~/.readline-bindings
    fi
    

    ~/.readline-bindings:

    "\e[1;3D": backward-word
    "\e[1;3C": forward-word
    

    Note the space after the : character. Obviously you should use your own control sequence here.