Skip to content

ansilithic/cli2png

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cli2png

Swift 6.0 macOS 14+ License: MIT

Convert ANSI terminal output into a styled terminal screenshot. Produces PNG or SVG with proper colors, bold/dim styling, and optional macOS window chrome.

cli2png

How it works

Pipe any command's output through cli2png. It parses ANSI escape sequences (SGR codes for 24-bit RGB, bold, dim), renders the text with a monospace font, and outputs a screenshot with optional window decoration (title bar with traffic lights). Supports both rasterized PNG (retina-ready at 2x by default) and vector SVG output.

Install

Build from source (requires Xcode and macOS 14+):

make build && make install

Usage

USAGE: cli2png [--output <file>] [--width <cols>] [--height <rows>]
               [--prompt <text>] [--font-size <px>] [--no-chrome]
               [--padding <px>] [--format <fmt>] [--scale <n>]

OPTIONS:
  -o, --output <file>     Output file (default: stdout, format from extension)
  --width <cols>          Override column width (default: auto)
  --height <rows>         Minimum row count (default: auto)
  -p, --prompt <text>     Add a styled $ prompt line above the output
  --font-size <px>        Font size in pixels (default: 12)
  --no-chrome             Skip window chrome, render content only
  --padding <px>          Content padding (default: 6)
  --format <fmt>          Output format: png, svg (default: inferred)
  --scale <n>             Pixel scale for PNG (default: 2)
  -h, --help              Show help information

Examples

# Capture command output as PNG
ls --color=always | cli2png -o listing.png

# SVG output with a prompt
git status | cli2png -p "git status" -o status.svg

# Larger font, no window chrome
cat file.txt | cli2png --font-size 14 --no-chrome -o output.png

# Pipe to stdout
echo "hello" | cli2png > screenshot.png

License

MIT

About

Convert ANSI terminal output to styled PNG screenshots with macOS window chrome.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors