Using tmux as a Screencasting Tool

Author: 

Shawn Webb

I've been hearing a few of the folks I associate with praising tmux. For years, I used GNU's screen. I thought I'd give tmux a try. I've since fallen in love with it. I learned that tmux has a read-only option. I figured that using tmux's read-only option, I could create a useful tool for screencasting a command-line interface. This article will show you how to easily set up your box with tmux to screencast the commandline.

Requirements

  • bash
  • tmux
  • sshd

Setting up the System
You will need to download my helper shell script. You can find it here. Place it in /usr/local/bin, /usr/bin, or another place of your liking. Create a new user and set its shell to the path of the script (for example, adduser -m -s /usr/local/bin/tmux-ro.sh caster). In this article, we'll use caster as the username of our sample user. We'll set the password to be the same as its username.

Starting the Screencast
My helper script allows for multiple screencasts, using the name of the tmux session as the name of the screencast. In this article, we'll use testcast as the name of the screencast. Start the screencast by creating a new session of name testcast as the user you just set up: sudo -u caster tmux new -s testcast.

Sharing the Screencast
Now that the user has been created, its shell set to the helper script, and a screencast started, your viewers can now connect. Connect to your box using ssh as the caster user. You will be presented with a prompt asking for the session name. Enter testcast as the session name. You should now be able to view the screencast!

Recording the Screencast
tmux can also record your screencast. First make the directory ~/tmux/logs. Then, In each pane you wish to record, you can execute the tmux command to record it: pipe-pane -o 'cat >> ~/tmux/logs/`date +%F_%T`.#S-#I-#P.log'. You're now recording your screencast!

Conclusion
Screencasting with tmux is really easy. You now have a fully-functional command-line screencasting setup.

Tags: