How to make ls | less colorful?

Using lsor many other commands, we can get colorful results as follows:

enter image description here

But if these results are too large, and after we pass these results in less, the color will disappear.

This is the result ls -l | less:

enter image description here

  • Why color fades.
  • How to make the result ls | lesscolor?
+4
source share
1 answer

On the manls page for :

Using an option --colorwithout an optional WHEN argument is equivalent to using it --color=always.

--color=auto , (tty).

, always .

less:

-r or --raw-control-chars

"" .

, :

ls -l --color | less -r
+5

All Articles