Xref: utzoo comp.unix.programmer:313 comp.unix.questions:26405 Newsgroups: comp.unix.programmer,comp.unix.questions Path: utzoo!utgpu!watserv1!maytag!watdragon!lotus!psmielke From: psmielke@lotus.uwaterloo.ca (Peter Mielke) Subject: Re: Questions about rewriting the History function. Message-ID: <1990Oct21.220115.9458@watdragon.waterloo.edu> Sender: daemon@watdragon.waterloo.edu (Owner of Many System Processes) Reply-To: psmielke@lotus (Peter Mielke) Organization: University of Waterloo Date: Sun, 21 Oct 90 22:01:15 GMT Lines: 49 In <1990Oct19.165721.7584@polyof.poly.edu>, mhoffman@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 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@lotus.UWaterloo.ca University of Waterloo peter@doe.utoronto.ca An undergrad that's been around too long...