zsh-users
 help / color / mirror / code / Atom feed
* fastest way to bring up a shell function for editing?
@ 2006-02-07 14:36 Jean-Rene David
  2006-02-07 14:38 ` Clint Adams
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Jean-Rene David @ 2006-02-07 14:36 UTC (permalink / raw)
  To: zsh-users

Say I define a short function on the command line
and then want to bring it up again for editing.
What's the fastest way to do it?

vared is neat. Is there a "funced" of some sort?

-- 
JR


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

* Re: fastest way to bring up a shell function for editing?
  2006-02-07 14:36 fastest way to bring up a shell function for editing? Jean-Rene David
@ 2006-02-07 14:38 ` Clint Adams
  2006-02-07 14:46 ` Mike Hernandez
  2006-03-02 21:04 ` Julius Plenz
  2 siblings, 0 replies; 9+ messages in thread
From: Clint Adams @ 2006-02-07 14:38 UTC (permalink / raw)
  To: zsh-users

> Say I define a short function on the command line
> and then want to bring it up again for editing.
> What's the fastest way to do it?
> 
> vared is neat. Is there a "funced" of some sort?

zed -f


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

* Re: fastest way to bring up a shell function for editing?
  2006-02-07 14:36 fastest way to bring up a shell function for editing? Jean-Rene David
  2006-02-07 14:38 ` Clint Adams
@ 2006-02-07 14:46 ` Mike Hernandez
  2006-02-07 14:56   ` Peter Stephenson
  2006-03-02 21:04 ` Julius Plenz
  2 siblings, 1 reply; 9+ messages in thread
From: Mike Hernandez @ 2006-02-07 14:46 UTC (permalink / raw)
  To: zsh-users

On  Tue, Feb 07, 2006 at 09:36:37AM -0500, Jean-Rene David wrote:
> Say I define a short function on the command line
> and then want to bring it up again for editing.
> What's the fastest way to do it?
> 
> vared is neat. Is there a "funced" of some sort?
> 
Try this:

% foo(){ echo "this is a function" }
% foo
this is a function
% vared foo()
function> echo "vared works... sort of"
% foo
vared works... sort of

If you hack something into zle to print the contents of the function
at the prompt...  maybe... 

Sorry this reply wasn't a real answer to your question! :)

Mike


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

* Re: fastest way to bring up a shell function for editing?
  2006-02-07 14:46 ` Mike Hernandez
@ 2006-02-07 14:56   ` Peter Stephenson
  2006-02-07 15:17     ` Jean-Rene David
  2006-02-07 15:24     ` Mike Hernandez
  0 siblings, 2 replies; 9+ messages in thread
From: Peter Stephenson @ 2006-02-07 14:56 UTC (permalink / raw)
  To: Zsh users list

Mike Hernandez wrote:
> Try this:
> 
> % foo(){ echo "this is a function" }
> % foo
> this is a function
> % vared foo()
> function> echo "vared works... sort of"
> % foo
> vared works... sort of

