My thoughts went like this: If I could get the the string "esc[A" (I'm
using a VT102 terminal emulator) to be first be recoginized by ksh and
then if I could get ksh to perform the "^b" action, wow! But then
reality set in, the emulator is wired to send esc[A when left cursor key
is pressed, so that won't work. I could always program the Function Keys
to echo cursor left & right string, but that's ugly. Working...
Working... (that's 4 u EDT fans). I know that is has been done in the
tsch, but they must have built the functionality into the shell.
Despair! I don't know enough about the ksh/UNIX to make this brilliant
idea work!
Does anyone have an elagant solution to my "Since the cursor keys are
there, let's put them to work." question?
P.S. In the O'Reily & Assoc book "Learning the Gnu Emacs" there is a
setup to make the cursor keys suplement ^b, ^f, ^n, ^p within the
context of emacs. Also, you can use the VT102's keypad (or a
Sparstation, etc. if u know output keycodes) for some shorthand keys to
anything else that you might want (Born Again Eve? 4 u VMS wonks).
--
Roy Kannady Ignorance is curable;
Martin Marietta Astronautics Stupidity is terminal.
kan...@pogo.den.mmc.com Voice: (303) 971-5869
# ANSI keyboard escapes
alias __A=^P # uparrow = previous history line
alias __B=^N # downarrow = next history line
alias __C=^F # rightarrow = forward char
alias __D=^B # leftarrow = back char
substitute a _real_ control-p, etc, for the ^P, etc. control-q in
emacs will allow you to do this.
This only works in real ksh, not in pdksh. One of the reasons I wish
this Sun had real ksh.
--
dhs spe...@panix.com
: # ANSI keyboard escapes
: alias __A=^P # uparrow = previous history line
: alias __B=^N # downarrow = next history line
: alias __C=^F # rightarrow = forward char
: alias __D=^B # leftarrow = back char
You have no idea how long I've tried to figure this one out ==> THANK YOU!!
My man page says nothing about those aliases... Welcome to the Wonderful
World of ISC unix...;< .
Are there any other such special aliases? If so, please post them. Also,
if your man page talks about these things, please e-mail it to me.
Thanks again and in advance,
--
--Ami
Have YOU hugged YOUR smurf today?
Encyclopedia Salesmen:
Invite them all in. Nip out the back door. Phone the police
and tell them your house is being burgled.
-- Mike Harding, "The Armchair Anarchist's Almanac"
David> Add to your .kshrc # ANSI keyboard escapes
David> alias __A=^P #uparrow = previous history line
David> alias __B=^N # downarrow = next history line
David> alias __C=^F # rightarrow = forward char
David> alias __D=^B # leftarrow = back char
This is nice, actually it is one of the main reasons I don't use ksh :)
Since we are in the subject already, how can I map the <Tab> key to
M-ESC to get file name completion?
Thanks much,
Rob
--
Roberto Dorich o SKI rdo...@jade.tufts.edu
Electrical Engineering /= EXTREME rdo...@athena.mit.edu
Tufts University __/__, uucp: rob...@kastle.ext.tufts.edu
----------------------------------------------------------------------------
Sam
I tried defining the aliases and it works! Then I started reading
the ksh man pages a little more closely and I almost understand why
it works (but not totaly).
The following were taken from the ksh man pages on an HP-UX and SGI Irix
system (now they make sense):
M-"letter" Softkey. User's alias list is searched for an alias by
the name _letter and if an alias of this name is
defined, its value is inserted on the input queue.
This letter must not be one of the above meta-
functions. (from HP-UX and SGI man pgs)
M-"letter" Softkey. User's alias list is searched for an alias by
the name __letter and if an alias of this name is
defined, its value is inserted on the input queue.
This can be used to program funcion keys on many
terminals. (from SGI man pgs)
Even though the __letter feature is not documented on HP-UX, it works.
What I don't understand is exactly why. As an experiment I turned off
the emacs cmnd line option (set +o emacs) and pressed a bunch of
cursor-lefts then pressed RETURN. As I expected I got a lot of
"^[[D"s (this is a vt100 emulator not an ANSI terminal). The "^[" is
Escape or emacs' Meta character but how does M-[D map into __D? Maybe
the Korn Shell's author gave us an "un-documented feature".
I did pick up a tid-bit from "Learning the Korn Shell" by Bill
Rosenblatt, pg 42, "... emacs-mode has an interesting way of defining
keyboard shortcuts for commonly used commands by interacting with the
Korn shell's alias facility ... when you define and alias called _x
... then emacs-mode will expand the alias when you hit ESCx ... We
didn't find this particularly useful ..." Again, no reference to an
alais of form __x, but rather just to _x. Maybe Rosenblatt was using
HP-UX, but who knows?
On pg 53 (in vi-mode), he makes about the same statement "... then the
shell will expand the alias on the current line (but not run it) if
you type @ followed by x. As with the similar facility in emacs-mode,
we don't find this particularly useful."
Rosenblatt makes an interesting comment in the footnote on pg 29, "For
some unknown reason, the documentation on emacs-mode has been removed
from ksh(1) manual pages on some UNIX systems. This does not mean,
however, that the mode doesn't exist or doesn't work properly."
I hope that this will help.
>Thanks much,
>Rob
>--
No need to. The feature is built-in to ksh w/ emacs-mode cmnd line
editing activated. To quote from "Learning the Korn Shell" by Bill
Rosenblatt:
"There are three commands in emacs-mode that relate to filename
completion. The most important is ESC ESC. When you type in a word
of text followed by ESC ESC, the Korn shell will attempt to complete
the name of a file in the current directory (analogous to emacs
minibuffer completion with the TAB key). Then one of four things will
happen:
1. If there is no file whose name begins with the word, the shell will
beep and nothing further will happen.
2. If there is exactly one way to complete the filename and the file is a
regular file, the shell will type the rest of the filename and follow it
with a space ...
3. If there is exactly one way to complete the filename and the file is a
directory file, the shell will type the rest of the filename and follow it
with a slash.
4. If there is more than one way to complete the filename, the shell will
complete out to the longest common prefix among the available
choices."
Item 4 is dense, but for example if u had files program.c and
problem.c and typed cc pr + ESC ESC, the shell would expand ur input
to cc pro (the point where the ambiguity starts). If u added a g to
the shell's response followed by ESC ESC, the shell would respond
with cc program.c.
The other related comands are ESC * and ESC =. Try them and then RTFM.
|# ANSI keyboard escapes
|alias __A=^P # uparrow = previous history line
|alias __B=^N # downarrow = next history line
|alias __C=^F # rightarrow = forward char
|alias __D=^B # leftarrow = back char
When I put this into my .kshrc, then did Esc k to get into
command history, then up arrow, all I got was a beep. Do you
know if ksh in SCO UNIX 3.2v4 supports these aliases?
--
Bill Irwin - The Westrheim Group - Vancouver, BC, Canada
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
uunet!twg!bill (604) 431-9600 (voice) | Your Computer
bi...@twg.bc.ca (604) 430-4329 (fax) | Systems Partner
Make the jump to Solaris 2.x. Real ksh is standard as with any SVR4.
-David
------------------------------------------------------------------------------
David Lehmann Toshiba America Consumer Products, Inc.
Email: da...@toshiba.com Advanced Television Technology Center
Voice: (609)951-8500 ext. 21 201 Carnegie Center, Suite 102
Fax: (609)951-9172 Princeton, NJ 08540
------------------------------------------------------------------------------
> Does anyone have an elagant solution to my "Since the cursor keys are
> there, let's put them to work." question?
Roy, I would like to have the possibility of using the cursors in the
command line with ksh but Bill Rosenblat says in his book "Learning the Korn
Shell" (O'Reilly) that it's not possible, even in emacs mode and with the
keys reconfigured in a .emacs file.
I hope he's wrong.
Ismael
--
+-----------------------------------------------------------+
| ISMAEL CORDEIRO | Internet: ism...@cam.org |
| Montreal - Quebec - Canada | Fidonet: 1:167/179 |
+-----------------------------------------------------------+
: Make the jump to Solaris 2.x. Real ksh is standard as with any SVR4.
I did it in Solaris 2.x and it didn't work with cmdtool!
Any help ?
--
... ___ ____ _________ Christian Masopust
_][_n_n___i_i ____/___| | | Siemens AG Austria
(____________I.I_______I.|_______| E-Mail: ru...@emndev.siemens.co.at
/ooOOOO OOOOoo oo oooo oo oo Phone(Fax): +43-1-2501-4516 (4485)
cmdtool intercepts the cursor keys, use shelltool instead, or even
better, use xterm.
--
Michael Salmon
#include <standard.disclaimer>
#include <witty.saying>
#include <fancy.pseudo.graphics>
Ericsson Telecom AB
Stockholm
This will result in a long directory listing sorted by time whenever you
press the F1 key. The secret lies in aliasing META-O which is always the
prefix on my function key, to the META key (ESC on my keyboard).
--Ami
Have YOU hugged YOUR smurf today?
Zero Defects, n.:
The result of shutting down a production line.
| Well, after toying with the alias thingy for some time, I wanted to see if I
| could alias my function keys to something. On the console of my ISC unix
| box, F1 sends ^[OP, F2 sends ^[OQ, etc. I tried doing alias _OP=command but
| that didn't work since ksh only looks for SINGLE letter aliases. So, I
| found the solution to be like this:
| alias _O='ESC' (the ESC is a real escape code)
| alias _P='ls -alt'
| This will result in a long directory listing sorted by time whenever you
| press the F1 key. The secret lies in aliasing META-O which is always the
| prefix on my function key, to the META key (ESC on my keyboard).
Congratulations. Every couple of weeks, someone comes here wanting to know
how to get filename completion with one keystroke - this technique apparently
can achieve that effect, too. May your post be immortalized in the FAQ.
Donn Cave, University Computing Services, University of Washington
do...@cac.washington.edu
IN RESPONSE TO YOUR POSTING ON comp.unix.shell you (David Spencer (spe...@panix.com)) wrote:
: Add to your .kshrc
--
Scott Onofrio LaserJet IHV Developer Group
------------------------------------ Hewlett-Packard
sono...@hpdmd48.boi.hp.com (smtp) Boise Printer Division
hplabs!hpdmd48.boi!sonofrio (uucp) 11311 Chinden Blvd (M/S 112)
(208) 396-4529 Phone Boise, Idaho 83714
(208) 396-4021 Fax
> |# ANSI keyboard escapes
> |alias __A=^P # uparrow = previous history line
> |alias __B=^N # downarrow = next history line
> |alias __C=^F # rightarrow = forward char
> |alias __D=^B # leftarrow = back char
> When I put this into my .kshrc, then did Esc k to get into
> command history, then up arrow, all I got was a beep. Do you
> know if ksh in SCO UNIX 3.2v4 supports these aliases?
It seems you're in emacs mode, not vi mode. Esc k is the history command for
vi mode and the key bindings above are for emacs mode. If you put set -o
emacs in your .kshrc you're in emacs mode, not vi mode. Enter set -o and
you'll see in which mode you are. In emacs mode, with the aliases above, you
have just to press cursor-up to get the last command. If you want to use the
cursor keys in vi mode you'll have to modify the aliases above.
: Bill Irwin (bi...@twg.bc.ca) wrote:
: > |# ANSI keyboard escapes
: > |alias __A=^P # uparrow = previous history line
: > |alias __B=^N # downarrow = next history line
: > |alias __C=^F # rightarrow = forward char
: > |alias __D=^B # leftarrow = back char
: > When I put this into my .kshrc, then did Esc k to get into
: > command history, then up arrow, all I got was a beep. Do you
: > know if ksh in SCO UNIX 3.2v4 supports these aliases?
: It seems you're in emacs mode, not vi mode. Esc k is the history command for
: vi mode and the key bindings above are for emacs mode. If you put set -o
: emacs in your .kshrc you're in emacs mode, not vi mode. Enter set -o and
: you'll see in which mode you are. In emacs mode, with the aliases above, you
: have just to press cursor-up to get the last command. If you want to use the
: cursor keys in vi mode you'll have to modify the aliases above.
I thought the key bindings above are for vi mode. How can you make the arrow
keys work in the vi mode (if possible).
Gene Kratochvil
> : > |# ANSI keyboard escapes
> : > |alias __A=^P # uparrow = previous history line
> : > |alias __B=^N # downarrow = next history line
> : > |alias __C=^F # rightarrow = forward char
> : > |alias __D=^B # leftarrow = back char
> I thought the key bindings above are for vi mode. How can you make the arrow
> keys work in the vi mode (if possible).
I'm not sure it'll work but you could try replacing the control codes at the
right of the equal sign with the equivalent vi cursor commands.
Indeed, I tried in the "emacs" mode of ksh command editing
.............
alias __A=^P
alias __B=^N
alias __C=^F
alias __D=^B
.............
and it worked.
Then I tried in the "vi mode" of ksh
.............
alias __A=k
alias __B=j
alias __C=l
alias __D=h
.............
and it did not work.
Actually, what surprises me is that it worked for the emacs mode because, on my
terminal, pressing for instant the "up arrow" generates an Escape Sequence, with
three characters : ESC [ A
What is the mechanism built in the emacs-mode which can do the translation of
"ESC [ A" in "__A" ? Is there such a mechanism for the vi-mode?
Any suggestion welcome.
Jean-Marie Teuler
/--------------------------------------------------------\
| Jean-Marie Teuler |
| CNRS-IDRIS |
| Batiment 506 |
| B.P. 167 E-mail : teu...@idris.fr |
| 91403 Orsay Cedex Tel : 33.1.69.82.41.26 |
| France Fax : 33.1.69.28.52.73 |
\--------------------------------------------------------/
The __? alias in ksh is for ESC-[-?.
It works because this can be mapped to ^P, which emacs uses as up history.
--
Bruce Momjian | 830 Blythe Avenue