Scripting asciinema
The asciinema
program captures shell interactions in a form that can be replayed, or turned into an animated gif file. It’s an extremely convenient way to demonstrate command-line operations and utilities. But used directly it has one basic weakness: the need to type in the commands.
After starting to use asciinema
this week, the annoyance of typing in the commands became immediately unbearable. My solution is called asciinema-script
. This program records an interaction that is itself scripted. For example, here is a simple script:
t bin/asciinema-script
s 1
t bin/asciinema-script help
Using asciinema-script
to produce a gif from this script yields the following:
Another post uses this script:
t bin/pipeline
s 1
t bin/scrip help bin/pipeline
s 1
t bin/pipeline :: echo a :: sh -c 'echo b && cat -'
s 1
t bin/pipeline :: echo a :: xargs echo b :: xargs echo c
It’s now almost trivial for me to create a reproducible demo.