Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 211279 - sys-apps/less doesn't show colors for user request.
Summary: sys-apps/less doesn't show colors for user request.
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: High trivial (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-24 17:15 UTC by Naray Gabor
Modified: 2008-02-25 16:44 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Naray Gabor 2008-02-24 17:15:20 UTC
I am trying to make less output colored for a while. I have read everything how to do that, and tried all, but none worked.

Things I have tried:

export LESS="-R"
tried export LESSCOLOR="always" and export LESSCOLOR="yes"
tried both export LESSOPEN='|lesspipe.sh %s', and unset LESSOPEN

The result was always the same:

echo "asdqwe" | grep --colour=auto "asd"  :: Colored output.
echo "asdqwe" | grep --colour=auto "asd" | less -R :: Colorless output.

Man and all the other programs has colors which use less as pager, but when i append `` | less -R '' to command line, the output becomes black'n'white, and can't change that.

Nobody has written anything else than to change this variables to make less inherit colors to output.
Comment 1 Harald van Dijk (RETIRED) gentoo-dev 2008-02-24 17:41:31 UTC
grep --colour=auto only uses colouring when the output is a tty. When you pipe the output through another program, colours will be suppressed. The same thing will happen if you pass the output to cat.
Comment 2 Naray Gabor 2008-02-25 14:36:11 UTC
But this happens not only with grep, but with any other colored input i redirect. emerge, eix, or try to save it. So this is how colors are handled? if not going to tty, then suppressed? What reason has less -R then? Do you think this is a good solution? Well maybe for you it is. But not for me. But then, could you give me a guide where to start to make gentoo not to delete color codes from output if not going to tty?

This could result a nice review of emerge log-s, eix lists - where colors are VERY important -, greps and stuff like that. I know this will lead to unexpected results for example in pattern matching. Will take the risk. But still I don't think this is the way it should work.
Comment 3 SpanKY gentoo-dev 2008-02-25 16:44:21 UTC
most utilities out there will disable color output automatically if the output is not a tty.  this is the expected design behavior.  if you dislike it, you can force each utility to display color in the output.  read the relevant documentation for each utility (such as grep --color=always).  there's nothing to be "fixed" here.