This is about assigning keys right, especially the well known [CTRL]+[left arrow] to move the cursor back one word. Looking for this I spent lots of time reading this outstanding page and others. But none of them kept these information as short as possible and that is what I am going to try here. Notice that this is not shell independent, so that we need to individually setup this.
First off to find a keys corresponding keycode (which you need for any config) there are several possibilities:
- Press [CTRL]+V
- use the
Both of which will return something like
^[[1;5D to you.
- bash relies on a package called
readline, which uses
~/.inputrcas configuration file:
bind -llets one look up which commands are available
bind -f .inputrcwill load your new configuration
csh and tcsh
- look up an action, which the shell should perform, when you press this key combination with
. I found vi-word-fwd and vi-word-back useful.
- open your
~/.cshrcand append things you looked up this way with e.g.
~/.cshrc1234bindkey "^[[1;5C" vi-word-fwd # CTRL+RIGHTbindkey "^[[1;5D" vi-word-back # CTRL+LEFTbindkey "^[[1;3C" vi-word-fwd # ALT+RIGHTbindkey "^[[1;3D" vi-word-back # ALT+LEFT
- restart your csh
reset says ‘Erase is backspace.’
When you got this and you try to remove chars by hitting backspace, chances are that you won’t remove chars, but actually insert something like
?^. That can easily be fixed:
stty erase '^?'
Why the heck do both
CTRL+_ will undo changes in GNU readline.
The plain old sh under FreeBSD uses
libedit instead of
readline. Its configuration file is called
editrc and a man page
man editrc exists. It also supports a
bind command, but with a slightly different syntax. That bind can be used in a
.profile file to reduce the number of required configuration files.
bind ';5C' vi-next-big-word
bind ';5D' vi-prev-big-word