CLI Magic: Use ANSI escape sequences to display a clock in your terminal
Posted by: Anonymous
on January 22, 2008 09:07 PM
Nice script, but why do you query the COLOR and NORMAL variables every single second? I mean, they hardly ever change. Simply put that ontop of the while - do loop and your save quite a lot of cycles. The same could be said for the date aquisition: if you sleep 1sec all the time, why not get the time in the beginning, increase secs till 59 and then query again. Every program you call outside of bash uses quite a lot of cycles, if you stay inside of bash (declare -i sec; ...; sec++) you use way less cycles.
With todays CPUs it's close to negligible but nevertheless a better coding style.