2

enter image description here

My immediate itch is the status line in apt upgrade / apt update that is a tone of yellow — as I use a light background it is almost unreadable...

I tried the apt man page but /colou?r give no matches.

I tried Google but what I found is something on StackExchange that gave a reply for a specific use case, different from mine, and no reference resource.

I'd like also a specific answer scratching my issue above, but what I'd like best is a pointer to some (un)official doc that explain the colors in apt and how to modify each default.

tx in advance

ps apt as the command line utility — the packaging infrastructure of Debian-like distros is Apt.

4
  • Your best bet here is to ask the apt maintainers themselves. They hang out on OFTC. I think the channel is #debian-apt. If I get around to it, I might ask them myself. If there is an option to do this, isn't undocumented. It's possible it is hardwired, but I agree, it should be configurable. So if it is hardwired, I recommend filing a wishlist bug on the Debian BTS. Sep 18, 2017 at 10:01
  • Just posted a comment on #debian-apt. If they have an answer, I'll update the question. Sep 18, 2017 at 10:15
  • @FaheemMitha I appreciate the interest that you have put in my question, thanks a lot. If something comes out of the apt chat, please post an answer. ciao
    – gboffi
    Sep 18, 2017 at 14:04
  • I have to say that apt-get outputs a perfectly intelligible status line so a solution is to forget apt and keep using apt-get...
    – gboffi
    Sep 18, 2017 at 14:09

4 Answers 4

3

Here is a partial answer, courtesy of David Kalnischkies of APT, on OFTC's #debian-apt.

apt update -o APT::Color::Yellow="$(printf '\e[36m')"

I think that color is cyan. For other colors, see https://github.com/shiena/ansicolor/blob/master/README.md

And to add that permanently to APT's config, you can do (for example):

printf "APT::Color::Yellow \"\e[36m\";\n" >> /etc/apt/apt.conf

Which will add what looks like the following (if you are reading the file using less) to /etc/apt/apt.conf:

APT::Color::Yellow "ESC[36m";

Thanks to @sebasth for coming up with that printf incantation.

4
  • Oh my... I have to change a named color and I have to insert a literal escape into a configuration file... but this is the apt developers, your answer is perfect for me. tx a lot. - - - - - - ps yellow is red :-)
    – gboffi
    Sep 18, 2017 at 20:59
  • @gboffi: Not the perfect answer, agreed. Sep 18, 2017 at 21:24
  • no, your answer is good, it's apt that has a few problems and one has to jump through hoops to fix them...
    – gboffi
    Sep 18, 2017 at 21:56
  • @gboffi David didn't seem particularly interested in doing anything with this, so I imagine the possibility of a config option is remote. But one could still file a wishlist bug. Sep 18, 2017 at 21:58
1

Since there seem to be repeated questions (including the one that brought me here) about colours in apt and not much documentation on it, I thought it might be helpful to dig into this a bit more. The following expands on Faheem Mitha's answer.

The apt source code contains colour definitions for highlight and neutral and several colours (red, green, etc) in apt-private/private-output.cc. The definitions look like this:

APT::Color::Yellow "[33m";

The code inside the quotation marks is an ANSI escape sequence, a combination of hexadecimal digits interpreted by many terminal shells, in this case for the foreground colour yellow. The first character in the colour codes is hexadecimal 1B. There is no printed equivalent. If you view the code, the hex digit may show up as a caret (^) or a fuzzy little box or as ESC or not at all (as here), depending on what's sending the output and to where.

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.

Hence, "Yellow" can be thought of as a placeholder for the status line colour. If the colour is inappropriate (yellow on white for example), changing the code for "Yellow" - to blue say:

([34m)  

and then appending it to the end of /etc/apt/apt.conf using the printf approach in Faheem Mitha's answer fixes it:

printf "APT::Color::Yellow \"\e[34m\";\n" >> /etc/apt/apt.conf

Alternatively, you could use a hex editor (Oktata in my case) to change /etc/apt/apt.conf directly. Note that apt.conf may not exist; apt works fine without it, but will read it if it's there.

That's why changing the colours in the shell before running apt has no impact. Apt is hard coded to use its definition of "Yellow".

Finally, running

apt-config dump

in a terminal will output any colour codes in apt.conf (among other things). Each code will, in turn, change the terminal's colours. If the last or only line in apt.conf is "Yellow", the terminal will be set to whatever is assigned to "Yellow". That can be avoided by putting the reset code (which apt calls neutral)

"[0m";  

after the new definition of "Yellow" at the end of the file. Using the printf approach, that's:

printf "APT::Color::Neutral \"\e[0m\";\n" >> /etc/apt/apt.conf
0

Each terminal emulator should have some color scheme editor.

Just set colors, which are unacceptable, to better one.

enter image description here

0

You can customize apt by editing the file /etc/apt/apt.conf

Examples are provided in /usr/share/doc/apt/examples/configure-index.gz

2
  • 1
    I'm happy with progress bar's color. I'd like to change the status line. — I'll have a look at /usr/share/doc/apt/examples/configure-index.gz
    – gboffi
    Sep 17, 2017 at 19:04
  • If one googles apt change color the 1st result is askubuntu.com/a/445246 that contains Dpkg::Progress-Fancy::Progress-Bg "%1b[40m"; but I already knew that answer when I posted my question: that answer is not what I need.
    – gboffi
    Sep 17, 2017 at 19:49

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.