0

I find out ccat which is a command to colorize the usual cat command. Is there a way to pipe this in less mantaining colors?

If I do ccat config.json | less there's no color!

Thanks in advance.

4
  • 2
    less -R will show colorized output Commented Mar 3, 2020 at 16:01
  • Sadly it doesn't work with less -R as you can see with this asciinema: asciinema.org/a/Hw1n48N8VbJ0ak6mdrYkS5MvI Commented Mar 5, 2020 at 7:48
  • @Cirelli94 you also have to tell ccat to send colorised output to less (which it probably doesn't, like most decent tools when output is not a terminal). Probably with --color=always if it follows GNU conventions Commented Mar 6, 2020 at 2:23
  • Thanks for your help @muru, I find out the correct option in ccat! Commented Mar 6, 2020 at 9:47

1 Answer 1

1

As cat --help explain, I have to use color option:

-C, --color="auto": colorize the output; value can be "never", "always" or "auto" Using color is auto both by default and with --color=auto. With --color=auto, ccat emits color codes only when standard output is connected to a terminal. 

So to have less colorized I need to do:

ccat --color="always" config.json | less 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.