RE: [PATCH v7] help: colorize man pages if man.color=true under less(1)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ævar Arnfjörð Bjarmason wrote:
> From: Felipe Contreras <felipe.contreras@xxxxxxxxx>
> 
> We already colorize tools traditionally not colorized by default, like
> diff and grep. Let's do the same for man, but only if `color.man` is
> explicitly set to "true".
> 
> Unlike other `color.*` output this colorization is not enabled by
> `color.ui` being true, the user needs to explicitly set the
> `color.man` variable to `true.
> 
> When it was proposed to treat `color.man` like any other `color.*`
> variable some thought that git opting in coloring for an external
> program such as man(1) was a step too far[1], even if the user invoked
> it via the "git help <topic>" wrapper.
> 
> So let's make this explicitly opt-in for now. As noted in the
> documentation we're leaving ourselves an out to turn this on by
> default in the future, or e.g. putting it under the
> feature.experimental umbrella. We probably won't, but let's not
> promise users that `color.man` will forever be a special-case.
> 
> As for what this actually does the effect of having this enabled is
> that a documentation blurb like (some parts elided with "[...]"):
> 
> 	NAME
> 	----
> 	git-config - Get and set [...]
> 
> 	SYNOPSIS
> 	--------
> 	[...]
> 	'git config' [<file-option>] [...]
> 	[...]
> 	The `--type=<type>` option instructs 'git config' to ensure [...]
> 
> Will have "NAME" and "SECTION" shown as BOLD RED instead of BOLD, "git
> config" and other '-quoted parts in BLUE UNDERLINE instead of
> UNDERLINE, and `--type=<type>` and other `-quoted parts in RED BOLD
> instead of BOLD. The "Standout" setting is then used for the user's
> own search bar (invoked with "/") and prompt. See [2] for more
> examples
> 
> Normally check_auto_color() would check the value of `color.pager`, but
> in this particular case it's not git the one executing the pager, but
> man. Therefore we need to check pager_use_color ourselves.
> 
> We do not need to support `color.man` being set to `always`; The `git
> help` command is always run for a tty (it would be very strange for a
> user to do `git help $page > output`, but in fact, that works anyway,
> we don't even need to check if stdout is a tty, but just to be
> consistent we do). So it's simply a boolean in our case.
> 
> So, in order for this change to have any effect:
> 
>  1. color.man=true must be set in the config
>  2. The user must use less
>  3. Not have the same LESS_TERMCAP variables set (we call setenv(3) with overwrite=0)
>  4. Have color.ui enabled
>  5. Not have color.pager disabled
>  6. Not have git with stdout directed to a file
> 
> 1. https://lore.kernel.org/git/87tun1qp91.fsf@xxxxxxxxxxxxxxxxxxx/
> 2. https://unix.stackexchange.com/questions/119/colors-in-man-pages/147
> 
> Suggested-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
> Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>

Looks good to me.

-- 
Felipe Contreras



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux