Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.unix.questions Subject: Re: Defining function keys Message-ID: <9991@smoke.BRL.MIL> Date: 5 Apr 89 21:55:42 GMT References: <1869@umbc3.UMBC.EDU> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 22 In article <1869@umbc3.UMBC.EDU> rostamia@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 $*); }