k with S README
The k program (described below) provides ksh command editing
and history for unix commands.  To use k, type make in this
directory and copy kS to a commonly searched directory. 
Then invoke S using the command kS and you get the ksh command recall
and editing features.

In order to make the vi command in S work properly, it was necessary
write a dummy version of vi that turns off k's command recall
features and then calls the real vi.  In addition,  the environment 
variable ALWAYS_PROMPT must be set.  The command kS sets a user's
PATH to access the dummy vi before the real vi and also sets 
ALWAYS PROMPT.

*************************************************************************
k README
"k" (korn shell, hold the shell) is a program which supports history
and command line editing for arbitrary unix commands.  The only requirement
on the command is that it use standard input, without issuing ioctl()s to
set the modes of a tty.  Instead of a tty, the command will be connected to a
pipe which will send it input a line at a time, like a cooked tty.

Each unix command that you use with "k" gets its own unique history
file, so that history is preserved on a per command basis across
the execution of other commands.  These files are stored in your home
directory, are of the same relative size as your ksh_history file (HISTSIZE),
and are named .CMD_history where CMD is the unix command (e.g. .cat_history).
To turn off this feature, export a variable named NOHIST, and an annonymous
history file will be used each time you use "k" and will then go away.

To create the program, type make.  There are actually two makefiles,
(makefile and Makefile), with the Makefile file being an unaltered
korn shell make file, of which only the edit library part is made.
(Note that there is a minor change to this library, to support the
termination of programs using signals, while preserving the correct
tty settings on exit.)

To use the program, put it in an accessible place, and for each command
you want to use editing with, type "k command [shell exps] [arguments]"
For example, to line edit the input to cat, type:
	k cat >garp
An easier way to use the program is to use the korn shell aliasing
facility, for example:
	alias cat="k cat"
This may look recursive, but it isn't.  It may also concern you that
cat won't work as expected in cases where you want to write out a file
to the terminal, but it does!  also, if you redirect standard input to
the "k" program, it execs the command without doing any editing, so
everything works as you would expect it.

Interrupt signals work as you would expect, depending on the command
which you are running.  In fact, with the exception of being able to
line edit with history, I think I have preserved most other semantics
of the commands which are run with "k", such that you won't be able
to tell that it's there, except when you need it.

"k" also supports shell escape ("!cmd [args]").  As a side effect, if you want
to input anything to a program which starts with a "!", use "\!"  (A simple "!"
followed by newline is transmitted down the input stream.)  A "\" at the
beginning of the line is otherwise sent to the input stream, except for
comments (see next paragraph).

Comments may be sent to the history file by using the command #, or
placing a "#" at the front of the line being input.  These comments are
not transmitted down the input stream.)  A "\#" at the beginning of the line
causes # to start the line sent to the input stream.

When exiting, typeahead will often be disabled for a short period of time,
so it's best to wait for the shell prompt to show.  (This is because "k" relies
on signals from the termination of its child process, and thus may be reading
your typeahead, which it throws away.)

I have the following aliases in my .profile:

	alias bc="k bc"
	alias cin="k cin"
	alias dc="k dc"
	alias ed="k ed"
	alias library="k library"
	alias mail="k mail"
	alias sdb="k sdb"

Commands from a program can be accessed from the shell level using the
cmdhist program.  This program allows you to get the (input) script of a
program session and put it into a file, for example.  This is similar to the
history feature of ksh, with some additional options (primarily: give
me the last n commands).  See the cmdhist(1) man page for further details.

The program "k" is an accumulation of several sources, including the
korn shell (by David Korn, with edit modules for emacs by Michael T. Veach 
and vi edit capability by:  P.D. Sullivan)
the "inedit" program also by M. T. Veach, and my own hacks.
The cmdhist program is by Tyrone Shiu.

David Neal
