bash watch command with colors preserved

The right command is

watch --color "ls -a1 --color"

It isn't documented in the man page or the --help screen. I has to use strings to find it.


I think it may not be possible with the 'watch' command. Here is a longer way of doing it:

while true; do clear; date;echo;ls -al --color; sleep 2; done

You could put this in a script, for example:

echo "while true; do clear; date;echo;\$*;sleep 2; done" > watch2
chmod +x watch2
./watch2 ls -al --color

To clarify, here's why I think it's not possible with the 'watch' command. See what happens if you use cat -v:

watch "ls -al --color|cat -v"

It shows you the color control characters...which I think is not what you want.


If you're using a Mac, like me, watch from Homebrew does not support colour.

What you want is fswatch but it's not Homebrew yet. To install it you'll want to do the slightly more convoluted

https://raw.github.com/mlevin2/homebrew/116b43eaef08d89054c2f43579113b37b4a2abd3‌​/Library/Formula/fswatch.rb

See this SO answer for usage.