Questions about rewriting the History function.

Peter Mielke psmielke at lotus.uwaterloo.ca
Mon Oct 22 08:01:15 AEST 1990


In <1990Oct19.165721.7584 at polyof.poly.edu>, mhoffman at george.poly.edu writes:
> 
> I am working on a senior project to rewrite the history function for
> UNIX. My goal is to have the new history functon work like it does in
> MS_DOS.  i.e. I want to be able to call up past commands and edit them
> by using the control <hjkl> characters. Additionally, I would like to
> write this as a stand alone program so that I do not have to rewrite
> the shell.
> 

If you are in the csh you don't have to write such a creature, one
already exists:

----------cut here------------
# Edit history list at line containing last command (open mode).
# Get up to 22 most recent commands.
# To work properly, put in .login:  alias r source /usr/local/bin/redo
# Author unknown.
# history -h 22 >! /tmp/redo.$$
#
history -h 22 | grep -v '^r$' >! /tmp/redo.$$
#
# Make CR map to :wq! and start ex quietly at 2nd to last line in open mode.
# ex - '+map 
ex - '+map 
#
# have to show output so tty works
#
# ex '+map 
#
tail -1 /tmp/redo.$$ >! /tmp/cmd.$$
#
# Insert into history without executing.
#
source -h /tmp/cmd.$$
#
# Clear out temporaries.
#
/bin/rm -f /tmp/{cmd,redo}.$$
#
# If thing chosen to redo is the redo alias itself then DON'T redo it.
#
if (!-2:0 != !!:0) !!
----------cut here------------
--
Peter Mielke                     Preferred ->  psmielke at lotus.UWaterloo.ca
University of Waterloo                         peter at doe.utoronto.ca
An undergrad that's been around too long...



More information about the Comp.unix.programmer mailing list