17

I get colored tree using tree -C but when I pipe it to less I get results like this:

tree public/ -C | less

enter image description here

How can I have colors in less in this case?

2 Answers 2

20

You want the -R switch to less.

From the less man page:

-R or --RAW-CONTROL-CHARS Like -r, but only ANSI "color" escape sequences are output in raw" form. Unlike -r, the screen appearance is maintained correctly in most cases. ANSI "color" escape sequences are sequences of the form:

            ESC [ ... m

So you need

tree -C public/ | less -R
0
3

Passing -r to less will tell it to pass through control characters and escape sequences unmolested.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.