Defining function keys

Doug Gwyn gwyn at smoke.BRL.MIL
Thu Apr 6 07:55:42 AEST 1989


In article <1869 at umbc3.UMBC.EDU> rostamia at umbc3.UMBC.EDU (Rouben Rostamian) writes:
>Is there a way to define function keys to execute certain commands in UNIX?

Not normally, because all the UNIX terminal handler sees is a sequence of
ASCII codes starting with ESC, and it cannot assume that the sender of
those codes conforms to X3.64.  DEC's OS, on the other hand, has long
fully supported only DEC terminals, so their characteristics are known.
(I haven't looked at VMS recently to see if this situation has changed.)

There are some shells that have the capability of mapping escape sequences
into user-defined replacements, and many visual editors support that also.
Sometimes you can use this to map whole escape sequences (perhaps via a
series of partial mappings).

A more usual way to "package" your favorite functions on UNIX is to
define "aliases" (csh) or "shell functions" (SVR2 or later sh) or "shell
scripts" (any sh) with 1- or 2-character names that perform more elaborate
actions.  Since shell functions and scripts accept arguments they're more
general than a straight function key escape-sequence mapping.  For example,
I automatically set up my interactive SVR2-based shell so that I have an
"l" command defined:
	l(){ (set +u; exec ls -bCF $*); }



More information about the Comp.unix.questions mailing list