bat
A cat clone with syntax highlighting and Git integration.
bat is a cat replacement written in Rust that adds syntax highlighting for
hundreds of languages, automatic paging, line numbering, and Git diff indicators
— all in a single binary.
Features
- Syntax highlighting for over 150 languages via the Sublime Text grammar engine
- Shows Git modifications in the gutter (added, changed, removed lines)
- Automatic paging through
lesswhen output is too tall for the terminal - Non-printable characters can be shown explicitly with
-A - Can be used as a drop-in
catreplacement in scripts with--plainmode - Integrates with tools like
fzf,delta, andman
Installation
cargo install bat
Or via your system package manager:
# Debian/Ubuntu
apt install bat
# macOS
brew install batUsage
# View a file with syntax highlighting
bat src/main.rs
# Show line numbers and Git changes
bat -n src/main.rs
# Use as a plain cat (no decorations)
bat --plain file.txt
# Preview files in fzf
fzf --preview 'bat --color=always {}'