How do I configure Ctrl-Left and Ctrl-Right as previous/next word shortcuts for bash (currently alt-b and alt-f)?
The correct answer depends on which terminal you are using.
For Gnome Terminal or recent versions of xterm, put this in ~/.inputrc:
For PuTTY, put this in your ~/.inputrc:
For rxvt, put this in your ~/.inputrc:
You can probably get away with putting all of those together in ~/.inputrc.
In all cases, you also need to put this in your ~/.bashrc (or ~/.zshrc):
If that doesn't work, or you have a different terminal, go to your terminal and type Ctrl+V Ctrl+->. Then use that instead of
Note that you need to write the keyboard escape sequences using the inputrc syntax, e.g.
|show 7 more comments|
If you're using ZSH, you need to take a different method, because, quoting the relevant parts from ArchLinux's ZSH guide:
After reading that guide, I figured I need a modren source of ZSH to get the general idea of how to do this from, and so I found this oh-my-zsh file which describes the behaviour I wanted, I copied the relevant parts I wanted into my ~/.zshrc: