bat
Display file contents with syntax highlighting
TLDR
Pretty print the contents of one or more files to stdout
Concatenate several files into the target file
Remove decorations and disable paging (--style plain can be replaced with -p, or both options with -pp)
Highlight a specific line or a range of lines with a different background color
Show non-printable characters like space, tab or newline
Remove all decorations except line numbers in the output
Syntax highlight a JSON file by explicitly setting the language
Display all supported languages
SYNOPSIS
bat [options] [files...]
PARAMETERS
--help
Show help message and exit.
-l, --language
Explicitly set the language for syntax highlighting.
-n, --number
Show line numbers.
-A, --plain
Show plain text without syntax highlighting.
-p, --paging
Specify when to use the pager: 'auto', 'always', or 'never'.
-r, --read-all
Read all files even if the pager is not used.
-f, --force-colorization
Force colorization even when output is piped.
-m, --map-syntax
Specify a mapping from filenames to syntaxes.
-c, --cache
Use 'clear' to clear the cache. Use 'config-dir' to show the configuration directory.
--theme
Set the color theme for syntax highlighting.
--list-themes
List available themes.
--style
Comma separated list of styles: 'numbers', 'grid', 'changes', 'header', 'rule'.
--tabs
Set the tab width. Defaults to 8.
--wrap
Specify the character to wrap long lines at: 'never', 'auto', or 'number'.
--terminal-width
Specify the terminal width.
-v, --version
Show version information and exit.
DESCRIPTION
bat is a cat(1) clone with syntax highlighting and Git integration. It reads files from standard input or command-line arguments and writes them to standard output. bat automatically detects the language using heuristics and file extensions, and then applies appropriate syntax highlighting. It can also display Git modifications (added, modified, deleted lines) directly in the output. bat aims to make viewing code on the command line more pleasant and productive.
It offers features like automatic paging (using less), file concatenation, theme customization, and integration with other tools. It can be configured to use different themes for syntax highlighting, show line numbers, and use custom headers and footers. bat is written in Rust and is known for its speed and efficiency.
CONFIGURATION
bat's configuration file (config.toml) allows you to customize its behavior. The location of the configuration file can be found using the bat --cache config-dir command. You can set default themes, styles, mappings, and other options in this file.
GIT INTEGRATION
bat can display Git modifications inline, showing which lines have been added, modified, or deleted since the last commit. This requires git to be installed and accessible in the system's PATH. This features must be enabled with the style option.