How can I make the watch command interpret vt100 sequences?

前端 未结 3 1505
长情又很酷
长情又很酷 2021-01-04 00:39

Consider this simple example (which displays in red):

echo -e \"\\033[31mHello World\\033[0m\"

It displays on the terminal correctly in red. No

3条回答
  •  猫巷女王i
    2021-01-04 01:05

    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.

提交回复
热议问题