防止“less -R”跨换行重置颜色

Pra*_*han 5 bash colors ansi-colors

我如何less通过-R或以其他方式告诉不要跨换行符(\n)重置颜色?这是我所看到的一个例子:

$ echo -e '\033[31mThis is red.\nStill red.\n\033[0mBack now.' >> coltest
$ cat coltest
This is red. #Colour is red
Still red.   #Colour is red
Back now.    #Colour is the terminal's foreground colour.
$ less -RF coltest
This is red. #Colour is red
Still red.   #Colour is the terminal's foreground colour.
Back now.    #Colour is the terminal's foreground colour.
Run Code Online (Sandbox Code Playgroud)

为什么Still red.在输出中重置为终端的前景色的颜色less -RF?

小智 2

对于某些用例more可能就足够了:

printf '\033[31mThis is red.\nStill red.\n\033[0mBack now.\n' >> coltest


more coltest
Run Code Online (Sandbox Code Playgroud)