[ | Date | | | 2021-01-30 00:03 -0500 | ] |
[ | Current movie | | | Tron | ] |
From time to time, I wish I could take and use terminal screenshots, but traditional, bitmap screenshots have limitations:
they risk looking instantly dated1, as they capture the exact font, resolution, and rendering engine used at capture time;
they cannot be edited or pasted from as text.
On the contrary, vector-format (SVG) screenshots will display with as high a resolution as the reader's system can manage, making them adequate for screen display as well as for print. They would, conversely, be less adequate if capturing the whole current-day rendering is part of the goal.
Program termtosvg seems to fit the bill: it runs terminal sessions, and saves regular snapshots as SVG, either as separate stills, or as a single SVG + JavaScript animation.
As for 2020-06, the GitHub project is marked as unmaintained by its owner, but installs easily on e.g. Debian or Ubuntu from pip:
pip3 install termtosvg
I like to set some parameters to:
capture individual stills rather than an animation (--still-frames
);
set a specific terminal size (--screen-geometry 80x24
);
run a specific command to capture (here, htop
, using --command
);
use the current directory as an output location (.
).
termtosvg --still-frames --screen-geometry 80x24 --command 'htop' .
Capturing stops when the command exits (by hitting "q" in the case of htop
, or, if letting termtosvg start its own shell, which is the default, by quitting that shell). Then just pick the images that are wanted.
Inline in the present document:
htop
Converting from Markdown to PDF is straightforward using Pandoc. This requires a LaTeX install capable of emitting PDF, as well as the rsvg-convert tool (from package librsvg2-bin
on Ubuntu 20, or librsvg2
from Homebrew). When both dependencies are installed, any SVG pictures will be converted to PDF on the fly.
Mutt: spam
Such screenshots are good for presentation purposes: light edits are easy using a text editor2;
they are not so great for text that is meant to be copied by the reader (for example, at the moment, Firefox doesn't allow selecting or copying text directly from the embedded picture): it is probably best to keep using code snippets for that.
Quick links: