Globally disabling colour

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Globally disabling colour

Dr Rainer Woitok
Greetings,

having freshly erm ... converted from Ubuntu to Gentoo and thus being an
absolute Gentoo newbie  I'm desparately looking  for a way to get rid of
all the colour in the output  produced by "emerge"  but also by "qlist",
"eix", "e-file" and so on.

Is there a way to globally configure this for all these commands?   I've
already added  'NOCLOR="false"'  to my "make.conf" file but this doesn't
seem to do the trick.  Do I really have to remember for each call to one
of these commands to disable colour individually and in addition have to
remember what's the correct "nocolor" option for the command at hand?

Any pointers welcome ... :-)

Sincerely,
  Rainer

Reply | Threaded
Open this post in threaded view
|

Re: Globally disabling colour

Arve Barsnes
On Tue, 1 Oct 2019 at 13:28, Dr Rainer Woitok <[hidden email]> wrote:

> having freshly erm ... converted from Ubuntu to Gentoo and thus being an
> absolute Gentoo newbie  I'm desparately looking  for a way to get rid of
> all the colour in the output  produced by "emerge"  but also by "qlist",
> "eix", "e-file" and so on.
>
> Is there a way to globally configure this for all these commands?   I've
> already added  'NOCLOR="false"'  to my "make.conf" file but this doesn't
> seem to do the trick.  Do I really have to remember for each call to one
> of these commands to disable colour individually and in addition have to
> remember what's the correct "nocolor" option for the command at hand?

There was a similar question from someone else this summer, maybe this
will help you.

https://archives.gentoo.org/gentoo-user/message/e0528fd2b468b350aac9ff440f132683

Regards,
Arve

Reply | Threaded
Open this post in threaded view
|

Re: Globally disabling colour

Mick-10
In reply to this post by Dr Rainer Woitok
On Tue, 1 Oct 2019 at 12:29, Dr Rainer Woitok <[hidden email]> wrote:

>
> Greetings,
>
> having freshly erm ... converted from Ubuntu to Gentoo and thus being an
> absolute Gentoo newbie  I'm desparately looking  for a way to get rid of
> all the colour in the output  produced by "emerge"  but also by "qlist",
> "eix", "e-file" and so on.
>
> Is there a way to globally configure this for all these commands?   I've
> already added  'NOCLOR="false"'  to my "make.conf" file but this doesn't
> seem to do the trick.

I don't know if you have misspelled the above parameter.  Try setting:

NOCOLOR="true"

However, terminal colors are set differently - see thread mentioned by Arve.
--
Regards,
Mick

Reply | Threaded
Open this post in threaded view
|

Re: Globally disabling colour

Håkon Alstadheim
In reply to this post by Dr Rainer Woitok

Den 01.10.2019 13:28, skrev Dr Rainer Woitok:

> Greetings,
>
> having freshly erm ... converted from Ubuntu to Gentoo and thus being an
> absolute Gentoo newbie  I'm desparately looking  for a way to get rid of
> all the colour in the output  produced by "emerge"  but also by "qlist",
> "eix", "e-file" and so on.
>
> Is there a way to globally configure this for all these commands?   I've
> already added  'NOCLOR="false"'  to my "make.conf" file but this doesn't
> seem to do the trick.  Do I really have to remember for each call to one
> of these commands to disable colour individually and in addition have to
> remember what's the correct "nocolor" option for the command at hand?
>
> Any pointers welcome ... :-)

I've got this in make.conf, which gets me part-way there:

CMAKE_COLOR_MAKEFILE=OFF
NOCOLOR="true"
GCC_COLORS=""

I've also got this in /usr/local/bin/rustc and symlinked to
/usr/local/bin/cargo:

