Introduction
I recently became aware of Asciinema when I saw that the Aspire docs are using it to document installing their CLI. As someone who creates a lot of content (or used to, anyway) and docs, this seems like a really useful tool! But it doesn’t “just work” on Windows, so I figured I’d document how to get it working on Windows for future me.
Asciinema Itself
There are basically two parts to Asciinema:
- Recorder (a CLI) that captures terminal sessions and saves them to
.castfiles - Player (JS library) that renders
.castfiles on a web page.
You can self-host the JS and .cast files as just static assets.
Unfortunately, the CLI doesn’t support Windows. Which is where other tools come in. These other tools handle recording terminal data into the proper .cast file format, so that you can still use the Asciinema JavaScript player to render them.
PowerSession
There are two ports of the terminal session recorder, a Rust-based one called PowerSession (-rs) and a C# version called just PowerSession, both by the same maintainer. The Rust one is more actively maintained so it’s the one I chose to use.
Installing
To install the PowerSession recorder, just run this:
|
|
You should get something like this (note this would be animated if I already had a recorder but alas):
|
|
Now, to host the files you have options. You can upload and host them on asciinema.org or self-host. I prefer self-host so all of my content stays in one repo.
To host the recordings yourself, you just need this code:
|
|
You can get the player via npm or as a JavaScript bundle via GitHub release.
Testing It Out
So now that we have PowerSession installed and the asciinema player hosted with my site, let’s test it out. Here’s a quick example showing off my ardalis CLI tool:
Resources
- Asciinema - Terminal session recorder and player
- Aspire CLI Installation Docs - Example of Asciinema in action
- PowerSession-rs (Rust) - Windows terminal recorder (recommended)
- PowerSession (C#) - Alternative Windows terminal recorder
- Asciinema Windows Support Issue - Discussion on CLI Windows support
- Asciinema Self-Hosting Docs - Hosting options
- asciinema-player npm package - Player via npm
- asciinema-player GitHub Releases - JavaScript bundle download
Did you find this helpful? Let me know on BlueSky or subscribe to my newsletter for more content like this!