[net.micro.pc] MS-DOS command history/edit program

nather@ut-sally.UUCP (Ed Nather) (04/06/86)

# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by sally!nather on Sun Apr  6 13:20:24 CST 1986
# Contents:  Readme keydo.doc keydo.uue
 
echo x - Readme
sed 's/^@//' > "Readme" <<'@//E*O*F Readme//'
There are two different approaches (and many different programs) designed
to allow command-line editing and history recall in MS-DOS.  The program
DOS-EDIT derived from PC magazine is one approach -- and a rather inferior
one, in my opinion, since anything that has been scrolled off the current
display screen is not available.  This is nearly always the case where the
invoked program sends output to the screen.

A better and much more elegant approach is to provide an invisible, endless
buffer to hold prior commands, and bring them to the cursor line whenever
demanded, where they can be executed with or without editing. (Any command
which is changed is saved as a new command).  The attached program was
written by Jack Gersbach, who works at IBM and also wrote the beautiful
PD 808x disassembler "asmgen."  If you want to learn about programming an
808x processor, disassemble this program -- it is a working textbook.

Apparently there are more "advanced" copies of this program, which permit
aliases etc., but without argument substitution.  I use .bat files for that
purpose, which allow argument substitution.  I find just the command history
and editing provides a simple, clean and excellent tool.  I seriously miss it
whenever I use Unix.  To use it, put the command "keydo" in your autoexec.bat
file, and locate keydo.com in a directory known to your command search path.
WARNING: THIS PROGRAM IS ADDICTING.  The Surgeon General has determined you
will become seriously depressed if forced to use an operating system that
does not support it.

I have made two minor changes to the original.  When active, the original
"keydo.com" program defaults to "overwrite" mode, like the IBM BASIC editor.
Since I use PC-Write and it defualts to "insert" mode, I changed keydo.com
to correspond.  If this seriously offends you, send me mail and I'll tell
you how to change it back.

The second minor change allows one- or two-character commands to be stored,
which the original did not.  I assume this was to avoid storing commands like
"A:" but I don't really know.

Use "uudecode" to recover the original .com file below, and some form of
BINARY (or image) transfer to get it to your PC.  I use "Kermit -is keydo.com."

@//E*O*F Readme//
chmod u=rw,g=r,o=r Readme
 
echo x - keydo.doc
sed 's/^@//' > "keydo.doc" <<'@//E*O*F keydo.doc//'
             keydo - a simple history mechanism for MS-DOS

KEYPAD KEY   OPERATION                    KEY        OPERATION

Up Arrow     Recall earlier command       Dn Arrow   Recall later command

Left Arrow   Move cursor left 1 char.     Backspace  Delete prior char.
Right Arrow  Move cursor right 1 char.    Del        Delete current char.
Ctrl-Left    Move cursor left 1 word      Ctrl-Home  Erase to start of line
Ctrl-Right   Move cursor right 1 word     Ctrl-End   Erase to end of line
Home         Move cursor to line start    Esc        Erase complete line
End          Move cursor to line end      Ins        Toggle overwrite/insert

This program is loaded as a part of the command environment in MS-DOS, and 
remembers commands as they are typed.  If you want to repeat a command, just 
press the Up Arrow key on your keypad, and the command will appear on the 
command line just as if you had typed it in again.  To execute it unchanged, 
press the <RETURN> key.  

You can "back up" more than 1 command: pressing the Up Arrow key will recall a 
previous command each time.  The last 32 commands you typed are available in a 
circular buffer; to go the other way use the Down Arrow key.  

You can edit the recalled command before you execute it: use the Left and 
Right Arrow keys to move the cursor back and forth on the line.  Hold down the 
Ctrl key, and the arrow keys move the cursor one "word" at a time.  The Home 
key moves the cursor to the beginning of the line, the End key moves it to the 
end.  The Del key deletes the character the cursor is sitting on, the back-
space key deletes the one before the cursor.  Ctrl-Home erases from the cursor 
position to the start of the line, Ctrl-End erases from the cursor to the end 
of the line.  You can insert new characters just by typing them. To overwrite 
characters present, touch the Ins key once, then type.  

