From 2d891a0851001e82cc50a01ac3b2177238b1dbba Mon Sep 17 00:00:00 2001 From: Rudis Muiznieks Date: Thu, 16 May 2024 08:43:05 -0500 Subject: [PATCH] fix for mandoc --- manbat | 8 ++++++++ zsh-bat.plugin.zsh | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100755 manbat 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