Sometimes you need to record videos or demos that involves the terminal. Typing the commands is difficult, as you may miss-type or forget a specific command.

Today, I wanted to record a small demo for the Wasm Workers Server project. Instead of typing the commands, I tried to write a simple script to print and run them. However, the result was messy.

Fortunately, I found demo-magic, a bash script to emulate typing and prepare neat terminal demos. It comes with multiple helper methods. For exampl:

  • p: emulate typing a command
  • pe: emulate typing a command, wait you to press "Enter" and run the command
  • pei: emulate typing a command and run the command
  • wait: wait until you press "Enter"
  • cmd: give control back to you to type and run commands manually

The demo look and feel can be customized. You can configure the prompt (DEMO_PROMPT) and the waiting timeout (WAIT_TIMEOUT). You can find a sample script in the repository.

The result was pretty neat! The tool is simple, although I needed some practice with the different methods and the waiting periods 📹.feat