From 3c6d6c695b0ffea0d12f95973dbe84bf25b6b909 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Wed, 30 Oct 2019 19:54:29 +0100 Subject: [PATCH] Improve colorized man The previous solution worked fine for coloring the man pages but the display in bash's job control was a disaster: $ man sshd_config # followed by CTRL-z $ jobs [1]+ Stopped env LESS_TERMCAP_so=$(echo -ne"\033[${standout}m") LESS_TERMCAP_md=$(echo -ne "\033[${bold}m") LESS_TERMCAP_us=$(echo -ne "\033[${underline}m") LESS_TERMCAP_se='' LESS_TERMCAP_me='' LESS_TERMCAP_ue='' GROFF_NO_SGR=1 man sshd_config The new solution behaves identically regarding coloring the man pages but the job control information is much more useful: $ man sshd_config # followed by CTRL-z $ jobs [1]+ Stopped man sshd_config --- dotfiles/.bashrc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/dotfiles/.bashrc b/dotfiles/.bashrc index 118d557..f52486c 100644 --- a/dotfiles/.bashrc +++ b/dotfiles/.bashrc @@ -270,13 +270,11 @@ mkcd() { mkdir -p -- "$1" && cd -P -- "$1"; } # Colorized `man` man() { - if [ "$BACKGROUND" = "dark" ]; then - local standout="$Base02;44" bold="$Yellow" underline="$Base3;4" - else - local standout="$Base02;46" bold="$Blue" underline="$Base00;4" + local standout="$Base02;44" bold="$Yellow" underline="$Base3;4" + if [ $BACKGROUND = light ]; then + standout="$Base02;46" bold="$Blue" underline="$Base00;4" fi - env \ LESS_TERMCAP_so=$(echo -ne "\033[${standout}m") \ LESS_TERMCAP_md=$(echo -ne "\033[${bold}m") \ LESS_TERMCAP_us=$(echo -ne "\033[${underline}m") \ @@ -284,7 +282,7 @@ man() { LESS_TERMCAP_me=$'\033[0m' \ LESS_TERMCAP_ue=$'\033[0m' \ GROFF_NO_SGR=1 \ - man "$@" + command man "$@" } solarized() {