Asciinema Notes
Asciinema is an awesome tool for recording your console sessions. It’s great for documenting processes and, in general, showing people how shit works: one look is worth a thousand words, as they say. Unfortunately, I don’t use asciinema
often enough to remember the syntax and so here we are.
I strongly believe that new things are rarely good but are always annoying. In time you will come to the same conclusion. I am still clinging to CentOS/RHEL 6 and, unfortunately, the features of asciinema
I find most valuable are only available in version 2+, which requires Python 3. And so I had to jump through a few hoops to install it without screwing up the OS (just remember – yum
uses Python and it’s kind’a important).
The “basic” steps are: update system, install the latest version of Python and PIP, install Asciinema:
# Upgrading your system is highly recommended but may not be required yum update # Uninstall current version of asciinema, if any yum -y erase asciinema # Install development tools yum groupinstall -y development # Install some additional tools yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel xz-libs wget curl # Get the latest version of Python v="$(curl -s0 -k -q https://www.python.org/ftp/python/ | grep -oP "(?<=\>)([0-9]{1}(.)?){1,}(?=\/\<)" | sort -V | tail -1)" wget -q --no-check-certificate http://www.python.org/ftp/python/${v}/Python-${v}.tar.xz # Uncompress cd /var/tmp/ && xz -d Python-${v}.tar.xz tar -xvf Python-${v}.tar cd Python-${v} # Install. And this will take a while... ./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" make make altinstall # Link python3 to the latest 3.x version /bin/mv -f /usr/bin/python3 /usr/bin/python3_old 2>/dev/null /bin/mv -f /usr/local/bin/python3 /usr/local/bin/python3_old 2>/dev/null ln -sf $(which python${v:0:3}) /usr/local/bin/python3 ln -sf $(which python${v:0:3}) /usr/bin/python3 # Install setuptools and pip wget https://bootstrap.pypa.io/ez_setup.py -O - | python3 python3 -m easy_install pip # Install Asciinema cd ~ && git clone https://github.com/asciinema/asciinema.git cd asciinema python3 ./setup.py install asciinema --version
This is the price one pays for being set in one’s ways. Let’s get to asciinema
now. When you record a video, you have an option of storing it locally (self-hosted option) or uploading it to the asciinema.org
server. The latter is easier.
The first step is to create your account. Just head over to asciinema.org
and create an account. Next, run asciinema auth
. You will be give a url. Go there, log in with the account you just created. Then check email and click on the verification link. Fairly thorough and secure process.
Now, let’s make a test recording. The following command will start the recording session and, when you’re done and hit CTRL-D, it will upload the fruits of your labor to asciinema.org
server.
asciinema rec --stdin --overwrite -t "$(hostname | awk -F. '{print $1}')_$(date +'%Y-%m-%d_%H%M%S')" -i 3 -y -q
Now head over to asciinema.org
, log in, and your recordings should be there. You can click on “Share” and select “Embed the Player” code and paste it in your blog. And here it is.
Some additional URL parameters allow you to control appearance and playback. For example, here’s an image link to the same video as above, but using the solarized-dark theme and playing 2.5 times faster.
<a href="https://asciinema.org/a/hMzJDeQnRokgQeWvOXDR4ZXEB" target="_blank" rel="noopener"><img src="https://asciinema.org/a/hMzJDeQnRokgQeWvOXDR4ZXEB.svg?speed=2.5&theme=solarized-dark"></a>