diff --git a/manbat b/manbat new file mode 100755 index 0000000..00c6afa --- /dev/null +++ b/manbat @@ -0,0 +1,8 @@ +#!/bin/sh + +prg="$1" +shift + +# mandoc passes a file name, other tools write to stdout +# using `cat "$@"` we take care of both reading from file and stdin +exec cat "$@" | col -bx | $prg --language man --style plain diff --git a/zsh-bat.plugin.zsh b/zsh-bat.plugin.zsh index 9cadeb8..68fd6dd 100644 --- a/zsh-bat.plugin.zsh +++ b/zsh-bat.plugin.zsh @@ -1,3 +1,4 @@ +BASEDIR=$(dirname "$0") if command -v batcat >/dev/null 2>&1; then # Save the original system `cat` under `rcat` @@ -6,12 +7,12 @@ if command -v batcat >/dev/null 2>&1; then # For Ubuntu and Debian-based `bat` packages # the `bat` program is named `batcat` on these systems alias cat=$(which batcat) - export MANPAGER="sh -c 'col -bx | batcat -l man -p'" + export MANPAGER="$BASEDIR/manbat batcat" elif command -v bat >/dev/null 2>&1; then # Save the original system `cat` under `rcat` alias rcat=$(which cat) # For all other systems alias cat=$(which bat) - export MANPAGER="sh -c 'col -bx | bat -l man -p'" + export MANPAGER="$BASEDIR/manbat bat" fi