refactor: colourise man based on operating system

Use different method for coloured man on macOS & Linux.
This commit is contained in:
George Rawlinson 2021-07-08 16:57:44 +00:00
parent f3ae58d3eb
commit 1975a585c0
Signed by: grawlinson
GPG key ID: E0959FEA8B550539

View file

@ -1,6 +1,14 @@
# colour output in man #
# source: https://wiki.archlinux.org/index.php/Color_output_in_console#man # coloured-man
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_md=$'\e[01;31m' \
LESS_TERMCAP_me=$'\e[0m' \ LESS_TERMCAP_me=$'\e[0m' \
LESS_TERMCAP_se=$'\e[0m' \ LESS_TERMCAP_se=$'\e[0m' \
@ -8,6 +16,8 @@ man() {
LESS_TERMCAP_ue=$'\e[0m' \ LESS_TERMCAP_ue=$'\e[0m' \
LESS_TERMCAP_us=$'\e[01;32m' \ LESS_TERMCAP_us=$'\e[01;32m' \
command man "$@" command man "$@"
} }
fi
fi
# vim: ft=zsh expandtab tabstop=2 shiftwidth=2 # vim: ft=zsh expandtab tabstop=2 shiftwidth=2