9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "rob pike" <rob@plan9.bell-labs.com>
To: 9fans@cse.psu.edu
Subject: [9fans] history
Date: Tue, 22 Jan 2002 15:43:39 -0500	[thread overview]
Message-ID: <20020122204341.62A5119A04@mail.cse.psu.edu> (raw)

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%%



             reply	other threads:[~2002-01-22 20:43 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-22 20:43 rob pike [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-07-07 15:21 Fco. J. Ballesteros
2006-07-07 16:16 ` Skip Tavakkolian
2000-11-14 21:39 [9fans] History presotto
2000-11-14 21:46 ` Boyd Roberts
2000-11-14 20:45 Richard Miller
2000-11-14 19:12 anothy
2000-11-14 19:37 ` Boyd Roberts
2000-11-14 17:21 rog
2000-11-14 14:28 rob pike
2000-11-14 15:12 ` Boyd Roberts
2000-11-09 18:34 rob pike
2000-11-09 16:39 forsyth
2000-11-10  9:35 ` Douglas A. Gwyn
2000-11-14  9:33   ` George Michaelson
2000-11-14  9:51     ` Boyd Roberts
2000-11-14 15:50       ` Douglas A. Gwyn
2000-11-14 16:13         ` Boyd Roberts
2000-11-09 16:15 rog
2000-11-09 15:26 ` Boyd Roberts
2000-11-09 14:01 rob pike
2000-11-09 14:50 ` Boyd Roberts
2000-11-09 15:20   ` Axel Belinfante

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020122204341.62A5119A04@mail.cse.psu.edu \
    --to=rob@plan9.bell-labs.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).