ttysvg
Guides

Making it repeatable

Describe a demo as a small script so you can regenerate it any time.

Recording by hand is fine once. The problem comes later, when your output changes and every demo in the repo is out of date.

A tape fixes that. It is a small script describing the demo, so you can regenerate the recording with one command.

ttysvg build demo.tape

A complete tape

output "demo.svg"           # where to write the result
theme  "tokyonight"         # built in theme name, or a path to your own
width  80                   # recording size in characters, not pixels
height 20
window on                   # draw a title bar with traffic lights
title  "demo"

shell "powershell.exe" "-NoLogo" "-NoProfile"

type-delay 55ms             # pause between keystrokes, so typing looks human
trim-idle  700ms            # cut any dead air longer than this
tail       2s               # hold the last frame this long before looping

wait  "PS " 20s             # block until the prompt appears, up to 20 seconds
type  "cargo build"         # type it out, one character at a time
sleep 400ms
enter
wait  "Finished" 60s        # block until the build actually finishes
sleep 1s

Every directive is listed in the tape reference.

Why wait matters more than anything else

wait blocks until that text really appears on the screen. A fixed sleep guesses, and the guess is wrong the first time the machine is busy, which is how scripted demos end up cut off halfway. wait cannot desynchronize.

wait "test result" 300s

A generous timeout is a safety net, not a delay. It returns the moment the text appears, so a fast machine is not punished for it.

A clean prompt

Someone else's shell theme does not belong in your demo. Start the shell with a prompt you control:

shell "powershell.exe" "-NoLogo" "-NoProfile" "-NoExit" "-Command" "function prompt { '$ ' }; Clear-Host"

The bash equivalent:

shell "bash" "--norc" "-i"

followed by type "export PS1='demo $ ' && clear".

Overriding a tape

Any flag given on the command line beats what the tape says, so rebuilding in a different theme costs nothing:

ttysvg build demo.tape --theme gruvbox --out demo-gruvbox.svg

A tape really runs its commands. Keep demos on read only commands or on a scratch repository.

On this page