bat: cat clone with syntax highlighting
Enhanced cat replacement with syntax highlighting and Git integration for file viewing.
Learn more about bat
bat is a command-line utility written in Rust that functions as an enhanced version of the Unix cat command. It processes text files and applies syntax highlighting based on file extensions or explicit language specifications, while also integrating with Git to display modification indicators. The tool automatically detects terminal capabilities and can pipe output through pagers like less for large files, falling back to plain text output when used in non-interactive contexts. It supports over 200 programming and markup languages and can be integrated into existing workflows as a drop-in replacement for cat.
Git Integration
Displays Git modification markers in the sidebar, showing additions, deletions, and changes relative to the repository index.
Automatic Paging
Intelligently switches between paged and plain output based on terminal context, maintaining compatibility with pipes and redirects.
Non-printable Characters
Visualizes whitespace, control characters, and other non-printable elements with highlighting and special symbols.
# Display a single file with syntax highlighting
bat README.md
# Display multiple files at once
bat src/*.rs
# Concatenate files into a new document
bat header.md content.md footer.md > document.md
# Show line numbers only
bat -n main.rsv0.26.1
- –Add paging to '-h' and '--help' see PR #3478 (@MuntasirSZN)
- –Fix hang when using `--list-themes` with an explicit pager, see #3457 (@abhinavcool42)
- –Fix negative values of N not being parsed in <N:M> line ranges without `=` flag value separator, see #3442 (@lmmx)
- –Fix broken Docker syntax preventing use of custom assets, see #3476 (@keith-hall)
- –Fix diagnostics attempting to find the version of an executable named builtin when builtin pager is used. See #3498 (@keith-hall)
v0.26.0
- –Add build for windows/ARM64 platform. #3190 (@alcroito)
- –Add paging to `--list-themes`, see PR #3239 (@einfachIrgendwer0815)
- –Support negative relative line ranges, e.g. `bat -r:-10` / `bat -r='-10:'`, see #3068 (@ajesipow)
- –Support context in line ranges, e.g. `bat -r 30::5` / `bat -r 30:40:5`, see #3345 (@cavanaug)
- –Add built-in 'minus' pager, e.g. `bat --pager=builtin` see PR #3402 (@academician)
Use GitHub API to get correct PR submitter #2791 (@cyqsimon)
- –Set terminal title to file names when Paging is not Paging::Never #2807 (@Oliver-Looney)
- –`bat --squeeze-blank`/`bat -s` will now squeeze consecutive empty lines, see #1441 (@eth-p) and #2665 (@einfachIrgendwer0815)
- –`bat --squeeze-limit` to set the maximum number of empty consecutive when using `--squeeze-blank`, see #1441 (@eth-p) and #2665 (@einfachIrgendwer0815)
- –`PrettyPrinter::squeezeemptylines` to support line squeezing for bat as a library, see #1441 (@eth-p) and #2665 (@einfachIrgendwer0815)
- –Syntax highlighting for JavaScript files that start with `#!/usr/bin/env bun` #2913 (@sharunkumar)
Top in Developer Tools
Related Repositories
Discover similar tools and frameworks used by developers
pybind11
Header-only library creating minimal-boilerplate C++ Python bindings.
pygame
Python wrapper for SDL enabling 2D game development.
UniTask
Zero-allocation async/await using structs and custom method builders.
code-server
Run VS Code on remote servers via browser.
spdlog
Fast C++ logging with flexible sinks and fmt formatting.