diff --git a/src/batman.sh b/src/batman.sh index b795b49..8057d6c 100755 --- a/src/batman.sh +++ b/src/batman.sh @@ -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 $?