Recording & Sharing Terminal Sessions

This post describes how to make high quality recordings of terminal sessions that can be replayed in the terminal, or shared on the web. I'm defining high quality as recordings with zero typos, and relatively controlled timing between commands. Jump to the end to see an example of the type of output I'm talking about. Why? Videos and gifs take up a lot of disk space, don't age well as display technology improves, and are problematic for folks low vision requirements.