New feature today: hackfetch can turn itself into a shareable image.
The goal was simple: your terminal fetch should be more than a terminal thing. If it looks cool on your screen, you should be able to post it in a Slack channel or drop it in a devlog without ever having to take a screenshot.
hackfetch -export card.svg
Run that and instead of printing to your terminal, hackfetch writes an SVG file that looks exactly like the fetch on your screen: logo on the left, stats on the right, rounded corners, monospace font, every color preserved.
Getting the general SVG output was the easy part. Draw a rectangle, put text inside it, done.
The hard part was preserving the colors.
Terminals speak ANSI 256-color codes. SVGs speak hex color strings. They don’t line up one-to-one, so a naive export just drops every color and produces a black-and-white version of the fetch. Not very shareable.
The fix: a lookup table from ANSI 256-color codes to hex values, plus a rendering path that emits every styled character as its own SVG element with the correct fill color.
That’s actually a lot of tspans. Schemes like per-char, where every single glyph has its own gradient stop, can produce hundreds of colored elements per fetch. But it works. The SVG renders smoothly in any browser and looks identical to what shows up in your terminal.
Use It Anywhere
Some things you can do with the exported card:
- open it in a browser to see it
- drop it into a Slack channel or a devlog
- convert it to PNG with rsvg-convert if you need a raster image
hackfetch -export card.svg trans
Open it.
Post it.
Ship it.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.