From 85bb5f8bed0a7c7eb61278e353c34b64b34be007 Mon Sep 17 00:00:00 2001 From: Ethan P Date: Sat, 7 Sep 2019 15:19:12 -0700 Subject: [PATCH] Added script for using bat with man --- README.md | 1 + doc/batman.md | 30 ++++++++++++++++++++++++++++++ src/batman.sh | 20 ++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 doc/batman.md create mode 100755 src/batman.sh diff --git a/README.md b/README.md index 917bb08..a5253d2 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Bash scripts that integrate [bat](https://github.com/sharkdp/bat) with various c ## Scripts - [`batgrep`](doc/batgrep.md) (ripgrep + bat) +- [`batman`](doc/batman.md) (man with bat) - [`prettybat`](doc/prettybat.md) (pretty printing + bat)   diff --git a/doc/batman.md b/doc/batman.md new file mode 100644 index 0000000..c76fcaa --- /dev/null +++ b/doc/batman.md @@ -0,0 +1,30 @@ +# bat-extras: batman + +A script that allows bat to be used as a manual highlighter. + + + +## Command Line + +**Synopsis:** + +- `batman [SECTION] [ENTRY] ` + + + +## Caveats + +None so far. + + + +## Acknowledgements + +Thanks to [@sharkdp](https://github.com/sharkdp) and [@LunarLambda](https://github.com/LunarLambda) for debugging how to make this work properly in [certain environments](https://github.com/sharkdp/bat/issues/652). + + + +## Issues? + +If you find an issue or have a feature suggestion, make a pull request or issue through GitHub! +Contributions are always welcome. \ No newline at end of file diff --git a/src/batman.sh b/src/batman.sh new file mode 100755 index 0000000..d1b10a3 --- /dev/null +++ b/src/batman.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# ----------------------------------------------------------------------------- +# bat-extras | Copyright (C) 2019 eth-p | MIT License +# +# Repository: https://github.com/eth-p/bat-extras +# Issues: https://github.com/eth-p/bat-extras/issues +# ----------------------------------------------------------------------------- +LIB="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../lib" +source "${LIB}/print.sh" +source "${LIB}/opt.sh" +source "${LIB}/version.sh" +# ----------------------------------------------------------------------------- + +export MANPAGER='sh -c "col -bx | bat --language man --style grid"' +export MANROFFOPT='-c' +export BAT_PAGER="$PAGER" + +command man "$@" +exit $? +