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.
Install bat:
brew install batbat --version or bat -V after installing.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=autoWith bat configured, these bat-specific workflows will save you time every day:
bat file.py view with syntax highlightingbat --diff show git changes inlinebat -p plain mode (no line numbers)rg foo | bat$MANPAGER for colored man pagesOnce you're comfortable with bat basics, these advanced techniques will transform your bat workflow:
--tabs for tab character rendering--list-languagesHere are the most common bat issues and how to fix them:
BAT_THEME or check terminal truecolor supportbat --list-themes--paging=nevercat to use bat? Add alias cat="bat"Congratulations — you now have a solid bat foundation. Here's where to go next: