Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: variable containing the current command



On Wed, May 26, 1999 at 02:23:10PM -0600, benjamin@xxxxxxxxxxxxxx wrote:
> Is there a zsh environment variable that contains the current command
> so that it can be referenced in preexec() or precmd() (or ideally both)?
> 
> e.g.
> 
> precmd() { echo "Just did:$CURRENT_CMD" }
> preexec() { echo "Ready to do:$CURRENT_CMD" }
> 
> localhost[1]% ls
> Ready to do:ls
> foo		bar		snafu		tarfu
> Just did:ls
> localhost[2]%
	$_ is almost what you are looking for; it is supposed to be set for
any command to the full name of that command.  if you use it as you use 
CURRENT_CMD above, however, you get something like this:

(astaroth/1)~: precmd() { echo "Just did:$_" }
Just did:precmd
(astaroth/2)~: preexec() { echo "Ready to do:$_" }
Just did:preexec
(astaroth/3)~: ls
Ready to do:preexec
appconfig    Mail         News         public_html  working
bin          mail         news         src          www
docs         misc         nohup.out    tmp
Just did:ls
(astaroth/4)~: 

	i could never figure out why it acts that way, though, so i've
never really used it.

	-- sweth.

-- 
Sweth Chandramouli
IS Coordinator, The George Washington University
<sweth@xxxxxxx> / (202) 994 - 8521 (V) / (202) 994 - 0458 (F)
<a href="http://astaroth.nit.gwu.edu/~sweth/disc.html";>*</a>



Messages sorted by: Reverse Date, Date, Thread, Author