From eb24896ada0cb363365354b29d3c743f204e3688 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 4 Sep 2023 10:38:46 +0200 Subject: [PATCH] shell: add man wrapper to restore colored and searchable man pages --- shell/shell/aliases.in | 8 ++++++++ shell/shell/env | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/shell/shell/aliases.in b/shell/shell/aliases.in index a4db8bf..384d6e5 100644 --- a/shell/shell/aliases.in +++ b/shell/shell/aliases.in @@ -123,6 +123,14 @@ tree() { command tree -C "$@" | less -S } +# Modern Groff versions (at least on Debian) don't support LESS_TERMCAP_* to +# color man pages, set GROFF_NO_SGR as workaround. Also set LANG to C so that +# hyphens are not replaced with unicode making it impossible to search for +# options containg "-" or "--" in many man pages. +man() { + GROFF_NO_SGR=1 LANG=C command man "$@" +} + # Better viewer for info pages .. just pipe everything into less. info() { command info "$@" 2>/dev/null | less diff --git a/shell/shell/env b/shell/shell/env index 74715a0..6ad2475 100644 --- a/shell/shell/env +++ b/shell/shell/env @@ -63,7 +63,8 @@ PAGER=less export PAGER escape=`printf '\033'` -# Color man pages viewed with less, thanks to [1]. +# Color man pages viewed with less, thanks to [1]. Modern Groff versions (at +# least in Debian) also need GROFF_NO_SGR=1 for this to work. # # [1]: http://nion.modprobe.de/blog/archives/572-less-colors-for-man-pages.html # -- 2.43.2