| Crates.io | batless |
| lib.rs | batless |
| version | 0.4.0 |
| created_at | 2025-07-28 19:48:11.26157+00 |
| updated_at | 2026-01-08 10:29:39.194159+00 |
| description | A non-blocking, LLM-friendly code viewer inspired by bat |
| homepage | https://github.com/docdyhr/batless |
| repository | https://github.com/docdyhr/batless |
| max_upload_size | |
| id | 1771508 |
| size | 1,022,301 |
Transform code viewing from blocking interactive pagers to predictable streaming output:
❌ Before: bat file.rs → hangs in CI/CD, requires terminal, blocks automation
✅ After: batless file.rs → streams immediately, works everywhere, never blocks
Key Advantages:
batless is a minimal, blazing-fast syntax viewer that never blocks, never pages, never hangs. While bat is a feature-rich "cat with wings" for human users, batless is purpose-built for:
Core guarantee: batless will NEVER wait for user input or block your pipeline.
# Linux (x86_64)
curl -L https://github.com/docdyhr/batless/releases/latest/download/batless-x86_64-unknown-linux-gnu.tar.gz | tar xz
# macOS (Intel)
curl -L https://github.com/docdyhr/batless/releases/latest/download/batless-x86_64-apple-darwin.tar.gz | tar xz
# macOS (Apple Silicon)
curl -L https://github.com/docdyhr/batless/releases/latest/download/batless-aarch64-apple-darwin.tar.gz | tar xz
cargo install batless
brew tap docdyhr/batless
brew install batless
# View a file with syntax highlighting
batless src/main.rs
# Plain text output (no colors)
batless --plain file.py
# With line numbers (cat -n compatibility)
batless -n file.py
# JSON output for structured processing
batless --mode=json --max-lines=100 src/lib.rs
# Extract code summary (functions, classes, imports)
batless --mode=summary src/main.rs
# Get version info as JSON
batless --version-json
| Feature | batless |
bat |
cat |
|---|---|---|---|
| Never Blocks | ✅ Guaranteed | ❌ Uses pager | ✅ Simple output |
| Syntax Highlighting | ✅ 100+ languages | ✅ Rich highlighting | ❌ None |
| JSON Output | ✅ First-class | ❌ Not supported | ❌ Not supported |
| Summary Mode | ✅ AI-optimized | ❌ Not supported | ❌ Not supported |
| Memory Usage | ✅ Streaming | ⚠️ Loads full file | ✅ Streaming |
| Binary Size | ✅ ~2MB | ⚠️ ~10MB | ✅ System binary |
| Startup Time | ✅ <5ms (typical) | ⚠️ ~180ms | ✅ <10ms |
less, no more, no blocking|, >, and subprocess calls--max-lines) and/or bytes (--max-bytes)lines always retains the full file while summary_lines carries the condensed viewtoken_count reflects the full file even when the sampled tokens array is capped (~2K entries) and tokens_truncated tells you when sampling kicked inbatless has a focused design philosophy. It intentionally does NOT provide:
| Feature | Why Not? | Use Instead |
|---|---|---|
| Pattern Search | That's grep's job |
grep -rn "pattern" path/ |
| Arbitrary Line Ranges | Beyond our scope | sed -n '10,50p' file |
| File Globbing | Shell handles this | batless *.py (shell expands) |
| Interactive Paging | We're non-blocking | Use bat or less |
| Git Integration | Keep it simple | Use git diff or bat |
| File Management | Not a file browser | ls, find, fd |
| Text Editing | Viewer only | Use your editor |
❌ "batless is a drop-in replacement for bat" ✅ Reality: batless is purpose-built for automation and AI, not interactive use
❌ "batless should add grep-like search"
✅ Reality: Unix philosophy - do one thing well. Use grep for searching
❌ "batless needs more features like bat" ✅ Reality: Less is more. Our constraints are features for automation
bat - it has better human-focused featuresgrep, rg (ripgrep), or ag (silver searcher)bat with its full decoration suiteDo ONE thing well: Stream code with syntax highlighting, never block.
Everything else? There's already a better tool for that.
# Syntax highlighted output
batless main.rs
# Plain text (no colors)
batless --plain main.rs
# With line numbers
batless -n main.rs
# Limit output
batless --max-lines=50 large-file.py
batless --max-bytes=10000 huge-file.log
# JSON output for LLM processing
batless --mode=json --include-tokens --summary src/main.rs | jq
# Extract code structure only
batless --mode=summary src/*.rs
# CI/CD context generation
batless --mode=json --max-lines=100 failing-test.rs > context.json
# Machine-readable metadata
batless --version-json
JSON structure tips:
linesalways contains the full file content (even when--summaryis enabled), whilesummary_linescarries the condensed view. The payload now exposestotal_lines_exact,token_count, andtokens_truncatedso downstream tools can distinguish between fully processed files and sampled metadata.
# Use as PAGER replacement
PAGER="batless --plain" gh pr view 42
# Process multiple files
find src -name "*.rs" -exec batless --mode=summary {} \;
# Combine with grep
grep -l "TODO" src/*.py | xargs batless -n
# Stream stdin
cat file.rs | batless --language=rust
# Use AI-optimized profile
batless --profile=claude main.rs
# Interactive configuration wizard
batless --configure
# List available profiles
batless --list-profiles
batless supports multiple color themes for syntax highlighting:
# List available themes
batless --list-themes
# Use specific theme
batless --theme="Solarized (dark)" file.py
batless currently includes 7 carefully curated themes:
Try different themes to find the one that works best for your workflow:
# Try each theme with your code
batless --theme="InspiredGitHub" examples/theme-showcase.rs
batless --theme="Solarized (dark)" examples/theme-showcase.rs
batless --theme="base16-mocha.dark" examples/theme-showcase.rs
Note: Theme examples are available in docs/themes/ and can be regenerated with
./scripts/generate-theme-showcase.sh
# Auto-detect (default)
batless file.txt
# Force specific language
batless --language=python unknown.file
# List supported languages
batless --list-languages
Create custom profiles in ~/.batless/profiles/:
# ~/.batless/profiles/my-profile.toml
name = "my-profile"
max_lines = 1000
summary_level = "medium"
include_tokens = true
Use with:
batless --custom-profile ~/.batless/profiles/my-profile.toml file.rs
batless includes built-in shell completion support for bash, zsh, fish, and PowerShell.
# Generate and install completions
batless --generate-completions bash > ~/.local/share/bash-completion/completions/batless
# Or for system-wide installation
sudo batless --generate-completions bash > /usr/share/bash-completion/completions/batless
# Then reload your shell or source the completion file
source ~/.local/share/bash-completion/completions/batless
# Generate and install completions
batless --generate-completions zsh > ~/.zsh/completions/_batless
# Add to your ~/.zshrc (if not already present)
fpath=(~/.zsh/completions $fpath)
autoload -Uz compinit && compinit
# Then reload your shell
exec zsh
# Generate and install completions
batless --generate-completions fish > ~/.config/fish/completions/batless.fish
# Completions are automatically loaded in new fish shells
# Generate and add to your profile
batless --generate-completions powershell | Out-String | Invoke-Expression
# Or save to your profile for persistence
batless --generate-completions powershell >> $PROFILE
--mode <MODE> - Output mode: plain, highlight, json, summary--plain - Plain text output (equivalent to --mode=plain)--mode=json - Structured JSON output for automation--mode=summary - Extract only key code structures--max-lines <N> - Limit output to N lines--max-bytes <N> - Limit output to N bytes--lines <START:END> - Select specific line range (e.g., 10:50, :100, 50:)-n, --number - Show line numbers (cat -n compatibility)-b, --number-nonblank - Number non-blank lines only (cat -b compatibility)--theme <THEME> - Color scheme to use--language <LANG> - Force specific language syntax--include-tokens - Include token analysis in JSON output--summary - Add code summary to JSON output--profile <PROFILE> - Use AI-optimized profile (claude, copilot, chatgpt)--custom-profile <PATH> - Load custom profile from file--configure - Launch interactive configuration wizard--list-profiles - Show all available custom profiles--list-themes - Show all available color themes--list-languages - Show all supported languages--version - Show version information--version-json - Machine-readable version metadata--help - Show detailed help informationbatless is designed to work seamlessly with AI coding assistants:
# Use batless in Claude Code workflows
batless --profile=claude --max-lines=500 src/main.rs
# Generate context for Copilot
batless --mode=json --summary src/ | gh copilot suggest
# Generate structured context
batless --mode=json --include-tokens --max-lines=1000 file.rs > context.json
See docs/AI_INTEGRATION.md for detailed integration guides.
batless is built with:
See docs/ARCHITECTURE.md for technical details.
We welcome contributions! Please see:
# Clone repository
git clone https://github.com/docdyhr/batless.git
cd batless
# Build
cargo build
# Run tests
cargo test
# Run with example
cargo run -- src/main.rs
Note: Performance varies by hardware. Benchmarks on typical developer workstation.
MIT License - see LICENSE for details.
Built with ❤️ for automation, AI assistants, and modern CLI workflows