Как установить bat CLI: cat с подсветкой, paging, --theme, сравнение с cat

Поставить bat, настроить paging и темы, отключить pager в скриптах, оставить cat для POSIX.

cat выводит байты; конфиги и логи в терминале удобнее с подсветкой и номерами строк. bat (Rust, sharkdp) — cat с pager и темами. Материал:; reading configs, CI logs, or source in the terminal deserves syntax color and line numbers. bat (Rust, sharkdp) is a cat with language detection, paging, and themes. установка macOS/Linux, paging, --theme, bat vs cat для читателей hereink рядом с ripgrep и fd.

The query is how to install bat CLI set paging and theme compare to cat. You should finish with bat on PATH, comfortable paging through a long file, --paging=never for scripts, and a theme picked via --theme or ~/.config/bat/config.

installbrew · apt · dnf
pagingless · --paging
theme--theme · config
install batpaging & themevs cat

Что решает bat

Readable file previews

bat src/lib.rs highlights syntax, shows line numbers, and can show Git change markers. Lighter than opening an IDE for a quick peek over SSH or locally.

Подходит rg and fd

rg -l pattern | xargs bat opens hits with color; fd -e md | xargs bat previews many paths. Our fd guide covers search; this article stays on reading with bat.

Upstream: github.com/sharkdp/bat. Run bat --version after install.

Установка macOS и Linux

  1. 1
    macOS (Homebrew)

    brew install bat. Verify with which bat and bat --version.

  2. 2
    Debian / Ubuntu

    sudo apt update && sudo apt install bat. If packages lag, use GitHub Releases or cargo install bat.

  3. 3
    Fedora / Arch

    Fedora: sudo dnf install bat. Arch: sudo pacman -S bat.

  4. 4
    Windows (optional)

    scoop install bat or choco install bat. Examples below focus on macOS/Linux.

  5. 5
    First run

    In any repo: bat README.md. Tall terminals may page; short files print once.

Paging: less по умолчанию, off в скриптах

When output exceeds one screen, bat hands off to a pager (usually less). Great for humans; pipes and scripts need plain stdout.

bat long.log
bat --paging=never package.json
export BAT_PAGER=""
bat --paging=never Dockerfile
bat --paging=always src/main.go

--paging values include auto (default), never, and always. Inside less: space for next page, q to quit, /pattern to search.

Темы: --theme и config

bat --list-themes
bat --theme=TwoDark src/app.ts
bat --theme=GitHub README.md
echo '--theme="TwoDark"' >> ~/.config/bat/config
echo '--style="numbers,changes,header"' >> ~/.config/bat/config
export BAT_THEME="Monokai Extended"
bat Cargo.toml

--style toggles line numbers, headers, and Git bars. For a minimal cat-like view, use --style=plain or bat --plain.

Частые флаги

rg -n "ERROR" app.log | bat -l log
bat -r 10:25 src/config.yaml
bat src/*.rs
bat -A .env.example

bat vs cat

Goalbatcat
Interactive source/configbat file.tscat file.ts
Pipe to another toolbat --paging=never --plain file | wc -lcat file | wc -l
Concatenate filesbat a b c (headers)cat a b c
Binary dataavoidavoid; use xxd
POSIX minimal imageextra packagebuilt in
Pagingauto + lessnone; use less

You may alias cat to bat --paging=never --plain for daily use; legacy scripts can call /bin/cat when compatibility matters.

Fits
Terminal reading of code and configs, log snippets, piping rg/fd hits into previews.
Не подходит
Zero-dependency POSIX entrypoints or binary-safe byte streams—use cat or bat --plain --paging=never after checking output.
Overlap with the fd+bat article?

That guide pairs fd search with bat; this one goes deeper on install, --paging, --theme, and cat comparison.

Theme looks washed out?

Pick a light theme like GitHub or set BAT_THEME. Preview names with bat --list-themes | bat in your terminal.

Will bat break pipes?

Pagers and decorations can. Use --paging=never in scripts; add --plain when you need plain text.

Конфиги ясны — сверить на одном листе

Once modules are clear in the terminal, service boundaries still belong on a shared canvas. See как создать пространство.

Начать