Zsh Mailing List Archive
Messages sorted by:
Re: variable containing the current command
- X-seq: zsh-users 2346
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxxxxxx
- Subject: Re: variable containing the current command
- Date: Wed, 26 May 1999 22:17:41 +0000
- In-reply-to: <19990526202314Z13566-3056+232@xxxxxxxxxxxxxxxxxxxx>
- In-reply-to: <19990526174044.A7264@xxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <19990526202314Z13566-3056+232@xxxxxxxxxxxxxxxxxxxx> <19990526174044.A7264@xxxxxxxxxxxxxxxxxxxx>
On May 26, 2:23pm, benjamin@xxxxxxxxxxxxxx wrote:
> Subject: variable containing the current command
> Is there a zsh environment variable that contains the current command
> so that it can be referenced in preexec() or precmd() (or ideally both)?
In preexec, the positional parameter $1 holds the entire command line just
as it was read from the terminal (after history expansion but before any
You could have preexec copy this to a global parameter where precmd can
see it later.
On May 26, 5:40pm, Sweth Chandramouli wrote:
> Subject: Re: variable containing the current command
> $_ is almost what you are looking for; it is supposed to be set for
> any command to the full name of that command.
That's not quite correct. From the doc:
The last argument of the previous command. Also, this parameter
is set in the environment of every command executed to the full
pathname of the command.
So it's only during the execution of a command that you can find the path
of that command in $_. Once you're back in the shell (as during precmd),
you get the last word of the previous command line (not the first; try
your "ls" example with some file name arguments to "ls").
As for this:
> (astaroth/3)~: ls
> Ready to do:preexec
I suspect it has something to do with how or when preexec is executed.
PWS could tell us more, but he's out for a few days.
Messages sorted by: