Although you can use traditional screen recording software to capture your screen, there are better solutions. I’m introducing Asciinema, a tool specifically made to record terminal sessions. What makes this tool better, you ask? In this blog post, we will discuss that very thing, from features to how to install, record, and playback the recordings, and more.
Features
Below is a list of some of the most important features.
- smaller files than traditional screen recording software
- copy and paste from recordings
- Is Open Source
- Cross-platform Support
- Customization during Playback
- Embedding and Sharing
How To Install
There are two main ways to install Asciinema one is to search your systems package manager for Asciinema and the other is to install the Python package directly.
Apt-based distros such as Debian or Ubuntu:
apt install asciinema
DNF-based distributions such as AlmaLinux, CentOS, Fedora, RHEL, and more:
dnf install asciinema
For Arch Linux and Arch-based Distros:
pacman -S asciinema
Installing The Python Package Directly
If your distro doesn’t have a direct package for asciinema, you can use a Python package manager like pip or pipx to install the package.
Using pip:
python3 -m pip install asciinema
Using pipx:
pipx install asciinema
Recording
To start recording a terminal session you first need to decide if you want to record the file locally or upload it to asciinema.org.
To record locally make sure to specially a filename
asciinema rec filename.cast
If you don’t have anything personal you plan to record and are fine uploading it publicly you don’t have to specify the filename.
Playback
Playback can be customized, but before we look at the options let’s look at basic playback.
asciinema play [filename or URL of cast file]
This will play the recording as it was recorded (if the recording was 5min so is playback).
Below are the most common options you will want on playback
-i, –idle-time-limit limit idle time during playback to a given number of seconds
-s, –speed set playback speed (can be fractional)
-l, –loop loops the playback over and over again
Bonus: Recording All Your SSH Sessions
Do you need to record all your ssh sessions? The function below catches any commands starting with SSH then runs them through asciinema and records them to a folder called asciinema in your home directory.
function ssh {
ssh=$(whereis -b ssh | cut -d' ' -f2)
SESSION_NAME="ssh-$(date +%Y%m%d-%H%M%S)"
# Create asciinema recording (for users not using sshrc)
asciinema rec -y "$HOME/asciinema/$SESSION_NAME.cast" --command "$ssh $@"
}
Conclusion
Asciinema is a tool designed specifically recording terminal sessions, in this blog post we touched on features compared to traditional screen recording software. Then moved one to how to install, record, and playback the recordings. As I only touched the surface if you looking for other features or more intonation please check out asciinema docs site as it goes into much more detail than we can in a single blog post.
Embracing a lifelong passion for technology since childhood, CJ delved into the intricate workings of systems, captivated by the desire to understand the unknown. This innate curiosity led to his discovery of Linux, a revelation that resonated deeply. With more than 7 years of on the job experience, he’s honed his technical skills as a Geek and Senior Linux Systems Administrator.
Leave a Reply