----/usr/local/bin/rustc:----#!/usr/bin/perlmy @newargs=();my $skipnext=0;my $me=$0;$me =~
s(.*\/)();push @newargs, "--color";push @newargs, "never";foreach $arg
(@ARGV) {    if($arg eq "--color"){    $skipnext =1;    }
elsif($skipnext == 1){    $skipnext = 0;    } else { # any arg EXCEPT
color gets passed along verbatim     push @newargs, $arg   
}}exec("/usr/bin/${me}",@newargs);
---

This last trick could probably be used for other commands as well
(modulo specific argument)



Reply | Threaded
Open this post in threaded view
|

Re: Globally disabling colour

Dr Rainer Woitok
Hakon,

On Tuesday, 2019-10-01 16:07:55 +0200, you wrote:

> ...
> I've got this in make.conf, which gets me part-way there:
>
> CMAKE_COLOR_MAKEFILE=OFF
> NOCOLOR="true"
> GCC_COLORS=""

I already had the  "NOCOLOR" environment variable set  (there was a typo
in my mail, not in my "make.conf" file :-),  but the Cmake and Gcc spec-
ific environment variables were not yet there.  Thankyou for this tip.

> I've also got this in /usr/local/bin/rustc and symlinked to
> /usr/local/bin/cargo:

This assumes "/usr/local/bin" to precede "/usr/bin" in environment vari-
able "PATH".  Can I set this for Portage only in "make.conf"?

> ----/usr/local/bin/rustc:----#!/usr/bin/perlmy @newargs=();my $skipnext=0;my $me=$0;$me =~
> s(.*\/)();push @newargs, "--color";push @newargs, "never";foreach $arg
> (@ARGV) {    if($arg eq "--color"){    $skipnext =1;    }
> elsif($skipnext == 1){    $skipnext = 0;    } else { # any arg EXCEPT
> color gets passed along verbatim     push @newargs, $arg   
> }}exec("/usr/bin/${me}",@newargs);
> ---

Alas,  this code snippet did not survive  mail transmission :-(.   Could
you please run

   perl -MMIME::Base64 -ne 'print encode_base64($_)' < /usr/local/bin/rustc

and post (or send me privately) the base64 encoded output?  Thankyou.

Sincerely,
  Rainer

Reply | Threaded
Open this post in threaded view
|

Re: Globally disabling colour

Håkon Alstadheim

Den 02.10.2019 11:01, skrev Dr Rainer Woitok:

> Hakon,
>
> On Tuesday, 2019-10-01 16:07:55 +0200, you wrote:
>
>> ...
>> I've got this in make.conf, which gets me part-way there:
>>
>> CMAKE_COLOR_MAKEFILE=OFF
>> NOCOLOR="true"
>> GCC_COLORS=""
> I already had the  "NOCOLOR" environment variable set  (there was a typo
> in my mail, not in my "make.conf" file :-),  but the Cmake and Gcc spec-
> ific environment variables were not yet there.  Thankyou for this tip.
>
>> I've also got this in /usr/local/bin/rustc and symlinked to
>> /usr/local/bin/cargo:
> This assumes "/usr/local/bin" to precede "/usr/bin" in environment vari-
> able "PATH".  Can I set this for Portage only in "make.conf"?
Correct.

>> ----/usr/local/bin/rustc:----#!/usr/bin/perlmy @newargs=();my $skipnext=0;my $me=$0;$me =~
>> s(.*\/)();push @newargs, "--color";push @newargs, "never";foreach $arg
>> (@ARGV) {    if($arg eq "--color"){    $skipnext =1;    }
>> elsif($skipnext == 1){    $skipnext = 0;    } else { # any arg EXCEPT
>> color gets passed along verbatim     push @newargs, $arg  Â
>> }}exec("/usr/bin/${me}",@newargs);
>> ---
> Alas,  this code snippet did not survive  mail transmission :-(.   Could
> you please run
>
>     perl -MMIME::Base64 -ne 'print encode_base64($_)' < /usr/local/bin/rustc
>
> and post (or send me privately) the base64 encoded output?  Thankyou.
>
> Sincerely,
>    Rainer
Just doing an attachment, so you'll get the charset as well. Don't know
if that gets through to the list.



rustc (624 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Globally disabling colour

Dr Rainer Woitok
In reply to this post by Håkon Alstadheim
Greetings and a Happy New Year to all of you :-)

Way back on Tuesday, 2019-10-01 16:07:55 +0200, Håkon Alstadheim wrote:

> Den 01.10.2019 13:28, skrev Dr Rainer Woitok:
> > ...
> >                         I'm desparately looking  for a way to get rid of
> > all the colour in the output  produced by "emerge"  but also by "qlist",
> > "eix", "e-file" and so on.
> > ...
> ...
> I've also got this in /usr/local/bin/rustc and symlinked to
> /usr/local/bin/cargo:
>
> ----/usr/local/bin/rustc:----
> #!/usr/bin/perl
> my @newargs=();
> my $skipnext=0;
> my $me=$0;
> $me =~ s(.*\/)();
> push @newargs, "--color";
> push @newargs, "never";
> foreach $arg (@ARGV) {
>     if($arg eq "--color"){
> $skipnext =1;
>     } elsif($skipnext == 1){
> $skipnext = 0;
>     } else {
> push @newargs, $arg
>     }
> }
> exec("/usr/bin/${me}",@newargs);

I've used this script ever since  (even though  I had to slightly modify
it when I learned that  "--color=yes"  is also a valid option  which was
not detected  by the original version).   However, yesterday I found the
following:

   error: cannot specify the `--color` option with `--json`

Regardless of whether this  was a change to "rustc"  or of whether up to
now none of my builds used "rustc" with "--json": the effort to keep the
script compatible  with the current versions  of "rustc" and "cargo" now
by far outweighs the nuisance of colour in build logs for me.  Of course
anybody else's milage  might vary,  but I think  anybody else using this
script should at least know.

It was a nice workaround, though.  Thankyou Hakon :-)

