---
name: "batpipe"
section: "1"
platform: "linux"
package: "bat-extras"
version: "2024.08.24-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/batpipe"
---

# batpipe(1)

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

## NAME

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

## DESCRIPTION

## USAGE

Like lesspipe, *batpipe* is designed to work with programs that support preprocessing with the *LESSOPEN* environment variable. Setting up *batpipe* will depend on your shell:

**Bash:**

    eval "$(batpipe)"

**Fish:**

    eval (batpipe)

## ENVIRONMENT

| | |
| --- | --- |
| **Variable** | **Description** |
|
| *BATPIPE\_TERM\_WIDTH* | Sets the terminal width provided to *bat*. If this variable starts with a hyphen (*-*), the number provided will be relative to the detected terminal size. |

## BUILT-IN VIEWERS

| | |
| --- | --- |
| **Files** | **Program** |
|
| Directories | *eza*, *ls* |
| *.tar, .tar.gz* | *tar* |
| *.zip, .jar* | *unzip* |
| *.gz* | *gunzip* |
| *.xz* | *xz* |

## EXTERNAL VIEWERS

For file formats that aren't supported by default, an external file viewer can be added to *batpipe* through the external viewer API.

External viewers are be added to batpipe by creating bash scripts inside the *~/.config/batpipe/viewers.d/* directory.

### Creating Viewers

Viewers must define two functions and append the viewer's name to the *$BATPIPE\_VIEWERS* array.

 \- *viewer\_${viewer}\_supports \[file\_basename\] \[file\_path\] \[inner\_file\_path\]*\
\
  \- *viewer\_${viewer}\_process \[file\_path\] \[inner\_file\_path\]*

The *viewer\_${viewer}\_supports* function is called to determine if the external viewer is capable of viewing the provided file. If this function returns successfully, the corresponding *process* function will be called.

### API

    $BATPIPE\_VIEWERS      -- An array of loaded file viewers.\
\
     $BATPIPE\_ENABLE\_COLOR -- Whether color is supported. (*true*\|*false*)\
\
     $BATPIPE\_INSIDE\_LESS  -- Whether batpipe is inside less. (*true*\|*false*)

    batpipe\_header \[pattern\] \[...\]    -- Print a viewer header line.\
\
     batpipe\_subheader \[pattern\] \[...\] -- Print a viewer subheader line.

    strip\_trailing\_slashes \[path\]     -- Strips trailing slashes from a path.

## CAVEATS

\- By default, *batpipe* will not use colors when previewed inside *less*.\
\
   Colors must be explicitly enabled with *BATPIPE=color*.
