On Mon, Mar 27, 2023 at 08:52:10AM -0400, Dan Ritter wrote:
> Greg Wooledge wrote: 
> > 3) apt uses a horrible yellow color that is nigh-unreadable on a white
> >    background.  (This is not configurable.)
> 
> It appears that it is, just badly documented.
> 
> In /etc/apt/apt.conf, you can specify the escape sequences for
> colors like this:
> 
> APT::Color::Yellow "ESC[33m";

unicorn:~$ man apt.conf | grep -i -e color -e colour
unicorn:~$ man apt-config | grep -i -e color -e colour
unicorn:~$ 

Yeah, that's "badly documented" i.e. "not documented at all".

Here are some other things one might find by poking around the web or
various commands:

apt-config(8)
        dump
            Just show the contents of the configuration space.

unicorn:~$ apt-config dump | grep -i -e color -e colour
Binary::apt::APT::Color "1";

So, there's a quasi-visible configuration element that lets you turn off
apt's use of colors completely.  Undocumented, obviously.

Your APT::Color::Yellow is not even visible in the dump of all the
configuration elements.

<https://salsa.debian.org/apt-team/apt/-/blob/main/doc/examples/configure-index>
contains:

    apt::moo::color "<BOOL>";

    apt::color::highlight "<STRING>";
    apt::color::neutral "<STRING>";

    APT::Color "<BOOL>";

I have no idea how out of date or inaccurate these may be.

It's also incredibly difficult to TEST any changes to apt's color
configuration, because the parts I care about are circumstantial.
The yellow color is used on the progress/status line while apt
is downloading stuff -- and if you've already run "apt update" earlier
today, chances are there won't be any new data to download when you run
it a second time.

If I use "apt search google-chrome-stable" I get the following text:

unicorn:~$ apt search google-chrome-stable
Sorting... Done
Full Text Search... Done
google-chrome-stable/stable,now 111.0.5563.110-1 amd64 [installed]
  The web browser from Google

where the package name (google-chrome-stable) appears green.  So...
can I test using that?  It appears I cannot.

If I put Binary::apt::APT::Color "0"; in my /etc/apt/apt.conf.d/99local
file, and re-run the apt search command, it's still green.

If I put APT::Color::Green "ESC[33m"; in there and re-run the apt search
command, it's also still green.  Is "ESC" supposed to be exactly that,
the capital letters E, S and C?  Or is it supposed to be a raw ASCII Esc
character?  If I change it to a raw Esc character and re-run the apt search
command ... the package name is still green.

More web searching... here's another page,
<https://unix.stackexchange.com/questions/392791/apt-configure-the-colors>.
One of the answers says:

    Despite defining several colours, apt currently (1.8.2) doesn't
    use most of them. Highlight and Neutral are used in a few places,
    but none of the colours are except Yellow. It appears in one line
    in acqprogress.cc as the output colour for status.

So, if I put APT::Color::Highlight "ESC[33m"; in my file and re-run the
command, I get:

unicorn:~$ apt search google-chrome-stable
Sorting... Done
Full Text Search... Done
ESC[33mgoogle-chrome-stable/stable,now 111.0.5563.110-1 amd64 [installed]
  The web browser from Google

Aha!  So it does use that particular configuration element, and it does
expect a raw Esc character.  But just to be absolutely sure, I'll try
a backslash+e first:

unicorn:~$ apt search google-chrome-stable
Sorting... Done
Full Text Search... Done
\e[33mgoogle-chrome-stable/stable,now 111.0.5563.110-1 amd64 [installed]
  The web browser from Google

Nope.  Raw it must be.  Unfortunately, I can't test APT::Color::Yellow
because it depends on ephemeral state.

It's also quite curious that "apt search" uses the Highlight color even
when Binary::apt::APT::Color is set to "0".  Bug?  Well, it can't be a
bug if it's not documented.  But it's really stupid.  And it makes me
wonder just what Binary::apt::APT::Color actually controls.

Reply via email to