Sincerely,
  Rainer

Reply | Threaded
Open this post in threaded view
|

Re: Globally disabling colour

Robert Bridge
I had this issue many moons ago, which lead to my discovery of the ansifilter package:

> # emerge -pv ansifilter | ansifilter
>
> These are the packages that would be merged, in order:
>
> Calculating dependencies  . ... done!
> [ebuild   R    ] app-text/ansifilter-2.15::gentoo  USE="qt5" 0 KiB
>
> Total: 1 package (1 reinstall), Size of downloads: 0 KiB

It strips all the terminal escape chars which are how applications do the color in their terminal output. Very handy when combined with pastebin utilities.

Cheers,
Robert.

Reply | Threaded
Open this post in threaded view
|

Re: Globally disabling colour

Dr Rainer Woitok
Robert,

On Sunday, 2020-01-05 12:17:23 +0000, you wrote:

> I had this issue many moons ago, which lead to my discovery of the
> ansifilter package:
>
> > # emerge -pv ansifilter | ansifilter

Nice find.  However, this only produces a clean terminal window but does
not prevent all the garbage in "/var/log/portage/" :-\

Sincerely,
  Rainer

Reply | Threaded
Open this post in threaded view
|

Re: Globally disabling colour

Robert Bridge
But it can easily strip the garbage from that file when you need to use the contents...

> # ansifilter /var/log/portage/elog/summary.log-20200105 | less

On Sun, 5 Jan 2020 at 12:45, Dr Rainer Woitok <[hidden email]> wrote:
Robert,

On Sunday, 2020-01-05 12:17:23 +0000, you wrote:

> I had this issue many moons ago, which lead to my discovery of the
> ansifilter package:
>
> > # emerge -pv ansifilter | ansifilter

Nice find.  However, this only produces a clean terminal window but does
not prevent all the garbage in "/var/log/portage/" :-\

Sincerely,
  Rainer