Colors with unix command “watch”?

前端 未结 6 807
无人及你
无人及你 2020-12-12 17:57

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 ha

6条回答
  •  独厮守ぢ
    2020-12-12 18:11

    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 

    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 

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

提交回复
热议问题