Err, actually what you're doing there is defining two functions, one
called vared and one called foo, with the same body.  The function>
prompt is the usual continuation prompt.  You'd get it just the same if
the first line were:
% foo() {

Of course, in a case like this you can simply up-arrow and edit the
foo()... a few lines before.

Clint's answer is the most useful... the function zed supplied with the
shell does this.  Remember to autoload it.  Pedantically,

autoload -Uz zed
zed -f foo

Hit ^J when you're finished (or ^X^W if your terminal is weird).

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php


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

* Re: fastest way to bring up a shell function for editing?
  2006-02-07 14:56   ` Peter Stephenson
@ 2006-02-07 15:17     ` Jean-Rene David
  2006-02-07 15:24     ` Mike Hernandez
  1 sibling, 0 replies; 9+ messages in thread
From: Jean-Rene David @ 2006-02-07 15:17 UTC (permalink / raw)
  To: Zsh users list

* Peter Stephenson <pws@csr.com>:
> Clint's answer is the most useful...

Indeed. Thanks very much.

-- 
JR


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

* Re: fastest way to bring up a shell function for editing?
  2006-02-07 14:56   ` Peter Stephenson
  2006-02-07 15:17     ` Jean-Rene David
@ 2006-02-07 15:24     ` Mike Hernandez
  1 sibling, 0 replies; 9+ messages in thread
From: Mike Hernandez @ 2006-02-07 15:24 UTC (permalink / raw)
  To: Zsh users list

On  Tue, Feb 07, 2006 at 02:56:11PM +0000, Peter Stephenson wrote:
> Mike Hernandez wrote:
> > Try this:
> > 
> > % foo(){ echo "this is a function" }
> > % foo
> > this is a function
> > % vared foo()
> > function> echo "vared works... sort of"
> > % foo
> > vared works... sort of
> 
> Err, actually what you're doing there is defining two functions, one
> called vared and one called foo, with the same body.  The function>
> prompt is the usual continuation prompt.  You'd get it just the same if
> the first line were:
> % foo() {
> 
> Of course, in a case like this you can simply up-arrow and edit the
> foo()... a few lines before.
> 
> Clint's answer is the most useful... the function zed supplied with the
> shell does this.  Remember to autoload it.  Pedantically,
> 
> autoload -Uz zed
> zed -f foo
> 
> Hit ^J when you're finished (or ^X^W if your terminal is weird).
> 

I knew if I said something silly like that, that I'd end up learning
something in the end :)

Mike


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

* Re: fastest way to bring up a shell function for editing?
  2006-02-07 14:36 fastest way to bring up a shell function for editing? Jean-Rene David
  2006-02-07 14:38 ` Clint Adams
  2006-02-07 14:46 ` Mike Hernandez
@ 2006-03-02 21:04 ` Julius Plenz
  2006-03-03  2:35   ` Jean-Rene David
  2 siblings, 1 reply; 9+ messages in thread
From: Julius Plenz @ 2006-03-02 21:04 UTC (permalink / raw)
  To: zsh-users

* Jean-Rene David <jrdavid@magma.ca> [2006-02-07 15:38]:
> vared is neat. Is there a "funced" of some sort?

I have these two aliases in use:

aliased() { vared   aliases[$1]; }
funced()  { vared functions[$1]; }

Julius


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

* Re: fastest way to bring up a shell function for editing?
  2006-03-02 21:04 ` Julius Plenz
@ 2006-03-03  2:35   ` Jean-Rene David
  2006-03-03  4:11     ` Dan Nelson
  0 siblings, 1 reply; 9+ messages in thread
From: Jean-Rene David @ 2006-03-03  2:35 UTC (permalink / raw)
  To: zsh-users

* Julius Plenz [2006.03.02 16:15]:
> I have these two aliases in use:
> 
> aliased() { vared   aliases[$1]; }
> funced()  { vared functions[$1]; }

Which means you keep all your aliases and
functions in arrays? 

-- 
JR


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

* Re: fastest way to bring up a shell function for editing?
  2006-03-03  2:35   ` Jean-Rene David
@ 2006-03-03  4:11     ` Dan Nelson
  0 siblings, 0 replies; 9+ messages in thread
From: Dan Nelson @ 2006-03-03  4:11 UTC (permalink / raw)
  To: zsh-users

In the last episode (Mar 02), Jean-Rene David said:
> * Julius Plenz [2006.03.02 16:15]:
> > I have these two aliases in use:
> > 
> > aliased() { vared   aliases[$1]; }
> > funced()  { vared functions[$1]; }
> 
> Which means you keep all your aliases and
> functions in arrays? 

zsh does it automatically (see the description of the zsh/parameter
module).

-- 
	Dan Nelson
	dnelson@allantgroup.com


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

end of thread, other threads:[~2006-03-03  4:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-07 14:36 fastest way to bring up a shell function for editing? Jean-Rene David
2006-02-07 14:38 ` Clint Adams
2006-02-07 14:46 ` Mike Hernandez
2006-02-07 14:56   ` Peter Stephenson
2006-02-07 15:17     ` Jean-Rene David
2006-02-07 15:24     ` Mike Hernandez
2006-03-02 21:04 ` Julius Plenz
2006-03-03  2:35   ` Jean-Rene David
2006-03-03  4:11     ` Dan Nelson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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