[net.unix-wizar] redo

ks (07/31/82)

#R:psuvax:-106600:pur-ee:500006:000:326
pur-ee!ks    Jul 31 03:48:00 1982

I must say I like Dave Sibley's method of editing previous command lines
with ex(open mode).  Simple yet powerful, it works quite well for me,
although I don't use it too often.  When it is used, it is QUITE handy.
Also, one may wish to chmod 600 on the file ~/.cmd or whatever you call it..

						Kirk Smith
						Purdue EE

davy (08/01/82)

#R:psuvax:-106600:pur-ee:500007:000:2456
pur-ee!davy    Jul 31 14:14:00 1982


	I have discovered a problem with Dave's "redo" alias, and I'm
not quite sure how one would go about fixing it.  Let's say I have a 
command which looks like:

			man foo | lpr

	Now, if I do a "redo" on that, all that shows up in the file is
"man foo".  What is happening is this:  the output from "ex" is getting 
piped through "lpr", not the changed command!

	Aside from this, the only other disadvantage to using redo is that
the new command does NOT go into your history list, thus, you can't execute 
it again with something like "!!".  Other than that, the editing idea is nice, 
although I have become pretty proficient at using the editing features built 
in to csh, and probably wouldn't use redo too much.

	For those of you who haven't bothered to learn csh's editing features,
here is a quick summary of the three most useful commands:

	1)  The '^' character works on the previous command only, and may be 
	used for correcting spelling, as in:

		you:	% wha am i
		csh:	wha: command not found.
		you:	% ^a^o
		csh:	who am i
			<command is executed>

	This command does not cover spaces, so you cannot change more than one 
	"word".  You can also do things like:

		^who^where davy		- change command completely
		^davy^joe		- change argument
		^joe^			- delete argument

	2) The "s" command.  This command is basically like the "s" in ex, and 
	works as follows.  You give it a command reference, like "!!" or "!30", 
	or "!-3", followed by a colon (:) and then the substitution command:

		you: 	foo -a -b bar
			<command executes>
		you:	!!:s/-a -b/-c -d
		csh:	foo -c -d bar
			<new command, "foo -c -d bar", executes>

	3) The "g" command.  The "g", when placed in front of an "s" command, 
	implies global substitution.  Say you had two programs, "acudaily" and 
	"acpdaily", both of which needed compiling.  You could type both 
	commands, or, do this:

		you:	cc -O -s -DPURDUE-EE -o acudaily acudaily.c -lm 
			<command executes>
		you: 	!!:gs/acu/acp
		csh:	cc -O -s -DPURDUE-EE -o acpdaily acpdaily.c -lm
			<new command executes>

Just by using the three things above, I am able to do just about anything I 
want with my history list, and only occaisionally do I have a problem which 
I can't change.  There are zillions of other things the manual describes to
help you edit commands, but I think most of them are rather specialized, and
a waste of time to bother memorizing.

--Dave Curry
decvax!pur-ee!davy
ucbvax!pur-ee!davy

mark (08/01/82)

Another alternative is, instead of putting the output of ex into
a file and sourcing it, to use the "typein" command.  (I found
typein.c in /usr/guest on my 4.1BSD system, if you don't have it,
it just uses TIOCSTI to "type in" its arguments, as though you
had typed them on the keyboard.)  If you do it this way, it goes
on your history list.  typein does not type the newline for you,
presumably to let you continue typing more stuff, although I
personally would prefer the newline.  TIOCSTI is in 4.1BSD and
presumably 2.8BSD, but no other version of UNIX that I know of.

	Mark

jqw (08/02/82)

One solution to the problem of redo-ing statements that contain csh
special characters (e.g. | < > ;) is to have the alias "again"
be "redo !-1:q" instead of "redo !-1". Remember to escape the "!" with
a backslash.