Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

bat

Stow package for ~/.config/bat/config. bat is a cat clone with syntax highlighting, line numbers, and git change markers.

Table of contents

Layout

FileStows to
bat/.config/bat/config~/.config/bat/config

Settings

--theme="ansi"                                          # terminal palette (themed by p10k)
--style="numbers,changes,header,grid,header-filesize"   # line nums, git markers, file header + size, gutter grid
--pager="less -RFX"                                     # raw colors, quit-if-one-screen, no alt-screen

--theme="ansi" is intentional — it picks up whatever color scheme the terminal/Dracula gives us instead of locking to a fixed bat theme. Run bat --list-themes to see alternatives.

BAT_THEME=ansi is also set in zsh/.zshrc as a belt-and-suspenders default for tools that invoke bat via env (e.g., MANPAGER).

--pager="less -RFX" matches LESS='-RFX' in zsh/.zshrc so the pager behaves identically whether bat invokes it or LESS is exported.

Syntax mappings

bat recognizes most filenames by extension/shebang, but a few common files need help:

--map-syntax="Dockerfile.*:Dockerfile"   # e.g. Dockerfile.dev
--map-syntax="*.jenkinsfile:Groovy"
--map-syntax="*.tfvars:HCL"              # Terraform variable files
--map-syntax=".envrc:Bash"               # direnv files
--map-syntax=".ignore:Git Ignore"        # ripgrep / fd ignore files

Add more as new conventions show up.

Regenerating the default template

bat ships a fully commented default config:

bat --generate-config-file        # writes ~/.config/bat/config if missing

If you want to start over with the full template, delete the symlink and run the above, then move the new file into bat/.config/bat/config and re-stow.

Fresh-machine setup

brew install bat        # in the Brewfile
stow bat