Как установить fd и bat на macOS и Linux: поиск файлов, cat с подсветкой и связка с rg

Поставить fd/bat, выполнить первый поиск и просмотр, связать с rg.

find и cat в репозитории быстро надоедают. fd и bat — Rust-замены: find and reading sources with cat gets old fast. fd and bat are Rust-based replacements: fd respects .gitignore while finding paths by name or extension; bat is a syntax-highlighting cat with line numbers and paging. Материал: установка macOS/Linux, поиск fd, просмотр bat, связка с rg/grep для читателей hereink.

Запрос how to install fd and bat CLI tools on macOS and Linux. You should finish with both commands installed, a first fd and bat run, and a simple pipeline that finds files then searches or previews them.

fdbrew · apt · dnf
bathighlight · line numbers
combofd · rg · bat

Что решают fd и bat

fd instead of daily find

find . -name '*.ts' is verbose and often walks node_modules. fd recurses by default, honors ignore rules, and exposes -e, -t, and case flags—ideal for narrowing a file set before editing or searching.

bat makes cat readable

bat src/main.rs detects language, highlights syntax, shows line numbers, and uses a pager (disable with --paging=never). Configs, logs, and CI snippets are easier to scan than plain cat.

Upstream: github.com/sharkdp/fd and github.com/sharkdp/bat. After install run fd --version and bat --version.

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

  1. 1
    macOS (Homebrew)

    brew install fd bat. Verify with which fd bat and the version flags. Same formula on Apple Silicon and Intel.

  2. 2
    Debian / Ubuntu

    sudo apt update && sudo apt install fd-find bat. The binary may be named fdfind; add alias fd=fdfind in your shell or follow the package note to expose fd. Check with fdfind --version or fd --version.

  3. 3
    Fedora / Arch

    Fedora: sudo dnf install fd bat. Arch: sudo pacman -S fd bat. If repos lag, grab release binaries from GitHub and put them on PATH.

  4. 4
    Optional: Rust

    With Rust installed: cargo install fd-find bat. Slower compile, useful when packages are missing or stale.

Поиск файлов через fd

fd config
fd -e tsx
fd -t f README
fd -i dockerfile
fd \.env$ /etc --follow

Like ripgrep, fd reads .gitignore in Git trees. To include ignored paths, see upstream flags such as --no-ignore—expect much more output.

Просмотр через bat

bat src/lib/utils.ts
bat --paging=never Dockerfile
bat -n package.json
bat src/*.go

Tweak theme via ~/.config/bat/config or BAT_THEME; list themes with bat --list-themes. The bat README shows an optional cat alias—only if you want it.

Связка с grep / ripgrep (rg)

GoalExampleNote
Search inside one extensionfd -e py | xargs rg "def main"fd narrows to .py, rg searches content
Search then highlightrg -l "TODO" src | xargs batrg -l lists files; bat opens each
Piped outputrg -n "error" app.log | bat -l log-l log sets language for highlighting
Classic grepfd -e sh | xargs grep -n "set -e"Works without rg; rg is usually faster—see our ripgrep guide on this site
Подходит
Monorepo work: configs, scripts, logs; developers who want shorter find syntax and readable terminal previews.
Не подходит
IDE-wide refactor or GUI search. This guide focuses on macOS/Linux package paths; on Windows use scoop/chocolatey per upstream README.
Ubuntu only has fdfind, not fd?

Debian-family packages often ship fd-find with a fdfind binary. Use alias fd=fdfind or a compatibility package that provides the fd name.

Can bat replace cat in scripts?

For human reading, yes. For pipelines that need plain stdout, use bat --paging=never --plain or keep cat so pagers and decorations do not break downstream tools.

fd or find?

Complex mtime, permissions, or -exec jobs stay on find. Quick name/extension lists are shorter with fd. Keep both.

После поиска в терминале — сверить на одном рисунке

Once fd/rg point at modules, service boundaries still belong on one shared board. See как создать пространство.

Начать