Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Get the current command line from a function
- X-seq: zsh-users 14391
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Get the current command line from a function
- Date: Tue, 15 Sep 2009 20:31:14 -0700
- In-reply-to: <20090915101929.GS949@xxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20090915101929.GS949@xxxxxxxxxxxxxxxxxxx>
On Sep 15, 12:19pm, Frank Blendinger wrote:
}
} I would like to get the entered command line from a function, just like
} !!, but at an earlier time. An example:
}
} foo -x -y | my-func -z
}
} I'd like to get the whole line within my-func, so obviously $0 $* don't
} work. Is there a way to do that?
So what you mean is that you want "my-func" to be able to access the
string "foo -x -y | my-func -z" ? Or you mean something else, such
as the contents of the current line of the function body?
If the former, then in an interactive shell only (so history is active)
you can do
zmodload zsh/parameter
and then refer to
$history[$HISTCMD]
to get the currently-executing history event. In the general case,
though (e.g., in a shell script) it is not possible to do that.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author