Colors with unix command "watch"?

Some newer versions of watch now support color.

For example watch --color ls -ahl --color.

Related.


Do not use watch ... When you use watch programs can detect they're not writing to a terminal and then strip the color. You must use specific program flags to keep the control codes there.

If you don't know the flags or there isn't you can make a poor's man watch by:

while sleep <time>; do clear; <command>; done

It will have a bit of flicker (watch works "double buffered") but for some stuff it is useful enough.

You may be tempted to make a double buffered poor man's watch using

while sleep <time>; do <command> > /tmp/file; clear; cat /tmp/file; done

But then you'll hit again the "I am not writing to a terminal" feature.