The Portable Solution
script! For example:
> script -f /tmp/lecture1.scrpt #use -F instead on MacOS
> ... #start doing things here!
> #after this, terminal will continuously print whatever's written to personal terminal
> tail -F /tmp/lecture1.scrpt
How It Works
script command copies everything written to the terminal screen (including what you type!) into a file it takes as a parameter. Ordinarily everything gets written to the file after you end the script (by typing
exit). However, the
-f option causes
script to flush its buffer after every write (on MacOS, this will be
-t 0). Then, in the presentation terminal, you can use
tail -F to see the contents continuously as they're written.
Things to Note
Since one terminal is writing to a file and the other is reading, this can be done between different users! This means you can have someone ssh in with very few permissions and as long as you place the script file in a location they can read, you'll still be able to present to them. (ie: if you have a server your students have access to, you could create a .scrpt file that'd be only readable for them so they could follow along on their own screens)
Given the nature of this method, one terminal is driving and the other is only watching.
This method also has the added bonus of making it easy for you to stop mirroring, do some secret work and begin mirorring again all without leaving your personal terminal. This can be done with the following:
> exit #end script session; stop writing to /tmp/lecture1.scrpt
> ... #do secret things not safe for student eyes!
> script -f -a /tmp/lecture1.scrpt #begin writing again with -a to append
More Fun With
The purpose of
script is to record your terminal session so it can be played back later (we just happen to be the special case of playing back as it's recording). To help with this,
script has the
-t option to record timing along with what's written to the screen. To use it, start your script session with:
> script -f -t 2>/tmp/lecture1.timing /tmp/lecture1.scrpt
And play it back (with timing!) with:
> scriptreplay -t /tmp/lecture1.timing -s /tmp/lecture1.scrpt
Have a student that emailed you saying he'd be sick and can't make lecture? Or just want to give your students more lecture material? If you record your voice during the lecture (and start script at about the same time as the recording), then your students could play back your terminal session with your voice and get the full lecture experience!
Have a student who likes to play all of his videos at 2x speed?
scriptreplay takes a "divisor" that it multiplies the play speed by! Just pass
-d 2 to play at 2x speed (note this is a double value, so you could even do
-d .5 for half speed!).