Instead of cat: bat
Use bat when you want to read a file in the terminal. It adds syntax highlighting, line numbers, Git change markers and paging. When its output goes to a pipe or a file it prints plain contents like cat, so it is safe to alias.
Both are for printing a file to the terminal to read it.
Why bat is better
- Syntax highlighting for a large number of programming and markup languages makes source files readable at a glance.
- Git integration shows which lines are added or modified relative to the index in a sidebar.
- Long files open in a pager automatically, so output does not scroll past.
- When it detects a non-interactive output such as a pipe or a file, it falls back to printing plain file contents, acting as a drop-in for cat.
- It works as a previewer for fzf and as a colourising pager for man pages.
When to keep cat
Keep cat in scripts and anywhere you concatenate files into another file or command. cat is on every Unix system, starts instantly and does nothing you did not ask for. bat is for reading, not for plumbing.
Switching
Install bat and call it directly, or alias cat to bat --paging=never if you want cat's no-pager behaviour with colours. On some older Debian and Ubuntu releases the executable is named batcat, so add a symlink or alias. Theme and style go in bat's config file.
Watch out
The batcat name on older Debian and Ubuntu breaks copied commands. Highlighting from stdin only works when bat can detect the language from the first line or you pass -l. The pager can surprise people who expected cat's output to stay on screen.
More newer, better command-line tools
Sources
- bat README
- cat (Unix) (Wikipedia)
- Modern Unix: alternatives to common Unix commands
- A list of new(ish) command line tools (Julia Evans)
Judged on 2026-11-06. See every command-line tools, or all 66 replacements.