bat

A cat clone with syntax highlighting and Git integration.

Screenshot of bat

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 less when output is too tall for the terminal
  • Non-printable characters can be shown explicitly with -A
  • Can be used as a drop-in cat replacement in scripts with --plain mode
  • Integrates with tools like fzf, delta, and man

Installation

cargo install bat

Or via your system package manager:

# Debian/Ubuntu
apt install bat

# macOS
brew install bat

Usage

# 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 {}'