LinuxCommandLibrary

bat

Cat clone with syntax highlighting and Git integration

TLDR

View file with syntax highlighting
$ bat [file.js]
copy
Show line numbers
$ bat -n [file.py]
copy
Show non-printable characters
$ bat -A [file.txt]
copy
Plain output (no decorations)
$ bat -p [file.log]
copy
Multiple files
$ bat [file1.rs] [file2.rs]
copy
Specific language
$ bat -l [python] [script]
copy

SYNOPSIS

bat [options] [file...]

DESCRIPTION

bat is a cat clone with syntax highlighting and Git integration. It displays file contents with automatic language detection, line numbers, and Git diff indicators in the margin.
The tool provides a more user-friendly file viewing experience for developers and system administrators.

PARAMETERS

-n, --number

Show line numbers
-A, --show-all
Show non-printable characters
-p, --plain
Plain mode (no decorations)
-l, --language lang
Specify language for syntax highlighting
-H, --highlight-line n
Highlight specific lines
--paging when
When to use pager (auto, always, never)
--style components
Configure output style
--theme name
Color theme
--list-languages
List supported languages
--list-themes
List available themes

CONFIGURATION

~/.config/bat/config

Default command-line options applied automatically. One option per line (e.g. --theme, --style).

FEATURES

- Syntax highlighting for 200+ languages
- Git integration (shows modifications)
- Line numbers
- Non-printable character display
- Automatic paging
- File concatenation
- Themes support
- Integrates with less pager

CAVEATS

Not a drop-in cat replacement for scripts (use cat for pipelines). Slower than cat on large files. Themes require true color terminal. On Debian/Ubuntu, the binary is installed as batcat due to a naming conflict with another package.

HISTORY

bat was created by David Peter (sharkdp) in 2018 as a modern replacement for cat with syntax highlighting and Git awareness.

SEE ALSO

cat(1), less(1), highlight(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard