LinuxCommandLibrary

batcat

View file contents with syntax highlighting

TLDR

View documentation for the original command

$ tldr bat
copy

SYNOPSIS

bat [options] [file(s)]

PARAMETERS

FILE
    File to display. If no file is specified, bat reads from standard input.

-A, --show-all
    Show non-printable characters.

-f, --force-colorization
    Force colorization even when stdout is not a terminal.

-l, --language LANGUAGE
    Specify a language for syntax highlighting.

-m, --map-syntax MAP
    Use this to define custom file extension to syntax mappings.

-n, --number
    Show line numbers.

-p, --plain
    Show the file content without any syntax highlighting.

-r, --read-only
    Disable interactive prompts.

-S, --style STYLE
    Highlighting style (see below).

-t, --truncate-long-lines
    Truncate long lines.

-u, --unbuffered
    Disable buffered output (useful when piping bat's output).

-V, --version
    Show version number.

-h, --help
    Show help message.

DESCRIPTION

bat is a cat clone with syntax highlighting and Git integration. It uses the same syntax definitions as Sublime Text and TextMate. Bat makes viewing files on the command line a much more pleasant experience. It automatically detects syntax, supports themes, shows Git modifications, and more.
Compared to regular cat, bat provides colorful output to help understanding code, markup files and other documents that can be highlighted by syntax.
bat aims to be a modern and more user-friendly replacement for cat, offering features that enhance readability and workflow.

CAVEATS

bat relies on syntax definitions for highlighting. If a file type is not recognized, it may not be highlighted correctly.
Performance might be slower compared to cat for very large files.

STYLES

The bat command can use different highlight styles. Available Styles: plain, numbers, header, grid. Styles numbers, header and grid show line numbers. Style header shows the file name in the output and the grid style shows a grid-like view.

CONFIGURATION

The configuration of bat can be done via a configuration file, for example with the bat.conf file. The configuration file is located in the usual folders, specific to each operating system.

HISTORY

bat was created to address the need for syntax highlighting and other modern features when viewing files from the command line. It's inspired by tools like pygmentize but aims for ease of use and speed. Development began in the late 2010s and the command has rapidly gained popularity within the developer community for its improved user experience.

SEE ALSO

cat(1), less(1), head(1), tail(1), vim(1)

Copied to clipboard