Site Tools


terminal:tools:bat

Table of Contents

bat

cat with syntax highlighting, line numbers, and git diff integration. Written in Rust.

bat file.py                 # view with syntax highlighting
bat -n file.py              # line numbers only (no decorations)
bat --plain file.py         # plain output (no line numbers, no pager)
bat -A file.py              # show non-printable characters
bat *.md                    # multiple files

As a pager — set as MANPAGER in ~/.profile:

export MANPAGER="sh -c 'col -bx | bat -l man -p'"
export PAGER=bat

With fzf — preview files:

fzf --preview 'bat --color=always {}'

Install

sudo apt install bat
# binary may be called batcat on Debian/Ubuntu — alias it:
alias bat='batcat'

See Also

terminal/tools/bat.txt · Last modified: by 127.0.0.1