From 1975a585c0daeecae218e81b9d51adac4c7dba0c Mon Sep 17 00:00:00 2001 From: George Rawlinson Date: Thu, 8 Jul 2021 16:57:44 +0000 Subject: [PATCH] refactor: colourise man based on operating system Use different method for coloured man on macOS & Linux. --- plugins/coloured-man | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/plugins/coloured-man b/plugins/coloured-man index dc6d01f..e2ca899 100644 --- a/plugins/coloured-man +++ b/plugins/coloured-man @@ -1,13 +1,23 @@ -# colour output in man -# source: https://wiki.archlinux.org/index.php/Color_output_in_console#man -man() { - LESS_TERMCAP_md=$'\e[01;31m' \ - LESS_TERMCAP_me=$'\e[0m' \ - LESS_TERMCAP_se=$'\e[0m' \ - LESS_TERMCAP_so=$'\e[01;44;33m' \ - LESS_TERMCAP_ue=$'\e[0m' \ - LESS_TERMCAP_us=$'\e[01;32m' \ - command man "$@" -} +# +# coloured-man +# + +# https://wiki.archlinux.org/index.php/Color_output_in_console#man + +if [[ -v OSTYPE ]]; then + if [[ "$OSTYPE" == "linux"* ]]; then + export MANPAGER="less -R --use-color -Dd+r -Du+b" + elif [[ "$OSTYPE" == "darwin"* ]]; then + man() { + LESS_TERMCAP_md=$'\e[01;31m' \ + LESS_TERMCAP_me=$'\e[0m' \ + LESS_TERMCAP_se=$'\e[0m' \ + LESS_TERMCAP_so=$'\e[01;44;33m' \ + LESS_TERMCAP_ue=$'\e[0m' \ + LESS_TERMCAP_us=$'\e[01;32m' \ + command man "$@" + } + fi +fi # vim: ft=zsh expandtab tabstop=2 shiftwidth=2