From: Simon Ruderich Date: Mon, 4 Sep 2023 08:38:46 +0000 (+0200) Subject: shell: add man wrapper to restore colored and searchable man pages X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=eb24896ada0cb363365354b29d3c743f204e3688;p=config%2Fdotfiles.git shell: add man wrapper to restore colored and searchable man pages --- 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 #