Backspace/Del/Home/End key mapping fixes

I got very annoyed for a long time about how rubbish the Linux mappings are for the backspace, delete, home and end keys: moving between different machines I often find that their behaviour is mixed up or that they simply don't work, resulting in tildes appearing on the command line when you really don't want them to. Hence I've got a fix for this behaviour in bash. I used to have one for tcsh as well, but since I don't use it anymore it would seem unwise for me to advertise it :-)

My fixes are quite specific to what I consider normal behaviour: backspace removes the character to the left of the cursor, delete removes the character under the cursor and home/end jump the cursor to the start and end of the line respectively. To achieve this, insert the following into either your /etc/inputrc or ~/.inputrc (or $INPUTRC) file:

"\e[1~": beginning-of-line "\e[4~": end-of-line "\e[5~": beginning-of-history "\e[6~": end-of-history "\e[3~": delete-char

It's also really worth looking at the readline man page — this is the library that bash uses to read the command line and is very customisable. The man page is actually quite clear as well, which is sadly a rare thing (in particular the sed man page is the benchmark for unhelpfulness as far as I'm concerned). For playing around with readline configs, a useful thing is to use the C-x C-r binding to refresh the config. It doesn't seem to unset test bindings, though, so sometimes a re-login is required.

The other thing I learned from this was that readline doesn't distinguish between <Cursor key> and Control-<Cursor key>, which I would like to be the back/forward-word bindings. Oh well :-)