My colleague Tobru recently pointed me to demo-magic, and I now seriously wonder how could I ever do a live demo without this. The description of the project says it all:
A handy shell script that enables you to write repeatable demos in a bash environment.
The idea is as simple as this: instead of having to type commands while doing demos or recording videos, just create a script that will:
- Write the command for you on the screen;
- Wait for you to press
- Execute the command live for you.
And not only that, but it’s written in 100% shell script: just save the file locally, and make sure you have pv installed (
sudo apt install pv should do the trick on Debian, Ubuntu and similar.)
Then write a script as follows:
#!/usr/bin/env bash # Include the magic . demo-magic.sh # Clear the screen before starting clear # Print and execute a simple command pe "echo 'hello world'" # Wait until the user presses enter wait # Print and execute immediately pei "bat my-demo.sh"
Save the script as a file named
my-demo.sh (well, any name, really) and just
bash my-demo.sh to get started. Press
<ENTER> to print the command, and press it again to execute it. As simple as possible, and very useful when demoing stuff on a terminal.
But you can do much more with
- Personalize the prompt;
- Simulate network connections even if offline (whaaat);
- Run hidden commands, not shown to the public;
- Add timeouts to the
- Get help on your
my-demo.shscript using the
- Type your own commands, if needed, using the
Simply put, this is a godsend for all the DevRel people reading this. Couple it with asciinema1 and you’re in for a treat.
Update, 2022–11-26: The movie in this page is embedded using the cljoly/gohugo-asciinema Hugo module created by Clément Joly.
asciinema is another gem worthy of its own blog post, because srsly. It’s so awesome I don’t know where to start. ↩︎