0

I'm trying to get colored less output in my terminal. Below is how I expect the output to look, and underneath that what "less -r" or "less -R" actually produces.

enter image description here

enter image description here

I'm using a build of suckless st that's collected here:

https://github.com/Lukesmithxyz/st

And I haven't really customized it at all.

I should also mention that every other terminal I've tried (including TTY2) has the same behavior.

Any ideas are appreciated.

2

You need to force ls to use colours, otherwise it disables them when not writing to a terminal:

ls -l --color | less -R

You can also use unbuffer (part of expect):

unbuffer ls -l | less -R
4
  • Ok! That's good for ls, but is that the only way you can get colors into less? Telling the preceding program to ignore the fact that it's a pipe? Is there a more general way of tricking programs into thinking that my pipe is a terminal? – fpf3 May 21 '20 at 14:39
  • We already have this Q&A at unix.stackexchange.com/q/249723/5132 . – JdeBP May 21 '20 at 15:32
  • @JdeBP thanks. I believe you’re familiar enough with SE to know what to do in such cases ;-). – Stephen Kitt May 21 '20 at 15:34
  • The mark answer comment as a duplicate of this question button is still hidden at this level of damage points. (-: – JdeBP May 23 '20 at 6:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.