From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu From: "rob pike" MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Message-Id: <20020122204341.62A5119A04@mail.cse.psu.edu> Subject: [9fans] history Date: Tue, 22 Jan 2002 15:43:39 -0500 Topicbox-Message-UUID: 4137b086-eaca-11e9-9e20-41e7f4b1d025 My semiannual mailing of " and "". You made need local adjustments to deal with the syntax of your shell prompt. These history commands search /dev/text for a pattern on a line beginning with a prompt. With no pattern, they find the previously executed command. " prints it for editing and sending with the mouse. "" just runs it. rc%% cat " #!/bin/rc rfork en if(test -r /mnt/acme/acme/body) bind /mnt/acme/acme/body /dev/text PROMPT='[^ ]*%+[ ]+' fn cmds { grep '^'$PROMPT'[^"]' /dev/text | sed 's/^/ /' } switch($#*) { case 0 cmds | tail -1 case * cmds | grep '^ '$PROMPT^$"* | {echo; cat} | pr -t -n | sort -nr | sort -u +1 | sort -n | sed 's/^ *[0-9]+ //' | grep . } # the silly {echo; cat} gets around pr printing "empty file" when # presented with no input. rc%% cat "" #!/bin/rc rfork e PROMPT='[^ ]*%+[ ]+' _x = `{" $* | tail -1} if(~ $#_x 0) { echo no such command found exit notfound } echo $_x _x=`{ echo -n 'eval '; echo $_x | sed 's/^'$PROMPT'//'} rc -c $"_x rc%%