1

If I do man bash inside of X, e.g., in xterm or mate-terminal, I get some words underlined.

If I do man bash in a virtual terminal, I get those same words colored.

Can I get the same coloring in X?

What causes this difference in the behaviors of the two?

Petr Skocik
  • 28,816

4 Answers4

4

If less is set as a viewer for man pages then you have opportunity to overwrite standard colors, with less special variables.

Example from my settings:

export LESS_TERMCAP_mb=$'\e[6m'          # begin blinking
export LESS_TERMCAP_md=$'\e[34m'         # begin bold
export LESS_TERMCAP_us=$'\e[4;32m'       # begin underline
export LESS_TERMCAP_so=$'\e[1;33;41m'    # begin standout-mode - info box
export LESS_TERMCAP_me=$'\e[m'           # end mode
export LESS_TERMCAP_ue=$'\e[m'           # end underline
export LESS_TERMCAP_se=$'\e[m'           # end standout-mode

Additionally you may need to set

export GROFF_NO_SGR=''

due to some bug in "new" groff behaviour.


I've checked in my linux box that if I set in console

export LESS_TERMCAP_md=$'\e[4m'

then instead of underlining (which is not possible under console) the code is indeed interpreted as light blue.

jimmij
  • 47,140
2

This question provides several ways to dump man page. They also discuss that man pages follow special formatting - the one that can be interpreted by terminal emulator.

Basically man page is a groff document, so it contains funny characters that man interprets as formatting.

Using man on two different terminal emulators might yield different results - just what happened to you. Unfortunately, there isn't much you can do about its behaviour - it's limited by your terminal emulator.

MatthewRock
  • 6,986
1

The answer is, in fact, simple: EGA–VGA colored text modes simply lack the underlining capability. Hence groff uses whichever substitute it deems appropriate.

fbdev emulation, technically, isn’t bound by VGA restrictions, but (for the sake of compatibility) it relies on the same screen buffer format with the same semantics.

One could change the code of Linux framebuffer TUI emulator to reserve, say, some foreground/background combinations for underline. But it will result in:

  • compatibility problems;
  • kernel bloat;
  • need to invent a new terminfo $TERM key (other than linux), because capabilities of hypothetical “new Linux console” will be different from classical TERM=linux;
  • need to ensure login shells set $TERM accordingly.
Incnis Mrsi
  • 1,988
1

The other answers are interesting, but no one answered OP's question: lacking any specific customization, why do some terminals show different behavior?

The Linux console has long (since the early 1990s) displayed color for the interesting video attributes which it does not support. @Incnis Mrsi mentioned this (though there are many better sources).

  • However, groff does not know that there is a lack of capability for underlining. The terminal description says it does; which is nice, because groff ignores that (it uses hard-coded escapes). However the Linux console renders those as it chooses.
  • The comments about less environment variables are interesting, but not often used.

Some other terminals can render video attributes as colors; xterm can, by setting resources colorUL and colorULMode (and it seems that often the Red Hat-based distributions configure it that way). Likewise, rxvt can (also resource-based, though less configurable).

Thomas Dickey
  • 76,765