[net.sources] Piping to vi

andrew@amdahl.UUCP (Andrew Sharpe) (09/09/86)

{}

How many times have you wanted to pipe to vi, but were loath to modify
the source? Well, I have been using the following shell function for
some time, and one of my colleagues suggested that the net might be
interested in it. This can be converted to an alias for the csh; it
will work as is in the System V.2 Bourne shell, and the Korn shell:


pvi()
{
	cat > pipe 2>&1 & view $* pipe < /dev/tty
}


A couple of notes:

	The file 'pipe' is a named pipe, so this function will only
	work if you can make such a beast.

	This will only work as a function/alias, not a script.

	Note that view is used instead of vi. This is to help avoid
	the problem of trying to write out the file to the named pipe
	(it will obviously hang - no readers). So view is used, and I 
	use either ':f file' or ':w file' to save to input.

	This is as simple to use as: ls -l | pvi


-- 
Andrew Sharpe          ...!{ihnp4,cbosgd,hplabs}!amdahl!andrew
--------------------------------------------------------------
 The views expressed above are solely my opinions; they do
 not reflect the views of the employees, nor the management,
 of Amdahl Corporation.
--------------------------------------------------------------