This is my .zshrc:
export REPORTTIME=3
When I run sleep 4
it doesn't output anything.
If I change to REPORTTIME=blablabla
(or anything non-sensical) it doesn't raise an error and starts behaving as REPORTTIME=0
, i.e. returning the time taken for everything.
Interestingly, if I try REPORTTIME=3s
I get the following message:
zsh: bad math expression: operator expected at `s'
sleep 4 0.00s user 0.00s system 0% cpu 4.004 total
So I get the error and still the output.
I tried RERPORTTIME="3"
and even REPORTTIME=1+2
. None of these work.
Also, if I run python -c "import time; time.sleep(4)"
I get the same results (so the problem is not with sleep
).
Of course, I tried other values too (other than 3).
I'm running MacOS with iterm2 and zsh is my default shell.
You need to set it explicitly to a non-negative integer representing seconds; i.e.
% REPORTTIME=3
Setting to other non-negative values does not work on my Zsh v5.4.2
either. Running something like a system update (e.g., yaourt
) then
acts as if I had put time
on the front of it. Pretty slick!
So you need a command that eats some user/system time; sleep
does
not. Although total elapsed is long enough, user and system time is
not:
% time sleep 3
sleep 3 0.00s user 0.00s system 0% cpu 3.002 total
Also, no need to export
this since it's directly used by Zsh.
You can undo/turn off this behavior with:
% unset REPORTTIME
Docs on REPORTTIME
from man zshparam
:
If nonnegative, commands whose combined user and system execution times (measured in seconds) are greater than this value have timing statistics printed for them. Output is suppressed for commands executed within the line editor, including completion; commands explicitly marked with the time keyword still cause the summary to be printed in this case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With