Command timer

Jan 19, 2011
614
15
Norman, OK
Using @timediff in Charles Dye's ISO8601 plugin combined with the PRE_EXEC alias, I've created a permanent command line timer on my PROMPT (which uses ANSI codes) that shows the duration of the previously executed command.
Code:
alias PRE_EXEC=`set STARTTIME=%_TIME`
PROMPT=`$e[35;2m%@timediff[%STARTTIME,%_TIME]$e[0m$_$e[32;2m[$P]$_$e[35;1m$t$s$$$e[0m$s`
 
May 31, 2008
382
2
Nice. I use something similar based on Vince Fatica's 4UTILS plugin - my prompt displays variable %[pr.z]
Code:
alias PRE_EXEC=`set pr.z=%@CLOCK[0]`
alias POST_EXEC=`set pr.z=%@TCONVERT[%@eval[(%@CLOCK[0]-%[pr.z])/1000]]`
 
Jan 19, 2011
614
15
Norman, OK
Nice. I use something similar based on Vince Fatica's 4UTILS plugin - my prompt displays variable %[pr.z]
Code:
alias PRE_EXEC=`set pr.z=%@CLOCK[0]`
alias POST_EXEC=`set pr.z=%@TCONVERT[%@eval[(%@CLOCK[0]-%[pr.z])/1000]]`
I like the millisecond accuracy.
 
May 24, 2010
855
0
Northlake, Il
And to make it even easier to use, an alias:
Code:
Ela*psedTime=*Echo %PR.Z
(Just a note. I couldn't get "PR.Z" to work (and really don't understand that variable name when you come right down to it) on this machine so I used another variable name and everything's fine. Echoing "%PR.Z" here yields ".Z".)
 
May 20, 2008
12,173
133
Syracuse, NY, USA
And to make it even easier to use, an alias:
Code:
Ela*psedTime=*Echo %PR.Z
(Just a note. I couldn't get "PR.Z" to work (and really don't understand that variable name when you come right down to it) on this machine so I used another variable name and everything's fine. Echoing "%PR.Z" here yields ".Z".)
Try %[PR.Z]. Without the []s the '.' terminates the variable name.
 
May 24, 2010
855
0
Northlake, Il
Thanks for the info, Vince. However, I have only used that construction for indirection in the past (a variable that contains a variable) and I wouldn't have thought that the very syntax of variable names would be different inside of brackets. (Might be documented, but I'm too lazy to look.) Therefore that construction would be considerably beyond my current habits, and I'm a very habit-driven person at this point in my life (a side-effect of very bad memory!).