A lightweight CLI tool to display file contents with encoding support and syntax highlighting - like cat but better.
- π¨ Syntax Highlighting: Automatic syntax highlighting for 219 languages
- π Multi-encoding Support: UTF-8, GBK, Big5, Shift-JIS, and more
- π Smart Detection: Auto-detects file type and encoding
- π Multiple Themes: 7 built-in color themes
- π Line Numbers: Optional line number display
- π Lightweight & Fast: Only 2.1 MB binary size with streaming architecture
- β‘ High Performance: Instant output for large files with line-by-line processing
- π§ Debug Mode: Detailed encoding detection information
- π Stdin Support: Read from pipes and redirects with language specification
- π― Manual Language Selection: Override auto-detection with
-l/--languageflag
curl -fsSL https://raw.githubusercontent.com/superyngo/cate/main/install.sh | bashirm https://raw.githubusercontent.com/superyngo/cate/main/install.ps1 | iexThe installation script will:
- Automatically detect your platform and architecture
- Download the latest release from GitHub
- Install the binary to the appropriate location
- Add it to your PATH automatically
Download the appropriate binary for your platform from the releases page.
# Extract the tarball
tar xzf cate-*.tar.gz
# Move to PATH (optional)
sudo mv cate /usr/local/bin/
# Make executable (if needed)
chmod +x /usr/local/bin/cateSimply download cate-windows-x86_64.exe and rename it to cate.exe. Add it to your PATH for easy access.
# Clone the repository
git clone https://github.com/superyngo/cate.git
cd cate
# Build with cargo
cargo build --release
# Binary will be in target/release/cate (or cate.exe on Windows)If you installed using the installation scripts, you can uninstall with:
curl -fsSL https://raw.githubusercontent.com/superyngo/cate/main/install.sh | bash -s uninstallirm https://raw.githubusercontent.com/superyngo/cate/main/install.ps1 | iex -UninstallFor manual installations, simply remove the binary from your system.
# Display file with syntax highlighting (default)
cate file.rs
# Display multiple files
cate file1.rs file2.py file3.js
# Show line numbers with highlighting
cate file.rs -n
# Specify encoding
cate file.txt -e gbk
# Use different theme
cate file.py --theme "Solarized (dark)"
# Disable syntax highlighting
cate file.txt --no-highlight
# Read from stdin with language specification
cat script.sh | cate -l bash
echo 'fn main() { println!("Hello"); }' | cate -l rust
# Override file extension detection
cate -l python file.txt
# List available themes
cate --list-themes
# List supported languages
cate --list-syntaxes
# List supported encodings
cate --list-encodings
# Debug mode (show encoding detection info)
cate file.txt --debug-h, --help Show help message
-v, --version Show version information
-e, --encoding <ENC> Specify encoding (utf-8, gbk, big5, shift-jis, etc.)
-n, --number Show line numbers
--debug Enable debug mode
--list-encodings List all supported encodings
Syntax Highlighting:
--no-highlight Disable syntax highlighting
--theme <THEME> Set color theme (default: base16-eighties.dark)
-l, --language <LANG> Specify syntax language (e.g., rust, python, js)
--list-themes List all available themes
--list-syntaxes List all supported languages
The tool uses the following priority for encoding detection:
- UTF-8/BOM: If file has BOM or is valid UTF-8
- User Specified: Encoding specified with
-eflag - System Encoding: Falls back to system default encoding
- UTF-8, UTF-16LE, UTF-16BE
- GBK (Simplified Chinese)
- Big5 (Traditional Chinese)
- Shift-JIS
- Windows-1252, ISO-8859-1
Any encoding supported by the encoding_rs crate (e.g., EUC-JP, ISO-8859-2, KOI8-R, etc.)
Syntax highlighting is supported for 219 languages including:
- Rust, Python, JavaScript, TypeScript
- Go, C, C++, Java, C#
- Bash, PowerShell, Batch File
- Makefile, Dockerfile
- JSON, YAML, TOML, XML
- HTML, CSS, Markdown
- base16-eighties.dark (default)
- Solarized (dark/light)
- InspiredGitHub
- base16-ocean.dark
- base16-mocha.dark
- And more...
# Display Rust file with syntax highlighting
cate src/main.rs
# Use a different theme
cate app.py --theme "Solarized (dark)"
# Show line numbers with highlighting
cate config.toml -n
# Display multiple source files
cate src/*.rs# Display GBK-encoded file
cate chinese_file.txt -e gbk
# Show Big5 file with line numbers
cate traditional_chinese.txt -e big5 -n
# Combine encoding and highlighting
cate source_code.py -e gbk -n# Debug encoding detection
cate mystery_file.txt --debug
# Use with pipes and specify language
cat unknown_script | cate -l python
echo 'fn main() { println!("Test"); }' | cate -l rust
# Language specification (case-insensitive, supports extensions)
cat script | cate -l Rust # Works with any case
cat script | cate -l rs # Works with file extension
cat script | cate -l js # JavaScript by extension
# Override file extension detection
cate config.txt -l yaml # Treat .txt as YAML
# Convert encoding and display with highlighting
iconv -f gbk -t utf-8 input.py | cate -l python
# Disable highlighting for plain text
cate log.txt --no-highlightcargo buildcargo build --releaseThe release build is heavily optimized for size using:
- LTO (Link-Time Optimization)
- Size optimization (
opt-level = "z") - Symbol stripping
- Single codegen unit
# Run all tests
cargo test
# Run with output
cargo test -- --nocapturecate uses a streaming architecture inspired by bat for optimal performance:
- β‘ Line-by-line processing: Files are processed and output incrementally
- π Instant output: First lines appear immediately, even for large files
- πΎ Low memory usage: Only buffers single lines, not entire files
- π― Stateful highlighting: Correctly handles multi-line syntax (comments, strings, etc.)
- π‘οΈ Long line protection: Automatically skips highlighting for lines >16KB
# 10,000 line file processes in ~0.3 seconds with instant first-line output
cate large_file.rs
# Use --no-highlight to disable syntax highlighting for faster plain text output
cate large_file.txt --no-highlightThe name "cate" combines "cat" (the Unix command) with "encoding", making it easy to remember and type.
- β Syntax highlighting for 219 programming languages
- β 7 beautiful themes with true color support
- β Streaming architecture for instant output on large files
- β Automatic encoding detection and conversion
- β Support for non-UTF-8 files (GBK, Big5, Shift-JIS, etc.)
- β
Manual language selection with
-lflag - β Debug mode for troubleshooting encoding issues
- β Built-in line numbering
- β Only 2.1 MB binary size
MIT License - see LICENSE file for details
This project uses syntax definitions from the bat project, which are licensed under MIT License / Apache License 2.0. The syntax definitions are originally derived from Sublime Text packages (MIT License).
For complete third-party license information, see THIRD-PARTY-LICENSES.md.
- bat project - For the excellent syntax definition collection
- Sublime Text community - For maintaining the original syntax definitions
- syntect - For the syntax highlighting engine
wen
Contributions are welcome! Please feel free to submit issues or pull requests.