shell’s keyboard mapping

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 read command

Both of which will return something like ^[[1;5D to you.

bash

  • bash relies on a package called readline, which uses ~/.inputrc as configuration file:
  • bind -l lets one look up which commands are available
  • bind -f .inputrc will 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 ~/.cshrc and append things you looked up this way with e.g.
  • 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:

investigation pending

Why the heck do both ^- and ^/ return ^_? Btw: CTRL+_ will undo changes in GNU readline.

sh

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.

max,