9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Filename Referencing in Sam
@ 2006-11-06  3:16 yard-ape
  2006-11-06  4:30 ` Russ Cox
  0 siblings, 1 reply; 3+ messages in thread
From: yard-ape @ 2006-11-06  3:16 UTC (permalink / raw)
  To: 9fans

Sam experts:

Are there any simple ways to use the current filename as material inside the command language?  For example, how might I insert a file's filename as a title at it's first line?  Or, how might I run a shell command (using "!") on a file with it's filename as an argument to the command?

I can do these kind of things manually with the mouse, of course, but it would be nice to be able to do it inside loops and tests (with "X", "Y", "x", "y", "g", etc).  If it helps clarify, what I'm *used* to using for this sort of thing is a filename variable (like "%" in many implementations of ed).

Thanks!

-Derek


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] Filename Referencing in Sam
  2006-11-06  3:16 [9fans] Filename Referencing in Sam yard-ape
@ 2006-11-06  4:30 ` Russ Cox
  2006-11-07  3:27   ` yard-ape
  0 siblings, 1 reply; 3+ messages in thread
From: Russ Cox @ 2006-11-06  4:30 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

I added this to the plan9port sam over the summer.
The name of the current file is exported as $samfile.

The code hasn't made it into Plan 9 but if you want it,
see the top of http://swtch.com/usr/local/plan9/src/cmd/sam/shell.c

Russ


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] Filename Referencing in Sam
  2006-11-06  4:30 ` Russ Cox
@ 2006-11-07  3:27   ` yard-ape
  0 siblings, 0 replies; 3+ messages in thread
From: yard-ape @ 2006-11-07  3:27 UTC (permalink / raw)
  To: 9fans

"Russ Cox" <rsc@swtch.com> wrote:

> I added this to the plan9port sam over the summer.
> The name of the current file is exported as $samfile.
>
> The code hasn't made it into Plan 9 but if you want it,
> see the top of http://swtch.com/usr/local/plan9/src/cmd/sam/shell.c
>
> Russ

Thanks, Russ.  I've been wanting something like that for a long time.

-Derek


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-11-07  3:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-06  3:16 [9fans] Filename Referencing in Sam yard-ape
2006-11-06  4:30 ` Russ Cox
2006-11-07  3:27   ` yard-ape

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).