61,271
stars
+19
2,334
forks
266
watchers
2,316
prs
1,650
issues
43
releases
92
discussions
README
A cat(1) clone with syntax highlighting and Git integration.
Key Features •
How To Use •
Installation •
Customization •
Project goals, alternatives
[English]
[中文]
[日本語]
[한국어]
[Русский]
Syntax highlighting
bat supports syntax highlighting for a large number of programming and markup
languages:
!Syntax highlighting example
Git integration
bat communicates with git to show modifications with respect to the index
(see left sidebar):
!Git integration example
Show non-printable characters
You can use the -A/--show-all option to show and highlight non-printable
characters:
!Non-printable character example
Automatic paging
By default, bat pipes its own output to a pager (e.g. less) if the output is too large for one screen.
If you would rather bat work like cat all the time (never page output), you can set --paging=never as an option, either on the command line or in your configuration file.
If you intend to alias cat to bat in your shell configuration, you can use alias cat='bat --paging=never' to preserve the default behavior.
File concatenation
Even with a pager set, you can still use bat to concatenate files :wink:.
Whenever bat detects a non-interactive terminal (i.e. when you pipe into another process or into a file), bat will act as a drop-in replacement for cat and fall back to printing the plain file contents, regardless of the --pager option's value.
How to use
Display a single file on the terminal
bash
bat README.md
Display multiple files at once
bash
bat src/.rs
Read from stdin, determine the syntax automatically (note, highlighting will
only work if the syntax can be determined from the first line of the file,
usually through a shebang such as !/bin/sh)
bash
curl -s https://sh.rustup.rs | bat
Read from stdin, specify the language explicitly
bash
yaml2json .travis.yml | json_pp | bat -l json
Show and highlight non-printable characters:
bash
bat -A /etc/hosts
Use it as a cat replacement:
bash
bat note.md quickly create a new file
bat header.md content.md footer.md document.md
bat -n main.rs show line numbers (only)
bat f - g output 'f', then stdin, then 'g'.
Integration with other tools
fzf
You can use bat as a previewer for fzf. To do this,
use bat's --color=always option to force colorized output. You can also use --line-range
option to restrict the load times for long files:
bash
fzf --preview "bat --color=always --style=numbers --line-range=:500 {}"
For more information, see fzf's README.
find or fd
You can use the -exec option of find to preview all search results with bat:
bash
find … -exec bat {} +
If you happen to use fd, you can use the -X/--exec-batch option to do the same:
bash
fd … -X bat
ripgrep
With batgrep, bat can be used as the printer for ripgrep search results.
bash
batgrep needle src/
tail -f
bat can be combined with tail -f to continuously monitor a given file with syntax highlighting.
bash
tail -f /var/log/pacman.log | bat --pTop issues
#1053Discussion: a builtin pager for 'bat'31 comments · 2020-06-05#2455`batcat` has (not) been renamed to `bat` in Debian30 comments · 2023-01-21#1006Keyboard arrow keys not working for scrolling from STDIN, rather shows keycode of the key pressed26 comments · 2020-05-18#1341Custom fallback syntax opt-in23 comments · 2020-10-24#1185Open file starting at line number19 comments · 2020-09-10#636files of infinite length cause bat to crash19 comments · 2019-08-23#3444ctrl-c still exits less, even when bat isn't passing `--quit-on-intr`18 comments · 2025-10-19#3724Man pages displaying bold reset code 22m15 comments · 2026-05-05
Discussions
#4107Add KDL syntax highlighting1 comments · 2026-11-01#4089How to grep output ?1 comments · 2026-10-19#4010any way to remove leading space added to each line when the style is plain?3 comments · 2026-09-12#3898Script that asks to write to terminal when using Bat in --paging=always mode0 comments · 2026-08-29#3796ccline: AI at the zsh prompt — built for people who use tools like bat0 comments · 2026-06-10#3722Question about checksum verification UX1 comments · 2026-05-03#3705word wrap seems not to work1 comments · 2026-04-27#3596does bat support vi navigation ?4 comments · 2026-02-20
Latest release
v0.26.1 v0.26.1 2025-12-02v0.26.1 Features - Add paging to '-h' and '--help' see PR 3478 (@MuntasirSZN) Bugfixes - Fix hang when using --list-themes with an explicit pager, see 3457 (@abhinavcool42) - Fix negative values of N not being parsed in line ranges without = flag value separator, see 3442 (@lmmx) - Fix broken Docker syntax preventing use of custom assets, see 3476 (@keith-hall) - Fix decorations being applied unexpectedly when piping. Now only line numbers explicitly required on the command line should be applied in auto decorations mode for cat compatibility. See 3496 (@keith-hall) - Fix di