[net.unix-wizards] redo

HOLSTEGE@CIT-20@sri-unix (07/30/82)

Date: 28 Jun 1982 1423-PDT
We have here a command, "redo", which takes all its arguments and
concatenates them together and allows you to edit the resulting string
with things like ^W ^U <del> horisontal arrow keys and similar
screen editor type functions. It has an insert mode and an overstrike
mode and so on. So what, you say. Well, if you alias:

    alias r redo \'\!-1\'

in your .cshrc, then when you make a typing mistake, just type

    r

and you can interactively fix it. UNLESS the command you incorrectly
typed had single quotes in it. There should be a way within the csh
history mechanism to get a previous command as a single word without
further interpretation.


-------

sibley (07/30/82)

I also use a 'redo' command instead of relying on the
history mechanism mess.  Mine just takes an entry from
the history list, puts it in a file, runs ex open
mode on it, and executes the result.  I spent a lot of
time fooling with this to get rid of quoting problems and
ambiguity.  The whole thing is done with the following
alias:
    alias redo 'echo \!*:q > ~/cmd; ex +open ~/cmd; source ~/cmd'

It is used as
    redo !-3
for instance, to edit the third previous command.  The
following alias is used to get the immediately previous
one:
    alias again 'redo \!-1 '

The only real difficulty is that the command line as
stored on the history list aleady has had history
substitution performed on it, so it may not be exactly
what you typed.  There seems no way around this.  The one
line messages on entrance to and exit from the editor are
a minor annoyance, but I don't know a reasonable way to
suppress them.  Otherwise it works great.

One obvious advantage of my system is that the editor is
a familiar one -- just vi with a one line window.  It's
also probably more powerful than any special purpose
editor cooked up just for this and requires no separate
maintenance.

Try it and let me know how you like it.

Dave Sibley
Department of Mathematics
Penn State University
psuvax!sibley