Search code examples
linuxbashubuntuwatch

Colors with unix command "watch"?


Some commands that I use display colors, but when I use them with watch the colors disappears:

watch -n 1 node file.js

Is it possible to have the colors back on somehow?


Solution

  • Some newer versions of watch now support color.

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

    Related.

    If you're seeing monochrome output when you expect color, it's likely that the command you're running within watch is detecting that it's not attached to the terminal and you'll need to force color output. Some examples:

    CLICOLOR_FORCE=1 watch --color ls -ahl    # MacOS
    watch --color ls -ahl --color=always      # Ubuntu
    

    For ls and other programs you may need to do other configuration, but that will show up even if you're not using watch.