Skip to content

Repository files navigation

dog

Faster than bat cli, with better theming. (written in swift, powered by tree-sitter, btw)

Animated terminal demo of dog highlighting a Swift file, cycling through themes — default UtilityDark, Catppuccin Frappé, Vim Adwaita Dark, Tokyo Night, then --light

Themes: UtilityDark (default), Catppuccin Frappé, Vim Adwaita Dark, Tokyo Night, built-in --light.

A cat alternative for macOS and Linux that prints files to your terminal with syntax highlighting — backgrounds, line numbers, and gutter included. Auto-pages with less. Starts up in ~5ms, so it's great piped into previewers like fzf, tv, and yazi.

# dog responds instantly when you call them
dog Sources/dog/Dog.swift

# dog can brighten up your day
dog --light src/lib.rs

# You can pass dog a bone
echo 'struct Point { let x, y: Int }' | dog -l swift

# dog remembers your favorite theme
dog --set-default-theme 'Nord Dark'

# dog plays well with other pets
fzf --preview 'dog --color=always --theme "Catppuccin Mocha" {}'

A yazi plugin wraps dog as a previewer with caching and theme config.

Why dog

  • 800+ Zed themes — drop a JSON file in, or point --theme-dir at your existing ~/.config/zed/themes and use what you already have. Backgrounds, line numbers, and gutter are all theme-controlled, opacity included. Two zero-cost built-ins ship too — dark is the default, --light flips to the bright one. Any theme can be saved as your default — stored precomputed, so it loads as fast as the built-ins.
  • Up to 14.6× faster than bat on large files — 54k lines of TypeScript in 0.4s vs 5.8s. 100% syntax coverage across all 17 supported languages.
  • ~5ms startup, every language — precompiled highlight queries mean there's no per-language warmup. In fzf or yazi, that's the latency on every keystroke.
  • Single binary, no runtime deps17 grammars statically compiled in. Copy it anywhere, it runs.
  • Built on tree-sitter — full AST parse, not regex. Highlight queries from nvim-treesitter.
  • Written in Swift — direct tree-sitter C API. Custom ANSI renderer, custom zero-copy JSON parser (sub-millisecond theme loads).

Supported languages

Language Speed vs bat, large files
Bash 6.1×
C 5.8×
C++ 7.7×
CSS 6.4×
Go 6.7×
HTML 1.7×
JavaScript 10.1×
JSON 9.1×
Lua 5.2×
Markdown 7.7×
Python 6.1×
Ruby 5.2×
Rust 6.8×
Swift 5.3×
TSX 11.9×
TypeScript 14.6×
YAML 9.5×

HTML's ratio looks tight because its "large" benchmark file is only ~2,400 lines — it benchmarks like a medium file. Full matrix in the benchmarks.

Tip

The language is auto-detected from the file extension, filename, or shebang — force one with -l <language>. dog --list-languages prints the names to use.

Install

Install script — picks the right build for your machine, installs it, and sets up shell completions:

curl -fsSL https://sh.dog/install | sh

Homebrew:

brew tap edden27/dog
brew trust edden27/dog
brew install dog

Binary — four builds: dog-macos-arm64, dog-macos-x86_64, dog-linux-x86_64, dog-linux-arm64. Grab yours:

curl -L https://github.com/edden27/dog/releases/latest/download/dog-macos-arm64.tar.gz | tar xz
sudo mv dog /usr/local/bin/

From source — needs Swift 6.3 or newer (Xcode 26 on macOS):

git clone https://github.com/edden27/dog
cd dog
make build && make install

make install copies the binary into /usr/local/bin, asking for sudo only when it has to; make install PREFIX=~/.local avoids sudo entirely. Only need a few languages? dog can compile a subset — a Swift+JSON-only build is ~5 MB instead of ~20. See custom builds.

Requires macOS 14+ or Linux with the Swift runtime (bundled in the Linux binary).

Tab completions — dog generates its own completion script for bash, zsh, and fish (dog --generate-completion-script zsh); the docs walk through the one-time install for your shell.

How does it compare to bat?

Side-by-side comparison of dog and bat rendering a 260,000-line C file — dog finishes in about a second while bat takes several

Left: dog in 1.1s, right: bat in 6.9s — printing the same 260,493-line C file.

dog bat
Engine tree-sitter, full AST regex per line
Themes Zed JSON, 800+ available TextMate XML
Bold & italic fonts (all 4 styles) Theme-controlled Partial — italics opt-in, never combined
Line background, gutter, line-number colors Theme-controlled Fixed
Languages 17 200+
Syntax coverage (avg) 100% 77%
Multi-file, git gutter, Windows Not yet Yes
Binary size ~20 MB (macOS) ~5 MB

Full benchmarks and methodology in the docs.

Documentation

Status

0.1.0 — first public release. dog is stable at 0.1 but still a puppy: we don't anticipate breaking changes, but it is in active development. Known limitations:

  • Single file at a time (multi-file planned)
  • No git-diff gutter
  • No Windows
  • --range, --header, and --no-line-numbers are stubs
  • $PAGER not honored (pager is hardcoded to less -R)

Most likely next — no promises, no order: line ranges, line highlighting, headers/footers, TOML config, more languages, alternative pagers, git integration, man + --help highlighting. See What's next.

Test suite: 222 Swift unit tests across 31 suites + 51 integration assertions across 9 suites + 13 bat-compatibility scenarios.

Acknowledgements

  • Highlight queries from nvim-treesitter (Apache 2.0)
  • Tree-sitter grammars from the upstream tree-sitter community
  • Theme format from Zed
  • Terminal recordings made with vhs by Charm

Tip

🐕 Dog Fact — Dogs love dark mode. They have superior night vision and motion detection, which was more important evolutionarily than color vision for their survival as hunters.

License

MIT — see LICENSE.

About

A cli like cat, faster than bat, with better theming. With ~5ms startup it's a perfect previewer for terminal tools like fzf, tv, yazi.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Contributors

Languages