From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7181 invoked from network); 26 May 1999 22:18:03 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 26 May 1999 22:18:03 -0000 Received: (qmail 26751 invoked by alias); 26 May 1999 22:17:49 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2346 Received: (qmail 26744 invoked from network); 26 May 1999 22:17:47 -0000 From: "Bart Schaefer" Message-Id: <990526221741.ZM22768@candle.brasslantern.com> Date: Wed, 26 May 1999 22:17:41 +0000 In-Reply-To: <19990526202314Z13566-3056+232@scapa.cs.ualberta.ca> Comments: In reply to benjamin@cs.ualberta.ca "variable containing the current command" (May 26, 2:23pm) References: <19990526202314Z13566-3056+232@scapa.cs.ualberta.ca> <19990526174044.A7264@astaroth.nit.gwu.edu> In-Reply-To: <19990526174044.A7264@astaroth.nit.gwu.edu> Comments: In reply to Sweth Chandramouli "Re: variable containing the current command" (May 26, 5:40pm) X-Mailer: Z-Mail Lite (5.0.0 30July97) To: zsh-users@sunsite.auc.dk Subject: Re: variable containing the current command MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On May 26, 2:23pm, benjamin@cs.ualberta.ca 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 other expansions/substitutions). 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.