bat is a command-line file viewer with syntax highlighting, line numbers, Git integration, and paging.
It is used as a more readable alternative to the standard cat command.
The tool is installed through Homebrew and declared in the project Brewfile.
It is part of the curated Homebrew environment; see Homebrew setup to install everything at once.
Install bat directly:
brew install batVerify the installation:
bat --version
brew list --formula | grep -x batDisplay a file:
bat README.mdDisplay several files:
bat README.md BrewfileDisplay line numbers:
bat --number README.mdDisable paging:
bat --paging=never README.mdbat automatically detects the file type and applies syntax highlighting.
Force a language when detection is incorrect:
bat --language yaml .pre-commit-config.yamlList the supported languages:
bat --list-languagesInside a Git repository, bat can display modified lines in the gutter.
This makes it useful for reviewing configuration and documentation changes without opening an editor.
Use cat when raw, unformatted output is required in a script or pipeline.
Use bat for interactive reading in the terminal.
Avoid replacing cat globally in scripts because bat adds formatting and may
invoke a pager.
Review the Brewfile:
bat BrewfileReview the pre-commit configuration:
bat .pre-commit-config.yamlDisplay a specific line range:
bat --line-range 20:60 README.mdAn optional interactive alias can be added:
alias cat='bat --paging=never'This alias should only be used interactively and should not be relied on in portable scripts.
Display all options:
bat --helpConfirm the executable path:
command -v batOn some Linux distributions, the executable may be named batcat, but the
Homebrew installation uses bat.
Remove bat with Homebrew:
brew uninstall batThen remove its entry from profiles/full/Brewfile.
