1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-12-12 08:25:53 +08:00
ohmyzsh/plugins/colored-man-pages/colored-man-pages.plugin.zsh
Iulian Onofrei 23688fc7ab
Add option to color any help command
This allows you to use `colored git log --help` for example, to get
colored output.
2018-09-29 17:01:41 +03:00

37 lines
792 B
Bash

if [[ "$OSTYPE" = solaris* ]]
then
if [[ ! -x "$HOME/bin/nroff" ]]
then
mkdir -p "$HOME/bin"
cat > "$HOME/bin/nroff" <<EOF
#!/bin/sh
if [ -n "\$_NROFF_U" -a "\$1,\$2,\$3" = "-u0,-Tlp,-man" ]; then
shift
exec /usr/bin/nroff -u\$_NROFF_U "\$@"
fi
#-- Some other invocation of nroff
exec /usr/bin/nroff "\$@"
EOF
chmod +x "$HOME/bin/nroff"
fi
fi
function colored() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
PAGER="${commands[less]:-$PAGER}" \
_NROFF_U=1 \
PATH="$HOME/bin:$PATH" \
"$@"
}
function man() {
colored man "$@"
}