Command timer

Jan 19, 2011
581
10
Norman, OK
#1
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
#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
581
10
Norman, OK
#3
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.
 
#5
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".)
 
#6
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.
 
#7
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!).