简体   繁体   中英

View time taken of last command in fish shell

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

Docs are here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM