Most likely your ls is aliased to ls --color=auto, which tells ls to only use colors when its output is a tty. If you do ls --color (which is morally equivalent to ls --color=always), that will force it to turn on colors.
You could also change your alias to do that, but I wouldn't really call that a good idea. Better to make a different alias with --color.
less needs -R too, which causes it to output the raw control characters.
Most likely your
ls
is aliased tols --color=auto
, which tellsls
to only use colors when its output is a tty. If you dols --color
(which is morally equivalent tols --color=always
), that will force it to turn on colors.You could also change your alias to do that, but I wouldn't really call that a good idea. Better to make a different alias with
--color
.less
needs-R
too, which causes it to output the raw control characters.Try less with the -R option like this:
This works for me in a one-liner like this:
And like this too:
But you have to tweak the primary output (the output of ls in this case) a bit with the --color parameter.