Enable bash output color with Lua script

前端 未结 2 609
既然无缘
既然无缘 2021-02-13 18:33

I have several Lua scripts that run experiences and output a lot of information, in text files and in the console. I\'d like to add some colors in the console output, to make it

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-13 18:34

    lua -e "print('This is red->\27[31mred\n')"

    Note the \27. Whenever Lua sees a \ followed by a decimal number, it converts this decimal number into its ASCII equivalent. I used \27 to obtain the bash \033 ESC character. More info here.

提交回复
热议问题