ConfigsApr 11, 2026·2 min read

bat — A cat Clone with Wings and Syntax Highlighting

bat is a cat clone with wings — syntax highlighting, Git integration, automatic paging, and line numbers. A drop-in replacement for cat that shows code and configs beautifully in your terminal. Written in Rust.

TL;DR
bat replaces cat with syntax highlighting, Git diff markers, line numbers, and automatic paging in your terminal.
§01

What it is

bat is a command-line tool that serves as a drop-in replacement for the Unix cat command. It adds syntax highlighting for over 200 languages, Git integration (showing modified lines), automatic paging, line numbers, and theme support. Written in Rust, it is fast and has no runtime dependencies beyond the binary.

bat targets developers, sysadmins, and anyone who reads code or configuration files in the terminal. If you use cat to view files, bat makes the output immediately more readable.

§02

How it saves time or tokens

Reading raw file output in the terminal without syntax highlighting means mentally parsing code structure. bat adds color-coded syntax, line numbers, and Git change markers automatically. For reviewing configuration files, log snippets, or code during debugging, this visual structure reduces the time to understand what you are looking at. It integrates with tools like fzf, ripgrep, and man for enhanced workflows.

§03

How to use

  1. Install bat:
brew install bat                        # macOS
sudo apt install bat                    # Debian/Ubuntu (may be batcat)
cargo install bat                       # From source
  1. Use it like cat:
bat file.py                             # View with highlighting
bat src/*.rs                            # Multiple files
bat -A config.yml                       # Show non-printable characters
  1. Optionally alias cat to bat in your shell config.
§04

Example

# View a Python file with syntax highlighting
bat app.py

# Show only specific line range
bat --line-range 10:20 main.go

# Use as a pager for other tools
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
git diff | bat

# Combine with ripgrep for highlighted search results
rg --json 'TODO' | bat --language json

# List available themes
bat --list-themes
§05

Related on TokRepo

§06

Common pitfalls

  • On Debian/Ubuntu, the package may install as batcat due to a naming conflict. Create an alias: alias bat=batcat.
  • bat uses a pager by default (less). For piping output to other commands, use bat --paging=never or bat -p to get plain output.
  • Custom themes need to be placed in the bat config directory and rebuilt with bat cache --build. Themes from VS Code can be converted.

Frequently Asked Questions

Can bat replace cat entirely?+

For interactive use, yes. bat handles all cat functionality plus adds highlighting and paging. For scripting and piping, use bat -pp (plain mode, no paging) to get behavior identical to cat.

Does bat slow down for large files?+

bat is written in Rust and handles large files efficiently. For very large files (hundreds of MB), syntax highlighting adds some overhead. Use bat -p for plain mode on huge files.

How many languages does bat support?+

bat supports over 200 languages and file formats for syntax highlighting out of the box. You can add custom syntax definitions using the Sublime Text syntax format.

Does bat work with Git?+

Yes. bat shows Git modifications in the gutter: additions, deletions, and changes are marked with colored symbols next to line numbers. This works automatically in any Git repository.

Can I change the color theme?+

Yes. bat ships with several themes and supports custom themes. Run bat --list-themes to see available themes. Set a default with the BAT_THEME environment variable or in the bat config file.

Citations (3)

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets