4 ms·
wouldn't it be more useful to show the time difference? Or maybe only show it in case it is larger than 1 second?
by enriquto 6y ago
wouldn't it be more useful to show the time difference? Or maybe only show it in case it is larger than 1 second?
- Izkata 6y agoI do that, if it's over 60 seconds - it's not as straightforward since you also need to use PROMPT_COMMAND, a debug trap, and a variable to store the start time: https://jakemccrary.com/blog/2015/05/03/put-the-last-commands-run-time-in-your-bash-prompt/ https://jakemccrary.com/blog/2015/05/03/put-the-last-command...
- chriswarbo 6y agoDuration and start time can both be useful, and the former can be calculated from the latter as needed. Plus it's easier to implement (stateless) and has consistent alignment (always 10 digits). BTW here's the function I use: ``` showTime() { if [[ "$?" -eq 0 ]] then TIMECOLOR='\e[92m' else TIMECOLOR='\e[91m' fi echo -e "$TIMECOLOR$(date '+%s')\e[0m" } ```