bat
Display file contents with syntax highlighting
TLDR
Pretty print the contents of one or more files to stdout
Concatenate several files into the target file
Remove decorations and disable paging (--style plain can be replaced with -p, or both options with -pp)
Highlight a specific line or a range of lines with a different background color
Show non-printable characters like space, tab, or newline
Remove all decorations except line numbers in the output
Syntax highlight a JSON file by explicitly setting the language
Display all supported languages
SYNOPSIS
bat [OPTIONS] [FILE...]
PARAMETERS
-A, --show-all
Show non-printable characters, line endings, and diffs
-n, --number
Show line numbers
-l, --plain
Disable syntax highlighting and formatting
--style=plain,header,grid,...
Control styles: header, line numbers, grid, rule, snip
--theme=NAME
Syntax theme, e.g., Nord, Gruvbox-dark
--tabs=TABS
Number of spaces per tab (default: 2)
--wrap=never|character|word
Line wrapping mode
--color=always|never|auto
When to use colors
--paging=auto|always|never
Control paging with less
--line-range=LINE[:LINE]
Display specific line range
-p, --paging=never
Disable paging
--diff
Highlight git uncommitted changes
--watch
Watch files for changes and redraw
-h, --help
Show help
--version
Print version
DESCRIPTION
bat is a cat(1) clone with "wings," designed to make viewing code and files more pleasant and informative. Written in Rust for speed and safety, it provides syntax highlighting for over 300 languages using tree-sitter parsers, automatic detection of file types, and git integration to highlight line additions, deletions, and changes. Key features include line numbers, grid and header styling, mouse support in terminals, true color output, automatic paging with less, and diff support for side-by-side comparisons.
It supports themes like OneHalfDark or Gruvbox, customizable via CLI or config files. bat is blazing fast, even on large files, and handles binary files gracefully by warning instead of displaying garbage. Ideal for developers, it enhances readability in terminals without needing external pagers or editors for quick inspections. Install via package managers (e.g., apt install bat on Debian/Ubuntu) or from GitHub releases. Widely used in modern CLI workflows alongside tools like exa, fd, and ripgrep.
CAVEATS
bat is not a standard Unix tool; requires installation. Some features like syntax highlighting need tree-sitter runtimes (auto-downloaded). Binary files are not rendered. Performance drops on extremely large files without --plain.
CONFIGURATION
Edit ~/.config/bat/config for defaults, e.g., --theme='Nord', --style=full.
CACHE MANAGEMENT
Pre-compile syntaxes with bat cache --build for faster startup.
THEMES
List available: bat --list-themes. Install more via bat cache --build.
HISTORY
Created by sharkdp (Patrick F.) in 2018 as a fun project on GitHub. Gained popularity via Rust rewrite for speed. Version 0.18 (2021) introduced tree-sitter for better parsing. Now at v0.24+, maintained actively with 40k+ stars. Inspired by tools like git log and delta.


