source: vendor/bash/3.1/examples/scripts.noah/stty.bash

Last change on this file was 3228, checked in by bird, 18 years ago

bash 3.1

File size: 1.7 KB
Line 
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
6
7# Conversion to bash v2 syntax done by Chet Ramey
8
9# Commentary:
10# Code:
11
12require remap_keybindings
13
14#:docstring stty:
15# Track changes to certain keybindings with stty, and make those changes
16# reflect in bash's readline bindings as well.
17#
18# This requires bash version 1.10 or newer, since previous versions did not
19# implement the `bind' builtin.
20#:end docstring:
21
22###;;;autoload
23function stty ()
24{
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=""
32
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})
38
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"
45
46 # Bind new key to appropriate readline function
47 bind "\"${key}\": ${readline_function}"
48
49 stty_command="${stty_command} ${1} ${2}"
50 shift 2
51 ;;
52 *)
53 stty_command="${stty_command} ${1}"
54 shift
55 ;;
56 esac
57 done
58
59 command stty ${stty_command}
60}
61
62provide stty
63
64# stty.bash ends here
Note: See TracBrowser for help on using the repository browser.