I usually set my terminal with transparent background. But, when I need to read a lot of text such as man, less, cat, etc., I want my background color to be solid black. I can change the backgrounds of vim and w3m. How to change the backgrounds of $PAGER, man, less, cat, more etc.? I'm on Debian-Buster using zsh shell with colored-man-page plugin installed.


That's actually multiple questions, where some have no useful answer:

  • cat "could" be wrapped in an alias (capturing some of its uses), to set a particular background color, but whatever it sends to the terminal can change that background.
  • $PAGER and more are redundant: you're unlikely to use anything but less underneath. The same applies to man (which uses $PAGER).
  • For less... the basic problem is that it is designed to color the text on the screen, and is almost completely agnostic regarding the background color.

Referring to

there's some mention of foreground (text) and background color. However, those do not mention that the terminal responds to this (used for resetting the bold attribute):

me      sgr0      turn off bold, blink and underline

by resetting colors as well. (It uses the same solution for resetting blink, but you are less likely to find that to be a problem). It does use a different string for resetting underline, so that part of me's description does not apply.

To make less use a particular color scheme, you would have to construct environment variables as suggested in this answer, fooling less into setting the background color when it is turning off bold or blink.

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.