I'm aware that I can use time
as
time <some command>
But this requires me to remember to type time
before <some command>
I'm wondering if it's possible create some sort of hook, so that time
is run for every command, but only displayed if I enter last-time
or something at the cli.
An example usage might be:
$ sleep 2
$ last-time
________________________________________________________
Executed in 2.00 secs fish external
usr time 2.28 millis 912.00 micros 1.37 millis
sys time 0.30 millis 296.00 micros 0.00 millis
The $CMD_DURATION
variable contains the duration of the last-run interactive command, in milliseconds.
$ sleep 2
$ echo $CMD_DURATION
2014