Bash scripts that integrate bat with various command line tools.
Go to file
2024-08-24 14:02:23 -07:00
.github ci: Fix downloading ripgrep dependency 2024-02-12 12:23:54 -08:00
.test-framework@6b97e0a531 test: Update test framework 2023-05-15 19:31:29 -07:00
doc batman: Provide way to use BATMAN as MANPAGER 2024-06-10 12:55:10 -07:00
lib batman: If fzf is installed, use batman to search through man pages 2021-08-21 15:22:29 -07:00
src prettybat: Use yq for YAML and JSON pretty formatting 2024-08-24 14:02:23 -07:00
test test: Ignore flags passed to shim less 2024-08-24 13:45:36 -07:00
.gitignore developer: Add '.vscode' to gitignore 2022-07-29 14:01:34 -07:00
.gitmodules Format with vs-shell-format 2020-04-01 02:55:41 +02:00
banner.txt docs: Update banner 2024-06-10 12:56:16 -07:00
build.sh build: Add termux support 2023-06-15 16:56:16 -07:00
CONTRIBUTING.md docs: Add CONTRIBUTING.md 2020-04-27 01:45:14 -07:00
LICENSE.md Added license. 2019-06-19 14:41:20 -07:00
mdroff.sh mdroff: Remove <br/> from output 2021-08-21 16:03:05 -07:00
README.md Update Arch Linux package URL in README.md 2024-02-12 01:01:06 -08:00
release.sh dev: Allow release script to be used as lib 2023-06-15 16:16:19 -07:00
test.sh developer: Update test framework 2020-10-29 01:35:47 -07:00
version.txt Bump version to 2024.07.10 2024-06-10 12:56:58 -07:00

bat-extras

Bash scripts that integrate bat with various command line tools.

 

Scripts

batgrep

Quickly search through and highlight files using ripgrep. Requirements: ripgrep

batman

Read system manual pages (man) using bat as the manual page formatter.

batpipe

A less (and soon bat) preprocessor for viewing more types of files in the terminal.

batwatch

Watch for changes in one or more files, and print them with bat. Requirements: entr (optional)

batdiff

Diff a file against the current git index, or display the diff between two files. Requirements: bat, delta (optional)

prettybat

Pretty-print source code and highlight it with bat. Requirements: (see doc/prettybat.md)

 

Installation via Package Manager

Homebrew

All of the bat-extras scripts can be installed with brew install bat-extras.

If you would prefer to only install the specific scripts you need, you can use the eth-p/software tap to install individual scripts: brew install eth-p/software/bat-extras-[SCRIPT]

MacPorts

The bat-extras scripts can also be installed via MacPorts on macOS:

sudo port install bat-extras

Port info here.

Pacman

bat-extras is officially available on the Arch extra repository!

If you have the extra repository enabled, you can install bat-extras by running:

pacman -S bat-extras

Gentoo

bat-extras is available on Gentoo's Guru Overlay as sys-apps/bat-extras.

To install, first make sure you've added the Gentoo Guru Overlay to your local repositories, then emerge accordingly...

emerge sys-apps/bat-extras

Fedora (Unofficial)

bat-extras is available in an unofficial Fedora Copr repository. Note: this package does not contain prettybat since prettier is not yet packaged for Fedora.

Install the Copr plugin, enable the repository, and then install the package by running:

dnf install dnf-plugins-core 
dnf copr enable awood/bat-extras
dnf install bat-extras

 

Installation

Test

The scripts in this repository are designed to run as-is, provided that they aren't moved around. This means that you're free to just symlink src/[script].sh to your local bin folder.

If you would rather have faster, self-contained scripts that you can place and run anywhere, you can use the build.sh script to create (and optionally install) them.

 

Building:

./build.sh [OPTIONS...]

This will combine and preprocess each script under the src directory, and create corresponding self-contained scripts in the bin folder. Any library scripts that are sourced using source "${LIB}/[NAME].sh" will be embedded automatically.

 

Minification:

There are three different options for minification:

Option Description
--minify=none Nothing will be minified.
--minify=lib Embedded library scripts will be minified. [default]
--minify=all Everything will be minified.

This uses shfmt to perform minification.

 

Installation:

You can also specify --install and --prefix=PATH to have the build script automatically install the scripts for all users on the system. You may need to run the build script as root.

If you only want to install a single script, you can run the build process and copy the script directly out of the newly-created bin folder.

Manuals:

The build script will automatically generate a man page for each of the markdown documentation files. This is a beta feature that uses a non-compliant Markdown "parser" written in Bash, and there is no guarantee towards the quality of the generated manual pages. If you do not want to generate manual files, you can provide the --no-manuals option to disable manual file generation.

Alternate Executable:

Depending on the distribution, bat may have been renamed to avoid package conflicts. If you wish to use these scripts on a distribution where this is the case, there is an --alternate-executable=NAME option which will build the scripts to use an alternate executable name.

You may also specify alternate executables for ripgrep, delta, fzf, or git with --alternate-executable:PROGRAM NAME where PROGRAM is one the aforementioned programs. Note that doing so may cause verification to fail.

Verification:

The build script will attempt to verify the correctness of the "bin" scripts by comparing their output with their source counterparts. It is recommended to let it do this, but you can disable verification with the --no-verify option.

 

Contributing

If you would like to contribute to bat-extras, please feel free to open an issue on GitHub, or make a pull request. If you do the latter, please keep our contributing guidelines in mind.