You can execute the revised command at any time, with the cursor in any 
position, by pressing the <RETURN> key.
@//E*O*F keydo.doc//
chmod u=rw,g=r,o=r keydo.doc
 
echo x - keydo.uue
sed 's/^@//' > "keydo.uue" <<'@//E*O*F keydo.uue//'
begin 644 keydo.com
MOA`!O[P'N30!*\[SI.FL!C/`CMB^A`"_9@*EI;A@`HE$_(Q,_K]@`+D``K`-
M\ZJZO`?-)P``````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````````````````````````````````````````(#\"G0%Z@``
M``!04U%25E=5'@;[Z"\!!Q]=7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`<.*`$;HPOWYP^CP_W,)L`<F(@90!'7RP^@;`'(8
MZ+G_Z_8F]@87!`)TW^@)`'(&L`<BPG7UPPOV^72N3NAZ_8`X"70*@#@@<S'H
M;?WK+%:+SHK!M`?C#TZ`."!S!X`X"70)_LSB\2XJ)JH'*N`"S(#A!W0%Z$+]
MXOM>^.M3D.BU_W)<Z_GHKO]R50O_=%$[]W1-5COW=`B*0`&(`$;K]%Y/@<T#
M`('E]_]6._=S"(H`Z!;]1NOTZ"G]]\4!`'00+H<&=0.1Z/_\)CL.4`1W]EZT
M`E-1+H@6JP>W`,T065O#_8'E]__HEO_HR?X&'@<.'XLVK`>LC7__N0`!Z.@`
MJ(#A^?QU!@8?!^GO_8'E\?_HU`#V!(!U"$[HT`!.Z,P`B3:L!^C``"1_)HIE
M_SK$<@**Q*J8D5'HK0"JZ(S\XO=?B_<&'P?#]\4&`'7Y'@93Z"S_Z%_^#@<.
M'XL^K`=7B_?H@P`\#77Y.S:N!W0(Z'8`Z(``Z_*P#8@%B]^''JX'7CO?=`7H
M;`#K]TZ)-JP'6P<?Z5?_)H`F%P1_Z$7\6.CQ_;`-Z*;[B`&+QXA'_XOS/`+K
M``X'+O\&K`?WQ0(`="4NBSZN!PR`Z"D`/`UT`ZSK]BZ)/JX'+C@%=`7H%0#K
M]BZ)/JP'P^@"`"ZLA_?H!P"']\/H`0"J+CL^L`=S!BZ+/K('3RX[/K('<@4N
MBSZP!\/H:O[HG?T>C,B.V([`BSZP!XD^K`>)/JX'N0`!L`WSJA_IQ?P``&`!
@.8`%@`6`"8`!@`&``8`&.
`
end
@//E*O*F keydo.uue//
chmod u=rw,g=r,o=r keydo.uue
 
echo Inspecting for damage in transit...
temp=/tmp/shar$$; dtemp=/tmp/.shar$$
trap "rm -f $temp $dtemp; exit" 0 1 2 3 15
cat > $temp <<\!!!
      38     371    2228 Readme
      35     340    2002 keydo.doc
      42      44    2404 keydo.uue
     115     755    6634 total
!!!
wc  Readme keydo.doc keydo.uue | sed 's=[^ ]*/==' | diff -b $temp - >$dtemp
if [ -s $dtemp ]
then echo "Ouch [diff of wc output]:" ; cat $dtemp
else echo "No problems found."
fi
exit 0
-- 
Ed Nather
Astronomy Dept, U of Texas @ Austin
{allegra,ihnp4}!{noao,ut-sally}!utastro!nather
nather@astro.UTEXAS.EDU

scott@hp-pcd.UUCP (scott) (04/09/86)

Re: Missing command stack in UNIX

Have you tried the K-shell?  You get the same stack, and
the EMACS cursor/line control keys manipulate the stack...

hp-pcd!hpcvck!scott

sitze@rruxu.UUCP (04/14/86)

	KSH is UNIX specific, as I remember...
	Twould be nice though  (I support's VI and EMACS editing..)

				<ras>