Add color option to batman

This commit is contained in:
Ethan P 2019-10-22 15:35:10 -07:00
parent fa8a3bb850
commit d9e34e2d5f
No known key found for this signature in database
GPG Key ID: 6963FD04F6CF35EA

View File

@ -9,13 +9,24 @@ LIB="$(cd "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}"
BAT="bat"
source "${LIB}/print.sh"
source "${LIB}/opt.sh"
source "${LIB}/version.sh"
source "${LIB}/opt_hooks.sh"
# -----------------------------------------------------------------------------
hook_color
# -----------------------------------------------------------------------------
MAN_ARGS=()
BAT_ARGS=()
export MANPAGER='sh -c "col -bx | '"$(printf "%q" "$BAT")"' --language man --style grid"'
while shiftopt; do MAN_ARGS+=("$OPT"); done
if "$OPT_COLOR"; then
BAT_ARGS="--color=always --decorations=always"
else
BAT_ARGS="--color=never --decorations=never"
fi
# -----------------------------------------------------------------------------
export MANPAGER='sh -c "col -bx | '"$(printf "%q" "$BAT")"' --language=man --style=grid '"${BAT_ARGS[@]}"'"'
export MANROFFOPT='-c'
export BAT_PAGER="$PAGER"
command man "$@"
command man "${MAN_ARGS[@]}"
exit $?