bat
Back to Terminal
batBeginner7 min

bat: A Cat Replacement with Syntax Highlighting and Git Integration

Why bat Replaces cat

Replace cat with bat for syntax-highlighted file viewing, automatic theme detection, and built-in git line status. Configure aliases and integrations.

bat is a drop-in replacement for cat with syntax highlighting, git integration, and automatic paging. It also themes itself based on your terminal's color scheme.

By the end of this 7 min guide, you'll have a working bat setup and practical bat workflows you can use immediately.

Installing bat on Any System

Install bat:

brew install bat
Tip: Verify the installation with bat --version or bat -V after installing.

Themes & Syntax Highlighting

Create a config file at ~/.config/bat/config with your default theme and style. Add a shell alias so cat uses bat everywhere.

Here's a foundational configuration to start with:

# bat config
--theme="Catppuccin-mocha"
--style="numbers,changes,header"
--paging=auto

Aliases & Shell Integration

With bat configured, these bat-specific workflows will save you time every day:

Pro tip: Don't try to adopt everything at once. Start with bat file.py view with syntax highlighting and add more as it becomes habit.

Piping, Paging & Git Integration

Once you're comfortable with bat basics, these advanced techniques will transform your bat workflow:

Color & Theme Issues

Here are the most common bat issues and how to fix them:

Beyond cat

Congratulations — you now have a solid bat foundation. Here's where to go next:

← PreviousStarship Cross-Shell Prompt Setup: A Beautiful Prompt for Every ShellNext →GitHub CLI Workflow: Pull Requests, Issues, and Actions from Terminal