Added gitignore entries needed to ignore derived objects generated from full build...
[bash.git] / examples / scripts.noah / stty.bash
blob611d970f8a1316861636ae82d048e8b4188f7829
1 # stty.bash
2 # Author: Noah Friedman <friedman@prep.ai.mit.edu>
3 # Created: 1992-01-11
4 # Last modified: 1993-09-29
5 # Public domain
7 # Conversion to bash v2 syntax done by Chet Ramey
9 # Commentary:
10 # Code:
12 require remap_keybindings
14 #:docstring stty:
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.
20 #:end docstring:
22 ###;;;autoload
23 function stty ()
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=""
30 local key=""
31 local stty_command=""
33 while [ $# -gt 0 ]; do
34 case "$1" in
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}"
50 shift 2
53 stty_command="${stty_command} ${1}"
54 shift
56 esac
57 done
59 command stty ${stty_command}
62 provide stty
64 # stty.bash ends here