Bug 250686 - How to get color in man (manual pages)
How to get color in man (manual pages)
Product: Fedora
Classification: Fedora
Component: man (Show other bugs)
All Linux
low Severity low
: ---
: ---
Assigned To: Ivana Varekova
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2007-08-02 17:20 EDT by Fdor
Modified: 2007-11-30 17:12 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-08-06 08:41:42 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Fdor 2007-08-02 17:20:42 EDT
Description of problem:

Bug #120112 explains how to turn off colors in manual pages when using xterm. I
want to do the opposite: to turn on colors in manual pages when using

I've played with:

1) /etc/man.config: "NROFF" ("-c" deleted) and "PAGER" ("-R" added to less) entries.

2) ~/.Xdefaults: *VT100*colorMode, *VT100*boldColors, Gnome-terminal*colorMode,
Gnome-terminal*colorBDMode, Gnome-terminal*colorBD, etc.

And I always get man pages in black&white&bold&underline, with no colors.

Is there any way to enable color in manual pages for gnome-terminal? Manual
pages are easy to read in Cygwin due to colors, which are enabled by default.
Any chance to enable colors by default in future releases of Fedora?

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. man man.config

Actual results:

black&white&bold&underline text.

Expected results:

Colored text
Comment 1 Ivana Varekova 2007-08-06 08:41:42 EDT
This is not a bug, the standard syntax of man pages is simple and the color tags
are not usually used. So there is no need to display man-pages using colors.
Comment 2 Fdor 2007-08-06 13:27:53 EDT
I know this is more a question than a bug: "How
to get color in man" ;-). But, since I've not been able to
get it, I think that this maybe a improvement or feature
request, to make it possible.

By default, in Fedora, man pages are shown with bold and 
underline. For example, if you type the command:

    man man

then you will see:

           man  -  format  and  display the on-line manual
           man [-acdfFhkKtwW]  [--path]  [-m  system]  [-p
           string]  [-C  config_file]  [-M  pathlist]  [-P
           pager] [-B browser]  [-H  htmlpager]  [-S  sec-
           tion_list] [section] name ...

In gnome-terminal (Fedora), the strings "NAME", "SYNOPSIS" 
and "man [-acdfFhkKtwW]" are shown in bold. The strings 
"system", "string" and "config_file"  are shown underlined.

In Cygwin (Windows), if you open the same manual page ("man
man"), the strings "NAME", "SYNOPSIS" and "man 
[-acdfFhkKtwW]" are not shown in bold, they are shown in 
one color (which I don't remember, maybe green). And the 
strings "system", "string" and "config_file" are not shown
underlined, they are shown in other color (maybe yellow).

So my question is how to get colors in Fedora too. This is,
how to replace "bold" by "color1", and "underlined" by

From what I've investigated, running "man page" is
aproximately equivalent to this command:

    cat $path_to_page.gz | gunzip | $NROFF | $PAGER

where $NROFF and $PAGER are defined in /etc/man.config.

By default, those variables have these values:

    NROFF           /usr/bin/nroff -c -mandoc 2>/dev/null
    PAGER           /usr/bin/less -is

The "-c" in NROFF variable means:

    The -h and -c options are equivalent to grotty's

and in grotty we see:

    Use   the  -c  switch  to  revert  to  the  old
    behaviour, printing a bold character c with the
    sequence  'c BACKSPACE c' and an italic charac-
    ter c by the sequence '_ BACKSPACE c'.  At  the
    same  time, color output is disabled.

Then, if I delete the "-c" ("nroff -mandoc 2>/dev/null"),
colors should be enabled. Right?

For the PAGER variable, we can use colors in "less" command
if we add the "-R" option ("less -isR"). I've tested it with
the command "ls --color | less -R", and it works.

So, by using the following values in /etc/man.config:

    NROFF           /usr/bin/nroff -mandoc 2>/dev/null
    PAGER           /usr/bin/less -isR

bold style would be replaced by color1, and underlined 
style would be replaced by color2 , in all manual pages.
Like in cygwin.

Is that right? Perhaps nroff doesn't convert bold and
underline into color1 and color3, even if colors are
enabled? Maybe the conversion is a "gnome-terminal" 
question (~/.Xdefaults) instead of a "man" question 

I can post the question at the gnome-terminal component, if
needed. Just tell me.

Thank you
Comment 3 Ivana Varekova 2007-08-07 06:51:27 EDT
Groff uses colors but they are different then you mean - it is possible in
"groff language" to write text with different colors and different colored
background. So nroff option -c switch of/on these colors (I don't find any
transformation from bold/underline/any other style to colors). less with -R
option accept these kind of colors. But in manual pages there are not used these
tags - so the text is black and white only.
but there are another programs which transformed bold and underlined text to
colored text (e.g. most) - so if you have installed most package you can use
most as a pager 
PAGER           /usr/bin/most
then there is no difference between the 
NROFF           /usr/bin/nroff -c -mandoc 2>/dev/null
NROFF           /usr/bin/nroff -mandoc 2>/dev/null
most command displays man-pages in colors. But most don't accept some special
characters (eg. quote), so less is the best "pager" and it is upstream choice too. 
Comment 4 Fdor 2007-08-07 16:23:00 EDT
I've tested "most". It has the problem you've said (the "'"
simbol is not well shown), and additionally I can't find 
how to keep the default background color for bold and 
underline styles when converted to colors.

I have three ideas to solve the problem of man+less:

1) Use some unix-style utilities to convert bold and
   underline into colors, and insert them into the piped
   chain of commands:

       cat $path_to_page.gz | gunzip | $NROFF \
       | bold2color -green | underl2color -yellow | $PAGER

   But I don't know if "bold2color" and "underl2color" do

2) Customize the "groff_man" macro, which is used by the
   "-mandoc" option of nroff to convert original "groff
   language" of man pages into ascii output. So, it assign
   bold and underline style to some components of the
   original pages.

   The documentaton of this macro (see "man groff_man")
   explains that we can customize it:

       For further customization, put additional macros and
       requests into the file man.local which will be loaded
       immediately after the man package.

   But I don't know hot to customize it (I would need to
   "study" groff, which is nearly-infinite ;-).

3) Extend the "-D" option of less to unix (currently it's
   only supported in msdos). In this way, we could assign
   colors to bold and underline styles.

   But this would require some development.

In the meantime, I've found the "pman" command (surprisingly
it was installed by default in my Fedora, as part of the
pinfo package). It has a "navigable" interface, with links
to other pages, and can be customized in /etc/pinforc. In
that config file, bold and underline styles can be
converted into colors by using these variables:

and background can be kept with the "COLOR_DEFAULT" value.

Anyway, "pman" sets the color of some characters (Á É Í Ó
Ú) to default color, and works differently from "less". I'd
prefer man+less if some idea could be used to get colors.

Thank you

Note You need to log in before you can comment on or make changes to this bug.