Thread View: gnu.bash.bug
2 messages
2 total messages
Started by Martin Farach
Sat, 09 Sep 1989 18:01
Novice question on binding keys
Author: Martin Farach
Date: Sat, 09 Sep 1989 18:01
Date: Sat, 09 Sep 1989 18:01
58 lines
2663 bytes
2663 bytes
Sorry for posting this message on a newsgroup that is set up for bug reporting but I didn't know where else to post. I use tcsh and have my arrow keys set to do the expected things. I just started using bash and I tried getting the same behaviour. I tried the following .inputrc: M-O: prefix-meta M-A: previous-history M-B: next-history M-C: forward-char M-D: backward-char as well as : M-OA: previous-history M-OB: next-history etc. and M-O-A: previous-history and every other combination I could think of. The weird thing is that if I type ESC-O-A manually, I get the behaviour I want. If I hit the up-arrow key, I get an A inserted into the line. Is there a way to get the desired behaviour? (bash-1.03, bison, gcc, sun3, vt100 terminal). Also, can user defined functions be bound to keys? Finally, can key bindings be changed on the fly rather than by changing .inputrc and then starting up a new bash? Thanks for you help. ******************************************************************************* * Martin Farach | * * University of Maryland | * * Department of Computer Science | * * College Park, Maryland 20742 | * * | * * also know as: | * * mpf@brillig.umd.edu | * ******************************************************************************* -- ******************************************************************************* * Martin Farach | * * University of Maryland | * * Department of Computer Science | * * College Park, Maryland 20742 | * * | * * also know as: | * * mpf@brillig.umd.edu | * *******************************************************************************
Re: Novice question on binding keys
Author: Ray Nickson
Date: Wed, 13 Sep 1989 04:36
Date: Wed, 13 Sep 1989 04:36
96 lines
4928 bytes
4928 bytes
From: Martin Farach <mpf@MIMSY.UMD.EDU>
Date: 9 Sep 89 18:01:00 GMT
Sorry for posting this message on a newsgroup that is set up for bug
reporting but I didn't know where else to post.
Hey, don't worry, the rest of us do it all the time.
I use tcsh and have my arrow keys set to do the expected things.
[ ... ] Is there a way to get the desired behaviour? [ ... ]
No, not with the current version.
Also, can user defined functions be bound to keys? Finally, can key
bindings be changed on the fly rather than by changing .inputrc and
then starting up a new bash?
Ditto.
However, I've been doing some hacking... :-)
The version I'm using has hacks in it to do the following:
- readline reads .keymaprc in $HOME (or file specified in KEYMAPRC);
this contains lines of the form
bind <keyseq> <readline_function>
unbind <keyseq>
mbind <keyseq> <macro>
clear
include <file>
<keyseq> is a sequence of characters, with the following special
interpretations:
\C- control
\M- meta
\F- lookup termcap; eg. \F-ku represents the up-arrow key
<readline-function> is the name of a function (previous-line etc)
<macro> is a sequence of characters to dispatch on
<file> is the name of a file to include
- bind, unbind are new shell builtins, for changing bindings on the fly
- extra readline functions:
signal-{stop, quit, interrupt} - send signals
redraw-line - tidy up messy displays
yank-previous-nth-arg - pull words down from history
I have sent my readline hacks to Brian. The code I have written works
in the limited environments I have tried it, but is not at all
well-written, and is certainly not portable, so I'd rather not
generally distribute it. I also haven't got around to slotting it
into 1.03, so it still exists only as 1.02 patches. Anyone care to
comment on the value of these ideas?
/* readline.c -- a general facility for reading lines of input
with emacs style editing and completion. */
/*
* This version of readline has been massively modified by rgn, Ray
* Nickson, nickson@comp.vuw.ac.nz. It is based on the version of
* readline distributed with bash-1.02. It differs from standard readline
* in the following ways:
* 1. I allow keymaps within keymaps; for example, the keymap entry for
* control-X can itself be a keymap, so the user can bind a function
* to control-X control-A.
* 2. I think we should give readline complete control of the
* keyboard. To this end, I save the UNIX terminal driver special
* characters (the tchars, like ERASE, SUSP etc) before going into
* readline, remove their special meaning, and then restore tham
* on exit. To achieve the old behaviour, I supply the readline
* functions `signal-interrupt', `signal-stop' and `signal-quit',
* which the user binds to the keys of her choice.
* 3. I've massively changed the format of (and renamed) the startup
* file (was ~/.inputrc). Read the comment before the
* `rl_read_init_file' for details. I'll supply an
* emacs-lisp program to convert an inputrc to a keymaprc.
* Important extensions allow binding to key sequences (instead of
* just single keystrokes), and the use of termcap names for
* function keys.
* 4. I advertise a function to allow readline's caller to
* interactively change bindings, without knowing about readline's
* internal structure.
* 5. Limited `macro' facility; `mbind keyseq string' in the keymaprc
* causes readline to dispatch on the characters in string when
* keyseq is typed. I advertise a function to the caller for
* interactively doing macro binds.
* 6. It should be possible to add a facility for binding to things
* that have meaning to readline's caller, but not to readline
* itself (such as shell functions) more easily than is the case
* with standard readline.
* 7. I haven't done vi mode; I don't think it would be excessively
* hard to do.
* 8. I haven't tried to make it work with terminfo; what I have
* done has been tried only on systems with termcap or termcap
* emulation.
*/
--
Ray Nickson, Dept. Comp. Sci., Victoria University of Wellington, New Zealand.
nickson@comp.vuw.ac.nz ...!uunet!vuwcomp!nickson + 64 4 721000x8593
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads