[comp.unix.shell] Use of function keys for common comands at the ksh prompt.

afc@shibaya.lonestar.org (Augustine Cano) (02/18/91)

I would like to use my function keys (F1-F8) to save keystrokes.
My keyboard generates "ESC O c-j" for F1-F8 respectively.  The ideal
solution is of course to have a separate ksh function that responds
to the escape sequence of each individual function key, whose content
would execute the desired command(s).  The problem is that ksh doesn't
like the leading escape.  This makes sense since ESC is used in the vi
editing mode.

Is there a way to use the escape sequences generated by the function keys
as function names?  Alternatively, is there another way to accomplish
the same thimg? (at the ksh level, of course; I know the keyboard driver
could be modified, but this is not an option.)  Other programs use
the function keys for other purposes, so these definitions should only
work at the ksh prompt.

Any solutions/hints would be most welcome.  I'll summarize e-mail responses.
Thanks

-- 
Augustine Cano		INTERNET: afc@shibaya.lonestar.org
			UUCP:     ...!{ernest,egsner}!shibaya!afc

mvadh@cbnews.att.com (andrew.d.hay) (02/19/91)

In article <1991Feb17.235721.20854@shibaya.lonestar.org> afc@shibaya.lonestar.org (Augustine Cano) writes:
[]
"Is there a way to use the escape sequences generated by the function keys
"as function names?  Alternatively, is there another way to accomplish
"the same thimg? (at the ksh level, of course; I know the keyboard driver
"could be modified, but this is not an option.)

nope, you're SOL.  strings that begin with ^[ are either syntax errors
or invalid alias names.

-- 
Andrew Hay		+------------------------------------------------------+
Ragged Individualist	| 			JAAAAAAANE!		       |
AT&T-BL Ward Hill MA	|	    HOW DO YOU STOP THIS CRAZY THING?	       |
a.d.hay@att.com		+------------------------------------------------------+

asg@sage.cc.purdue.edu (The Grand Master) (02/20/91)

In article <1991Feb17.235721.20854@shibaya.lonestar.org> afc@shibaya.lonestar.org (Augustine Cano) writes:
%I would like to use my function keys (F1-F8) to save keystrokes.
%My keyboard generates "ESC O c-j" for F1-F8 respectively.  The ideal
%Any solutions/hints would be most welcome.  I'll summarize e-mail responses.
%Thanks
%Augustine Cano		INTERNET: afc@shibaya.lonestar.org


 Try bash or tcsh (if you are used to ksh, bash would be your best choice
because they are more similar).
		The Grand Master
		  Bruce Varney

wjc@hos1cad.ATT.COM (Bill Carpenter) (02/20/91)

mvadh> nope, you're SOL.  strings that begin with ^[ are either syntax
mvadh> errors or invalid alias names.

In general, yes.  However, in the [ge]macs mode of KSH, aliases
defined as underscore-letter are invoked by typing ESC-letter.  For
example,

	alias -x _z="ls -laF \`whence \`^B"

This is invoked as "ESC z".  (The ^B at the end, literally a cntl-B in
my $ENV file, positions the cursor inside the backquote.  Then I just
finish the command and hit return.)  There's no problem if you want to
include the newline at the end of the alias definition.  I have
several of these aliases already wired into the ROMs in my fingers.

Any escape sequences already in use for the [ge]macs mode editing will
have their hardwired meanings and not this kind of alias invocation.
-- 
  Bill Carpenter         att!hos1cad!wjc  or  attmail!bill

gast@maui.cs.ucla.edu (David Gast) (03/05/91)

In article <1991Feb17.235721.20854@shibaya.lonestar.org> afc@shibaya.lonestar.org (Augustine Cano) writes:
>I would like to use my function keys (F1-F8) to save keystrokes.
>My keyboard generates "ESC O c-j" for F1-F8 respectively.

If you are using X windows, you can reconfigure the keyboard.  I suspect
that you are not, however.

David

edw@sequent.UUCP (Ed Wright) (03/06/91)

%>I would like to use my function keys (F1-F8) to save keystrokes.
%>My keyboard generates "ESC O c-j" for F1-F8 respectively.

Go to the shelf and get the book.
The manual for your terminal should tell you haow to program the
F keys.
Thank god each terminal appears to be different! (:-)/2)
THis is often a task that involves doing things that are not obvious
and sometimnes frustrating.
TVI-950s are easy
HP700s are less so

It can be done.
Have fun
Ed
-- 
 I think I've got the hang of it now .... :w  :q  :wq  :wq! ^d  X exit
 X Q  :quitbye  CtrlAltDel   ~~q  :~q  logout  save/quit :!QUIT ^[zz
 ^[ZZ ZZZZ  ^H  ^@  ^L  ^[c  ^# ^E ^X ^I ^T  ?  help  helpquit ^D  ^d
 ^C ^c helpexit ?Quit ?q  decwrl or uunet or tek !sequent!edw 

crissl@rulcvx.LeidenUniv.nl (Stefan Linnemann) (03/13/91)

In <54479@sequent.UUCP> edw@sequent.UUCP (Ed Wright) writes:
>%>I would like to use my function keys (F1-F8) to save keystrokes.
>%>My keyboard generates "ESC O c-j" for F1-F8 respectively.

>Go to the shelf and get the book.
>The manual for your terminal should tell you haow to program the
>F keys.
>Thank god each terminal appears to be different! (:-)/2)
>THis is often a task that involves doing things that are not obvious
>and sometimnes frustrating.
>TVI-950s are easy
>HP700s are less so

You don't have to reprogram your terminal function keys.  Just use
the emacs command line editor and map ESC-O to ESC-ESC, after which
you can define ESC-[c-j] as aliases for whatever you fancy.  You'd
have to use __[c-j] as the alias names, but that's no problem.
The following lines are from my .profile:
--- part of .profile start ---
# make sure the emacs command line editor is used, independant of $EDITOR
export VISUAL=emacs
# set up aliases, functions and variables
alias -x _O='['	\
	__A=''	\
	__B=''	\
	__C=''	\
	__D=''	\
	__P=''	\
	__Q='='	\
	__R='*'	\
	__S=''
--- part of .profile end ---

__[A-D] are my cursor keys, which produce ESC-ESC-[A-D] and
__[P-S] are my function keys: they work like wonder for me.

>It can be done.
>Have fun
>Ed
>-- 
> I think I've got the hang of it now .... :w  :q  :wq  :wq! ^d  X exit
> X Q  :quitbye  CtrlAltDel   ~~q  :~q  logout  save/quit :!QUIT ^[zz
> ^[ZZ ZZZZ  ^H  ^@  ^L  ^[c  ^# ^E ^X ^I ^T  ?  help  helpquit ^D  ^d
> ^C ^c helpexit ?Quit ?q  decwrl or uunet or tek !sequent!edw 

It's been done.
Good luck!
Stefan.

Stefan M. Linnemann, System programmer; Leiden University, the Netherlands.
crissl@rulcvx.LeidenUniv.nl

crissl@rulcvx.LeidenUniv.nl (Stefan Linnemann) (03/14/91)

In <54479@sequent.UUCP> edw@sequent.UUCP (Ed Wright) writes:
>%>I would like to use my function keys (F1-F8) to save keystrokes.
>%>My keyboard generates "ESC O c-j" for F1-F8 respectively.

>Go to the shelf and get the book.
>The manual for your terminal should tell you haow to program the
>F keys.
>Thank god each terminal appears to be different! (:-)/2)
>THis is often a task that involves doing things that are not obvious
>and sometimnes frustrating.
>TVI-950s are easy
>HP700s are less so

You don't have to reprogram your terminal function keys.  Just use
the emacs command line editor and map ESC-O to ESC-[, after which
you can define ESC-O-[c-j] as aliases for whatever you fancy.  You'd
have to use __[c-j] as the alias names, but that's no problem.

The following lines are from my .profile:

--- part of .profile start ---
# make sure the emacs command line editor is used, independant of $EDITOR
export VISUAL=emacs
# set up aliases, functions and variables
alias -x _O='^[['	\
	__A='^P'	\
	__B='^N'	\
	__C='^F'	\
	__D='^B'	\
	__P='^[^['	\
	__Q='^[='	\
	__R='^[*'	\
	__S='^['
--- part of .profile end ---

In the above abstract from my .profile all the real control characters
have of course been replaced by representations.  To make it really
work, you'd have to replace them by the real thing.

__[A-D] are my cursor keys, which produce ESC-[-[A-D] and
__[P-S] are my function keys, which produce ESC-O-[P-S]:
they work wonders for me.

>It can be done.
>Have fun
>Ed
>-- 
> I think I've got the hang of it now .... :w  :q  :wq  :wq! ^d  X exit
> X Q  :quitbye  CtrlAltDel   ~~q  :~q  logout  save/quit :!QUIT ^[zz
> ^[ZZ ZZZZ  ^H  ^@  ^L  ^[c  ^# ^E ^X ^I ^T  ?  help  helpquit ^D  ^d
> ^C ^c helpexit ?Quit ?q  decwrl or uunet or tek !sequent!edw 

It's been done.
Good luck!
Stefan.

Stefan M. Linnemann, System programmer; Leiden University, the Netherlands.
crissl@rulcvx.LeidenUniv.nl