One of the most boring and annoying parts of writing blogposts is adding images. Most of mine are screenshots, usually from the terminal.

So lately I created a small script and an AI skill to handle this for me. Now I just write the post in markdown, add image placeholders describing what I want, and ask my agent to go through them. It reads the descriptions (or uses a custom prompt I provide) and takes care of the rest.

This has saved me minutes, sometimes even hours, per technical blogpost, along with the hassle of resizing terminals and cropping screenshots 😁.

A skill for screenshots

The skill is called screenshotting-terminal-panes. It covers running the command, capturing the output, and checking the resulting image, so I don’t have to explain the process every time.

The workflow is very simple:

  1. Run the command in a detached tmux session.
  2. Capture the pane with its ANSI colors.
  3. Use freeze to turn the capture into an SVG with a terminal frame.
  4. Convert it to PNG or WebP using librsvg and cwebp.

Everything runs without a desktop or a browser. The agent can also capture an existing pane instead of launching a new command.

Still just a script

The script can be used directly too. From the skill directory:

scripts/termshot.sh -o money.webp -W 140 -H 40 -- money

And this way, one painful, boring task automated. Until next time with another task to automate.