Record and share your Linux terminal wizardry with two simple tools
The Linux terminal feels secretive. Intensely private. Like the stuff you keep at the back of the closet or underneath your socks. The stuff you hope no snooping visitor will come across.
But if you’re the kind of person who likes to write about their weird Linux terminal customizations, you might someday find yourself wanting to record and share the input/output of your Linux terminal. It turns out that Linux terminal recordings ar
Why would you want (or need) to record your Linux terminal activity?
I can think of plenty of reasons:
Get THE BEST DEALS IN CLOUD HOSTING from Los Angeles!Grab a huge 32GB RAM & 320GB of SSD storage for just $109/year!
- You want to show off your cool one-liners.
- You’re creating Linux/development-focused blog content and you want to show readers exactly how a certain command will run.
- You want to document and share information with co-workers.
- You want to record your personal procedures for posterity without typing everything out into a
- You’re having an issue on your Linux terminal and figure the Stack Overflow folks might understand your weird question better if you give them the full picture.
- Because GIFs (and animated SVGs) are just plain fun!
Using asciinema to create gif recordings of your Linux terminal
Once installed, you can initiate a recording with
asciinema rec recording.json. When you’re done, either type in
Ctrl + D or type in
exit and hit
Enter. You can then play the recording back using
asciinema play recording.cast.
Once you’ve confirmed it looks the way you want, you can upload it to asciinema.org by issuing
asciinema upload recording.cast. You have to authenticate yourself if you’d like your recording to stick around, but that process is super easy. The script and the website will walk you through it.
Here’s me trying one of the many cool one-liners from our One-line Wise tool!
Now that you know how to make, upload, and share recordings, let’s throw some SVG into the mix.
Converting your Linux terminal recordings to animated gifs
We’re now moving onto
svg-term-cli (GitHub), which is a simple script for converting
asciinema-made recordings into fully-animated SVGs. Install it with
npm install -g svg-term-cli.
You have two options. You can either convert a
.cast file you uploaded to asciinema.org, or you can pipe a
.cast file directly into
svg-term-cli. First, let’s convert from asciinema.org:
$ svg-term --cast=237456 --out examples/manrandom.svg
Or, converting from a
pipes.cast file I have on my comupter:
$ cat pipes.cast | svg-term --out pipes.svg
Why go SVG?
- SVGs can sometimes go where GIFs can’t.
- Animated SVGs tend to have smaller file sizes than GIFs.
- You can zoom into SVGs and get perfect vector quality.
- You can also make your SVG recordings as large as you’d like without quality loss (or bigger file sizes).
- SVGs play friendly with Markdown formatting.
- SVGs are just dang cool.
Why not go SVG?
Now that you know how to record your terminal in both GIF and SVG, it’s time to get sharing! It’s awesome to see what people are up to. I mean, just checkout this raytracing animation:
Have other uses for
svg-term-cli? Send me and email at mailto:[email protected] and I’ll add them to the post.