From 9af5a706f85aa775ff087be38b625c5a9bf3f1db Mon Sep 17 00:00:00 2001 From: Jordan Atwood Date: Wed, 21 Dec 2022 23:13:53 -0800 Subject: [PATCH] Remove terminfo manpager colors The motivation for this change comes from several reasons and frustrations with the previous setup used here. Firstly, the terminfo variables previously provided did not match those of the familiar-to-me termcap environment variables, not even remotely close. The color scheme the termcap variables creates is a largely yellow-and-white theme, while the terminfo variables created a largely blue-and-white theme. In addition to being unfamiliar, blue tends to be somewhat hard to read on my dark theme terminals, so it had to go. Secondly, in my efforts to update the terminfo variables to match the colors provided by termcap, I found that bright colors (such as the bright white used for underlined text) did not display correctly, and it blatantly ignored any attempts to display colors in their default or bright color variants. Due to the prevalence of underlined text in manpages, this meant that I could not achieve the desired color scheme whatsoever. Finally, maintaining this convoluted `less` version check is something I'd rather not do. Because terminfo is not universal and I typically use stable distributions of linux tending away from the bleeding edge, I can rely on termcap being available for `less` for some time to come, while terminfo isn't yet available for Debian stable. Given that, I'd like to maintain only a single set of color mappings for now. And unless I can overcome the color issue mentioned in the previous paragraph, I doubt I'll be interested in maintaining a parity between the two. n.b. In the process of slimming these definitions down, I did a decent amount of research to find parity in the text types identified by terminfo and termcap. The following table details those findings. Note that termcap variables would be set as environment variables in the format `LESS_TERMCAP_var` and are set to an ANSI escape sequence for a Select Graphic Rendition (see https://stackoverflow.com/a/33206814/540162), and terminfo variables are passed as arguments to `less` in the format `less -Dv` and are set to a 4-bit or 8-bit color string. (see `man less` on systems with `less --version` >= 580) | termcap | terminfo | | |---------|----------|------------------------------------| | mb | k | blinking text | | md | d | bold text | | me | | end bold/blinking text | | so | s | reverse video (standout) text | | se | | end reverse video text | | us | u | underlined text | | ue | | end underlined text | | | B | binary characters | | | C | control characters | | | E | errors and info messages | | | M | mark letters in status column | | | N | line numbers enabled via -N option | | | P | prompts | | rs | R | rscroll character | | | S | search results | | | W | highlight enabled via -w option | --- src/.bash_profile | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/.bash_profile b/src/.bash_profile index 69c3be6..3b38daf 100755 --- a/src/.bash_profile +++ b/src/.bash_profile @@ -43,20 +43,16 @@ if hash less >/dev/null 2>&1; then # Enhanced man pages export MANPAGER='less -R -s -M' - if [ "$(less -V | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '.' )" -ge 580 ]; then - export MANPAGER="${MANPAGER} --use-color -Dd+r -Du+b" - else - # Add man page colors - # Sourced from: https://unix.stackexchange.com/a/329092/136537 - export LESS_TERMCAP_mb=$'\e[1;31m' # begin blink - export LESS_TERMCAP_md=$'\e[1;33m' # begin bold - export LESS_TERMCAP_so=$'\e[01;44;37m' # begin reverse video (aka standout) - export LESS_TERMCAP_us=$'\e[01;37m' # begin underline - export LESS_TERMCAP_me=$'\e[0m' # reset bold/blink - export LESS_TERMCAP_se=$'\e[0m' # reset reverse video (aka standout) - export LESS_TERMCAP_ue=$'\e[0m' # reset underline - export GROFF_NO_SGR=1 # for konsole and gnome-terminal - fi + # Add man page colors + # Color scheme sourced from: https://unix.stackexchange.com/a/329092/136537 + export LESS_TERMCAP_mb=$'\e[1;31m' # begin blink + export LESS_TERMCAP_md=$'\e[1;33m' # begin bold + export LESS_TERMCAP_so=$'\e[01;44;37m' # begin reverse video (aka standout) + export LESS_TERMCAP_us=$'\e[01;37m' # begin underline + export LESS_TERMCAP_me=$'\e[0m' # reset bold/blink + export LESS_TERMCAP_se=$'\e[0m' # reset reverse video (aka standout) + export LESS_TERMCAP_ue=$'\e[0m' # reset underline + export GROFF_NO_SGR=1 # for konsole and gnome-terminal fi # Maven