How can I make the watch command interpret vt100 sequences?
linux, shell, terminal, unix, watch
Solution
Edit:
More recent versions of `watch` support color. You will need to use an extra level of quoting to preserve the quotes and escapes in the particular situation of the example in the question:
watch 'echo -e "\033[31mHello World\033[0m"'
From `man watch`:
-c, --color
Interpret ANSI color sequences.
Previously:
From `man watch`:
Non-printing characters are stripped from program output. Use "cat -v" as part of the command pipeline if you want to see them.
But they don't get interpreted, so I don't think there's any way.
Problem
Consider this simple example (which displays in red): `echo -e "\033[31mHello World\033[0m"` It displays on the terminal correctly in red. Now consider: `watch echo -e "\033[31mHello World\033[0m"` It does not display the color. Note: I am aware that it is easy to write a loop that mimics the basic behavior by clearing and rerunning. However, the clear operation causes the screen to flash, which does not happen under watch EDIT: Originally this question specified escape sequences rather than vt100 sequences, but that is not really what I am after, and was solved with single quotes.