9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Russ Cox <russcox@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] tip o' the day
Date: Thu, 10 Feb 2005 09:59:41 -0500	[thread overview]
Message-ID: <ee9e417a05021006596ac59032@mail.gmail.com> (raw)
In-Reply-To: <Pine.BSI.4.61.0502092127140.3971@malasada.lava.net>

> fn gn { grep -n $* /dev/null }
>         Grep, but force listing of filename:lineno so you
>         can click on an entry to jump to it in an editor.
>
> fn g { grep -n $* *.[chsyl] /dev/null }
>         gn on all sources in the current directory

rob and i use this as /bin/g.  it handles both of these:

% cat /bin/g
#!/bin/rc

flags=()
while(! ~ $#* 1 && ~ $1 -* && ! ~ $1 --){
	flags=($flags $1);
	shift
}
if(~ $1 --)
	shift

switch($#*){
case 0
	echo 'usage: g [flags] pattern [files]' >[1=2]
	exit usage
case 1
	pattern=$1
	files=(`{ls *.[bcChm] *.cc *.py *.tex *.ms *.java >[2]/dev/null})
case *
	pattern=$1
	shift
	files=($*)
}
grep -n $flags -- $pattern $files /dev/null
%

> (how about a plumber command that ran grep -n on the files
> in the current directory and the include directory?  Then
> you could plumb words to it in acme with mouse chording to
> quickly crossreference keywords in the src tree.  I tried
> goofing with that once but failed pretty miserably).

i don't see why you'd involve the plumber.  just write
a script.

i find i almost never want to grep both local files and
/sys/include.  i either run g or sig.

% sig memmove
	void* memmove(void *s1, void *s2, long n)
%

russ


  reply	other threads:[~2005-02-10 14:59 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-08  8:05 Russ Cox
2005-02-08  8:07 ` [9fans] " Russ Cox
2005-02-08  8:16 ` [9fans] " Tim Newsham
2005-02-08  9:41 ` Fco. J. Ballesteros
2005-02-08  9:58   ` Steve Simon
2005-02-08 12:08   ` Robert Raschke
2005-02-08  9:51 ` Steve Simon
2005-02-08 16:31   ` Ronald G. Minnich
2005-02-08 10:01 ` Catalin(ux aka Dino) BOIE
2005-02-08 11:01   ` Charles Forsyth
2005-02-08 11:04     ` Catalin(ux aka Dino) BOIE
2005-02-08 15:46 ` andrey mirtchovski
2005-02-08 16:29 ` Ronald G. Minnich
2005-02-08 17:31 ` Sam
2005-02-08 18:22   ` Heiko Dudzus
2005-02-08 19:13 ` Micah Stetson
2005-02-08 19:37   ` rog
2005-02-08 19:54     ` andrey mirtchovski
2005-02-09 16:29       ` Ronald G. Minnich
2005-02-15 14:11     ` Matthias Teege
2005-02-15 15:29       ` rog
2005-02-15 16:57         ` Matthias Teege
2005-02-15 17:21           ` rog
2005-02-15 17:26             ` Ronald G. Minnich
2005-02-15 17:34               ` rog
2005-02-16 19:17   ` McLone
2005-02-10  7:21 ` Vincent van Gelderen
2005-02-10  7:40   ` Tim Newsham
2005-02-10 14:59     ` Russ Cox [this message]
2005-02-10 19:16       ` Tim Newsham
2005-02-15 15:33 ` andrey mirtchovski
2005-02-15 16:48   ` Russ Cox
     [not found] <ee9e417a0502170724abbfaa7@mail.gmail.com>
     [not found] ` <0345be3b46120cbf06bdff45601d5540@plan9.ucalgary.ca>
     [not found]   ` <ee9e417a05021707521732ce1c@mail.gmail.com>
     [not found]     ` <Pine.LNX.4.60.0502171110160.11590@fbsd.cpsc.ucalgary.ca>
     [not found]       ` <ee9e417a050217104148427143@mail.gmail.com>
2005-02-17 18:43         ` Russ Cox
2005-02-18 16:37           ` Sergey Reva
2005-02-22 10:12 Steve Simon
2005-02-23  0:45 YAMANASHI Takeshi

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=ee9e417a05021006596ac59032@mail.gmail.com \
    --to=russcox@gmail.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).