I ran into a situation where I want to backspace
quickly in bash (maybe good for my speed and typing?). While I could increase my keyboard typematic rate,
I looked into Gnu Readline as I've been on bash kick recently ;).
The default use of emacs chorded keybindings pisses me off a bit because an emacs-fluent user would just
guess ("Hmm. I wonder if I can undo that type-o with a C-xC-u") and they'd be right. While I could
switch to vi-mode, I found it was easier to support a few non-chorded mappings that I want. Especially
after I realized that readline has a edit-and-execute-command hook that allows you to edit the current
command via your $EDITOR.
UPDATE: I found it instructive to examine the current bindings, i.e.
bind -m vi-command -P
bind -m vi-insert -P
and to override/revert as I see fit. So, errr, cover your eyes if you're a purist. ;)
# enable vi and then start overriding it ;)
set editing-mode vi
# automatically expand history references, e.g. !$ and tildes
Space: magic-space
$if Bash
set expand-tilde
$endif
# tab completion
set completion-ignore-case on
set show-all-if-ambiguous on
set completion-query-items 20
set match-hidden-files off
# http://haell.com/~wyrm/works/comp/sw/libs/readline/inputrc.emacs-standard.functions
$if mode=vi
# override any insert keymappings
set keymap vi-insert
# backspace boot party on words and unix filenames
# (at some point unix-rubout-filename will work)
"\C-xT": backward-delete-char
"\C-xt": kill-word
"\C-xP": character-search
"\C-xO": backward-word
"\C-h": "\C-xO\C-xP/\C-xP/\C-xP/\C-xP/\C-xP/\C-xP/\C-xT\C-xt"
# override any command keymappings
set keymap vi-command
#backward-char can be found on "\C-h", "\M-OD", "\M-[D", "h".
"H":vi-prev-word
#beginning-of-line can be found on "\M-OH", "\M-[H", "0".
"0":
#clear-screen can be found on "\C-l".
#delete-char can be found on "\M-[3~".
#end-of-line can be found on "\M-OF", "\M-[F", "$".
#forward-char can be found on "\M-OC", "\M-[C", " ", "l".
"L":vi-next-word
"l":forward-char
#forward-search-history can be found on "\C-s".
#insert-comment can be found on "#".
#kill-line can be found on "\C-k".
#next-history can be found on "\C-n", "\M-OB", "\M-[B", "+", "j".
"+":
#previous-history can be found on "\C-p", "\M-OA", "\M-[A", "-", "k".
"-":
#quoted-insert can be found on "\C-q", "\C-v".
#reverse-search-history can be found on "\C-r".
"!":reverse-search-history
#revert-line can be found on "U".
"U":
#transpose-chars can be found on "\C-t".
#unix-line-discard can be found on "\C-u".
#unix-word-rubout can be found on "\C-w".
#vi-append-eol can be found on "A".
#vi-append-mode can be found on "a".
#vi-arg-digit can be found on "1", "2", "3", "4", "5", ...
#vi-change-case can be found on "~".
#vi-change-char can be found on "r".
#vi-change-to can be found on "C", "c".
# instead we'll use it to upcase/downcase a word
"\C-xP": upcase-word
"\C-xp": downcase-word
"C": "H\C-xPL"
"c": "H\C-xpL"
#vi-char-search can be found on ",", ";", "F", "T", "f", ...
",":
";":
"F":
"f":
"T":
#vi-column can be found on "|".
#vi-delete can be found on "x".
#vi-delete-to can be found on "D", "d".
#vi-end-word can be found on "E", "e".
"e":edit-and-execute-command
#vi-eof-maybe can be found on "\C-d".
#vi-fetch-history can be found on "G".
"G":
#vi-first-print can be found on "^".
"^":vi-first-print
#vi-goto-mark can be found on "`".
#vi-insert-beg can be found on "I".
#vi-insertion-mode can be found on "i".
#vi-match can be found on "%".
#vi-next-word can be found on "W", "w".
"w":
"W":
#vi-prev-word can be found on "B", "b".
"b":
"B":
#vi-put can be found on "P", "p".
#vi-redo can be found on ".".
#vi-replace can be found on "R".
#vi-rubout can be found on "X".
"X":
#vi-search can be found on "/", "?".
"/":character-search
"?":reverse-search-history
#vi-search-again can be found on "N", "n".
#vi-set-mark can be found on "m".
#vi-subst can be found on "S", "s".
"S":
"s":
#vi-tilde-expand can be found on "&".
"&":
#vi-yank-arg can be found on "_".
#vi-yank-to can be found on "Y", "y".
#yank can be found on "\C-y".
$endif