explaingit

sharkdp/bat

🔥 Hot58,925RustAudience · developerComplexity · 2/5ActiveLicenseSetup · easy

TLDR

A command-line tool that displays file contents with syntax highlighting, line numbers, and Git change tracking, a colorful, feature-rich replacement for the Unix cat command.

Mindmap

mindmap
  root((bat))
    What it does
      Syntax highlighting
      Line numbers
      Git integration
      Pager support
    How to use it
      Drop-in cat replacement
      Read files or stdin
      Specify languages
      Pipe to other tools
    Integrations
      fzf preview
      ripgrep results
      Man pages
      Help text
    Tech stack
      Rust
      Fast startup
      Large file handling

Things people build with this

USE CASE 1

View source code in your terminal with colors and line numbers instead of plain text.

USE CASE 2

Preview files in fzf fuzzy finder with syntax highlighting for faster navigation.

USE CASE 3

See which lines changed in a file since the last Git commit while reading it.

USE CASE 4

Display man pages and help text with syntax highlighting for better readability.

Tech stack

Rust

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

bat is a command-line tool for displaying the contents of files in your terminal, serving as an enhanced replacement for the standard Unix cat command. The core problem it solves is that reading source code or configuration files in a terminal with the default cat command is tedious: there is no color, no line numbers, and no way to tell at a glance what changed in a file. bat adds syntax highlighting for a large number of programming and markup languages, line numbers, and Git integration that shows which lines have been modified, added, or deleted since the last commit, all displayed in a scrollable pager so long files don't flood your screen. The tool is designed as a drop-in replacement for cat, meaning you use it the same way. When bat detects that its output is being piped to another command or to a file rather than displayed in a terminal, it automatically removes the decorative formatting and behaves exactly like plain cat, so it works correctly in scripts without any adjustment. Beyond standalone use, bat integrates well with other command-line tools: it can serve as the preview window in fzf, a fuzzy file finder; it can colorize the output of ripgrep search results; it can display man pages with syntax highlighting; and it can colorize help text from other commands. bat supports both reading from files and from standard input, and it can highlight specific programming languages you specify manually. The project is written in Rust, which gives it fast startup time and good performance even on large files. You would use bat whenever you are frequently reading code, config files, or logs in a terminal and want readable, color-coded output with contextual Git information, without leaving the command line.

Copy-paste prompts

Prompt 1
How do I install bat and use it as a drop-in replacement for cat in my shell?
Prompt 2
Show me how to integrate bat with fzf so file previews have syntax highlighting.
Prompt 3
How do I make bat show Git changes (added/modified/deleted lines) when I view a file?
Prompt 4
Can I use bat to colorize ripgrep search results, and if so how?
Prompt 5
What programming languages does bat support for syntax highlighting?
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.