zsnap
is a command‑line tool that captures the ANSI output of any shell command and renders it as an image. This is useful for embedding colorful terminal output into documentation, slides, or bug reports.
- Capture stdout (and optionally stderr) from any command
- Preserve ANSI colors and formatting
- Output to common image formats: PNG, JPG, JPEG, BMP
- Configurable image width
- Cross‑platform: supports both Unix shells and Windows
cmd.exe
- Rust toolchain (stable)
- On Linux/macOS: development headers for GTK/X11 if using system clipboards
- On Windows: no additional dependencies
cargo install zsnap
git clone https://github.com/yourusername/zsnap.git
cd zsnap
cargo build --release
cargo install --path .
zsnap --exec "ls --color=always" --out report.png
Usage: zsnap [OPTIONS]
Options:
--exec Command to run and capture (with ANSI color codes)
-o, --out Output file path (png│jpg│jpeg│bmp) [optional]
-w, --width Width of the generated image in pixels [default: 800]
-f, --format Image format (png│jpg│jpeg│bmp) [default: "png"]
--errors Include stderr output after stdout
-h, --help Print help information
-V, --version Print version information
## Examples
- Capture 'ls' and save as PNG:
```bash
zsnap --exec "ls --color=always" --out ls.png
- Capture
git diff
with stderr included:
zsnap -e --exec "git diff HEAD~1 HEAD"
- Use custom width and JPEG format:
zsnap -w 1200 -f jpg --exec "top -b -n 1"
- Unix (Linux, macOS): uses $SHELL (or falls back to /bin/sh)
- Windows: uses %COMSPEC% (defaults to cmd.exe)
This project is licensed under the MIT License. See LICENSE for details.