How bat is put together
bat is a Rust command-line utility that acts as a cat(1) clone with syntax highlighting, Git modification markers, automatic paging, and non-printable character display. It is structured as a library crate (src/lib.rs exposing Config, Controller, assets, syntax mapping) plus a thin binary (src/bin/bat) built on clap for argument parsing. Data flow: input files/stdin are read (with clircle-based I/O loop detection), mapped to a syntax via glob-based SyntaxMapping rules, highlighted by the syntect engine using serialized syntax/theme assets embedded at build time, decorated with line numbers/Git diff markers, and written either directly to stdout or through a pager (less or the built-in 'minus' pager). A build script (build/) generates static syntax-mapping code from TOML rule files and renders manpage/shell-completion templates.
Languages
Frameworks
Infrastructure
Major components
CLI application (src/bin/bat)
Binary entry point handling argument parsing (clap_app.rs), app setup, config-file resolution, directories, completions, and asset management.
Controller (src/controller.rs)
Orchestrates the pipeline: reads inputs, resolves syntaxes, applies highlighting/decoration, and dispatches output.
Printer & decorations (src/printer.rs, src/decorations.rs, src/vscreen.rs)
Renders highlighted lines with style components such as line numbers, grid, headers, Git modification markers, and non-printable notation.
Assets system (src/assets.rs, src/assets/*)
Loads/embeds serialized syntax sets and themes (bincode-compressed via flate2), supports building custom cached assets and acknowledgements.
Syntax mapping (src/syntax_mapping.rs, src/syntax_mapping/builtins/, build/syntax_mapping.rs)
Maps file paths/extensions to syntaxes via lazily compiled glob matchers generated at build time from per-platform TOML rule files.
Paging & preprocessor (src/pager.rs, src/paging.rs, src/less.rs, src/lessopen.rs)
Selects and launches an external pager (or built-in minus pager) and integrates the $LESSOPEN preprocessing hook.
Git/diff integration (src/diff.rs, gix dependency)
Computes blob diffs against the Git index to mark added/modified lines and support --diff context views.
Build script (build/main.rs, build/application.rs, build/util.rs)
Generates BUILTIN_MAPPINGS code from TOML definitions and renders manpage and bash/zsh/fish/PowerShell completion templates.
Log-file highlighting got smarter about log levels, and bat can now guess a file's language when reading from a pipe.
4 weeksWeek of 2026-08-10
Week of 2026-08-10latest
Log-file highlighting got smarter about log levels, and bat can now guess a file's language when reading from a pipe.
Week of 2026-08-03
A quiet week with just one small documentation fix.
Week of 2026-07-27
A busy week of dependency upgrades plus two real fixes: faster log scanning and closing a security gap in text sanitization.
Week of 2026-07-20
bat gained a new compatibility feature matching the classic Unix cat command.
Over the past month, the bat project focused on polishing syntax highlighting for log files and fixing small but user-visible bugs like language auto-detection from piped input. A new cat-compatible option (-b / --number-nonblank) was added, along with a security fix that stops hidden text-direction characters from slipping through the --sanitize flag. Much of the remaining activity was routine dependency updates and documentation cleanup.
Week by week
2026-08-10Log-file highlighting got smarter about log levels, and bat can now guess a file's language when reading from a pipe.latest4 changes
Fix
Better log-level coloring in Syslog files
The Syslog syntax definition now keeps log-level labels (like INFO or ERROR) properly highlighted instead of losing their color styling.
Refactor
Faster detection of log levels in log files
Log-level matching now only checks at the start of each line, avoiding slow repeated scans through long log files.
Fix
Auto-detect language from piped input
When content is fed to bat through a pipe (rather than a named file), it can now figure out the programming language automatically.
Docs
Documentation typo fixes
A batch of small typos in the project's documentation were corrected.
2026-08-03A quiet week with just one small documentation fix.1 change
Docs
Fixed a doubled word in the README
A repeated word in the project's front-page README was removed.
2026-07-27A busy week of dependency upgrades plus two real fixes: faster log scanning and closing a security gap in text sanitization.6 changes
Refactor
Avoid repeated log level scans
Highlighting log files no longer re-scans lines over and over to find log levels, making large logs render faster.
Fix
Security fix for hidden direction characters
The --sanitize option previously let certain invisible characters (used in 'trojan source' attacks) pass through; they are now stripped out.
Fix
Paging fix for --list-languages
Listing all supported languages no longer gets stuck or misbehaves with the pager in certain situations.
Chore
Resolved security audit failures
Dependency versions were updated so the project passes its automated security audit again.
Chore
Routine dependency bumps
Several underlying libraries (including regex, gix, minus, and others) were upgraded to newer versions for stability and fixes.
Docs
Changelog updates
The changelog was updated to record the recent performance and sanitization fixes.
2026-07-20bat gained a new compatibility feature matching the classic Unix cat command.1 change
Feature
New -b / --number-nonblank option
You can now number only non-empty output lines, just like 'cat -b', improving compatibility for people switching between the two tools.
Dependencies and code review
Dependency advisories
Security Watch
No known advisories across 0 scanned dependencies.
No known advisories in the scanned dependencies.
Code review
No concrete code-level issues confirmed.
Get this report every week for your repos.
GitZoid learns each repo, reports what changed, and flags what needs attention. One flat price for the whole team.
$19 a month, flat · First 10 outputs free · No card required