2 # Author: Noah Friedman <friedman@prep.ai.mit.edu>
4 # Last modified: 1993-09-29
7 # Conversion to bash v2 syntax done by Chet Ramey
12 require remap_keybindings
15 # Track changes to certain keybindings with stty, and make those changes
16 # reflect in bash's readline bindings as well.
18 # This requires bash version 1.10 or newer, since previous versions did not
19 # implement the `bind' builtin.
25 local erase
="backward-delete-char"
26 local kill="unix-line-discard"
27 local werase
="backward-kill-word"
28 local lnext
="quoted-insert"
29 local readline_function
=""
33 while [ $# -gt 0 ]; do
35 erase |
kill | werase | lnext
)
36 key
=$
(echo "${2}" |
cat -v |
sed 's/\^/\\C-/')
37 readline_function
=$
(eval echo \$
${1})
39 # Get rid of any current bindings; the whole point of this
40 # function is to make the distinction between readline
41 # bindings and particular cbreak characters transparent; old
42 # readline keybindings shouldn't hang around.
43 # could use bind -r here instead of binding to self-insert
44 remap_keybindings
"${readline_function}" "self-insert"
46 # Bind new key to appropriate readline function
47 bind "\"${key}\": ${readline_function}"
49 stty_command
="${stty_command} ${1} ${2}"
53 stty_command
="${stty_command} ${1}"
59 command stty
${stty_command}