BATPIPE(1)

๐Ÿ“ฆ version 2024.08.24, in arch rolling

๐Ÿฆ‹ batpipe(1) โ€” General Commands Manual ๐Ÿฆ‹

okay so welcome to the batpipe(1) glow-up, bestie ๐Ÿ’– this is the manual page that explains the whole vibe: batpipe is a less (and bat) preprocessor situation, and it's genuinely iconic for peeking at way more file types in your terminal. iykyk ๐Ÿ’…

โœจ NAME โœจ

  • batpipe โ€” A less (and bat) preprocessor for viewing more types of files in the terminal. periodt ๐Ÿ’–

๐ŸŒธ DESCRIPTION ๐ŸŒธ

no extra description text here in the original โ€” the deets are all in the sections below, and they ate โœจ

๐Ÿ’… 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 ๐ŸŽ€

one variable, one job, periodt:

  • 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 ๐Ÿงš

these are the file types batpipe already handles by default, no cap:

  • 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 get 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 ๐Ÿ’€

caveat time, bestie โ€” don't skip this one ๐Ÿ™ˆ
  • By default, batpipe will not use colors when previewed inside less. Colors must be explicitly enabled with BATPIPE=color.

xoxo, BATPIPE(1) ๐Ÿ’… โ€” General Commands Manual (the footer is literally just BATPIPE(1), bestie โ€” no date or version to spill, and I'm not making one up) ๐Ÿซถ

๐Ÿ“ฆ where this page comes from