Linux – Bash – Skip Words using Control Key
If you are reading this, chances are you are trying to navigate a long string in a bash shell using the arrow keys, which by default, skip 1 letter at a time. However, you can make a few simple changes and bind your control key so when you press control and left or right arrow key you will skip entire words (vs letters) making it much faster to traverse long strings. This will also apply to your mysql command line interface which makes it much easier to jump around in long sql queries.
You can add the capability to skip entire words in one of two ways:
/etc/inputrc
Add the following lines to your /etc/inputrc file:
“\eOD”: backward-word
“\eOC”: forward-word
~/.inputrc
Exactly the same as adding to the /etc/inputrc but will only affect the user’s bash environment vs making a global change to everyone’s bash environment. Add the following lines to your ~/.inputrc file:
“\eOD”: backward-word
“\eOC”: forward-word
For any of the above changes to work you will have to restart your session, I tried to source the files and didn’t work until I logged out/in.
