Speaker notes with tslide
tslide is great. It’s a minimal presentation program that adheres nicely to the unix philosophy of doing one thing well.
It uses a single markdown file as its source. It uses
--- dividers to delimit
slides. Usage is as easy as
$ cat > talk.md ## hello world let's talk about the question that's on everybody's mind --- ## yet another slide what's the deal with marsupials ^D $ tslide talk.md (magic)
This’ll show the same markdown as above, but per-slide, with the ability to use the arrow keys or j/k to move through them.
But what if you’re like me and have notes? cues for yourself per-slide to help jog your memory?
Ideally these notes you’ll want to see on your laptop screen but not appear on the big screen.
do one thing well
I wrote an elaborate PR to do this. It was a bit complicated, and involved starting an HTTP server on one tslide instance to help another instance connect, and only show speaker notes on one.
But the best programs are the ones that do one thing well.
How can we use !!THE POWER OF UNIX!! to avoid bloating an otherwise concise program?
pipes to the rescue
You’ll want two terminals: one for the speaker, and one for the presenter.
In the speaker terminal, run
$ mkfifo present $ tslide my_talk.md | tee present
And in the presentation terminal (the one on the big screen) run
$ cat present
Let’s break this down step by step.
$ mkfifo present
The first command creates a fifo pipe, which one process can write to and it will buffer until another process asks for the data.
$ tslide my_talk.md | tee present
The second tells
tslide to start presenting to standard out, but also pipes
that output to
tee, a program that lets its input flow through back to
standard out, but also writes a copy of it to a file of your choosing. Here I
choose the fifo from before,
You’ll notice the command hangs here, waiting until I connect the other end to
present before running. this happens because fifos wait until a full pipeline
is present before letting the data flow.
Finally, in the second terminal I run
$ cat present
This tells the terminal to write the contents of
present to standard out,
effectively mirroring everything the presenter sees, including the ansi codes
that deal with clearing the screen and applying colors and formatting effects
But wait, I thought I wanted speaker notes to not appear for the presentation terminal?
One can do this with a slight modification to
$ cat present | grep -v "\s>"
This pipes each slide through the filtering program
grep. If you aren’t
already familiar with regular expressions, there’s a few components to this:
-vtells grep to omit the lines it matches
^matches the beginning of a line
\smatches the whitespace group of characters
\+matches at least one of the preceding character (whitespace, in this case)
>is the markdown blockquote character
This will match all lines that have some whitespace leading up to a blockquote, and omit those lines.
From here you could bundle these commands into handy little shell scripts:
FIFO=/tmp/present mkfifo $FIFO tslide $1 | tee $FIFO
FIFO=/tmp/present cat $FIFO | grep -v "\s>"
addendum: what about those weird symbols?
tslide is trying to move your cursor down to the bottom left corner of the
screen after writing the slide text. Since the viewing terminals are no longer
running as interactive (we’re using them through pipes)
tslide is failing to
get the window height (thus
NaN) but still writing it. This is fixed as of