Pipe to less but keep the highlighting
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Riding Sky Waves v001
--
Chapters
00:00 Pipe To Less But Keep The Highlighting
00:18 Accepted Answer Score 54
00:53 Answer 2 Score 2
01:13 Answer 3 Score 1
01:38 Thank you
--
Full question
https://superuser.com/questions/940014/p...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#pipe #syntaxhighlighting #less #highlighting
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Riding Sky Waves v001
--
Chapters
00:00 Pipe To Less But Keep The Highlighting
00:18 Accepted Answer Score 54
00:53 Answer 2 Score 2
01:13 Answer 3 Score 1
01:38 Thank you
--
Full question
https://superuser.com/questions/940014/p...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#pipe #syntaxhighlighting #less #highlighting
#avk47
ACCEPTED ANSWER
Score 54
Use the --human
parameter to view colored dmesg
output in a less
-like environment.
dmesg --human --color=always
Or use the short version:
dmesg -H
Alternatively, use the following command to achieve similar results.
dmesg --color=always | less -R
Many other utilities that produce colored output (ls
, grep
, etc.) have a similar --color=always
option.
ANSWER 2
Score 2
A generic command to preserve coloration independent of the program providing the output is the unbuffer
command (which is part of the expect
package).
Usage:
unbuffer dmesg | less -R
ANSWER 3
Score 1
Yes, it works nice.
for tree:
tree -C | less -r
for ls:
ls -lA --color=always | less -r
for pytest:
py.test --color=yes | less -r