How To Record and Share Terminal Sessions Using Terminalizer on Ubuntu 18.04

The author selected the Electronic Frontier Foundation to receive a donation as part of the Write for DOnations program.

Introduction

Terminalizer is a terminal recorder application that allows you to record your terminal session in real-time, and then play it back at a later date. It works in the same way as a desktop screen recorder, but instead runs in your terminal.

Recording your terminal session is useful if you want to review a particular activity again, or to help debug a particularly tricky error. Recordings made with Terminalizer can also be exported as animated GIFs, which are great for sharing online or adding to marketing material for your software.

In this tutorial, you will install Terminalizer, use it to record and play back terminal sessions, customize your recordings, and then export them to share online.

Prerequisites

To complete this tutorial, you will need:

  • An Ubuntu 18.04 server set up by following the Initial Server Setup with Ubuntu 18.04, including a sudo non-root user.

  • Node.js and npm, which can be installed by following the Installing the Distro-Stable Version for Ubuntu section within How to Install Node.js on Ubuntu 18.04.

If you wish to share your recordings online, you’ll also need:

  • A free account on the Terminalizer website.

Once you have these ready, log in to your server as your non-root user to begin.

Step 1 — Installing Terminalizer

In this step, you will download and install Terminalizer on your system. Terminalizer is written using Node.js, and is available to install using the npm package manager.

To install Terminalizer globally on your system, run the following command:

  • sudo npm install --global --allow-root --unsafe-perm=true terminalizer

Terminalizer uses the Electron application framework to export recorded terminal sessions into GIF format. The --unsafe-perms=true command argument is required in order to install Electron globally on your system.

Once Terminalizer has been installed, you’ll see similar output to the following:

Output. . . /usr/local/lib └── [email protected] 

Next, check your installation of Terminalizer by running:

  • terminalizer --version

This will display something similar to the following:

Output0.7.1 

Finally, generate a default Terminalizer configuration file, which you can use for Terminalizer’s advanced customization (detailed further in Step 4):

  • terminalizer init

This will produce output similar to the following:

OutputThe global config directory is created at /home/user/.terminalizer 

Now that you’ve installed Terminalizer, you can make your first terminal recording.

Step 2 — Recording and Playing Back a Terminal Session

In this step, you will record and playback a terminal session.

To begin, set up a new Terminalizer recording using a name of your choice:

  • terminalizer record your-recording

This will output the following to indicate that the recording has started:

OutputThe recording session has started Press Ctrl+D to exit and save the recording 

You can now proceed to do anything that you want within your terminal. Each key press and command will be recorded in real-time by Terminalizer.

For example:

  • pwd
  • date
  • whoami
  • echo "Hello, world!"

When you’d like to stop the recording, press CTRL+D. Terminalizer will then save the recording to the specified file in YAML format, for example, your-recording.yml.

OutputSuccessfully Recorded The recording data is saved into the file: /home/user/your-recording.yml 

You may be prompted by Terminalizer to share your recording online. Just press CTRL+C to cancel this for now, as you can playback the terminal recording locally first.

Next, play your recorded terminal session with the followng command:

  • terminalizer play your-recording

This will replay the recorded session in real-time in your terminal:

[email protected]:~$ pwd /home/user [email protected]:~$ date Sun Mar  8 14:55:36 UTC 2020 [email protected]:~$ whoami user [email protected]:~$ echo "Hello, world!" Hello, world! [email protected]:~$ logout 

You can also adjust the playback speed of your recording using the --speed-factor option.

For example, the following will playback your recording twice as slowly (half speed):

  • terminalizer play your-recording --speed-factor 2

Alternatively, you can play back your recording twice as fast (double speed):

  • terminalizer play your-recording --speed-factor 0.5

You’ve recorded and played back a terminal session. Next, you can share a recorded terminal session online.

Step 3 — Sharing a Recorded Terminal Session

In this step, you’ll share your recorded terminal session online on the Terminalizer Explore page.

Begin by selecting a recorded session to share:

  • terminalizer share your-recording

You will then be prompted to provide some basic metadata about your recording, such as the title and description:

OutputPlease enter some details about your recording ? Title Title of Your Recording ? Description Description of Your Recording ? Tags such as git,bash,game Comma-separated Tags for Your Recording 

Warning: Terminalizer recordings are shared publicly by default, so ensure that there are no personally identifiable or confidential details present in your terminal recording that you don’t want to share.

If this is the first time that you’ve shared a recorded session using Terminalizer, you’ll need to link your Terminalizer account. Terminalizer will display a verification link if this is required:

OutputOpen the following link in your browser and login into your account https://terminalizer.com/token?token=your-token  When you do it, press any key to continue 

Warning: Ensure that you keep your Terminalizer token private, as it will allow anyone in possession of it to access your Terminalizer account.

Once you have visited the link in your web browser and signed in to your Terminalizer account, press any key to continue.

Terminalizer will now upload your recording and provide you the link to view it:

OutputSuccessfully Uploaded The recording is available on the link: https://terminalizer.com/view/your-recording-id 

Visiting the link in a desktop web browser will allow you to view your shared recording:

A screenshot of the Terminalizer website, showing an example of a shared terminal recording

You’ve shared a recorded terminal session on the Terminalizer website and viewed it in your web browser.

Step 4 — Setting Advanced Terminalizer Configuration

Now that you’ve gained some familiarity with Terminalizer, you can begin to review some of the more advanced customization options, such as the ability to adjust the display colors and style.

Each recording inherits the default configuration from the global Terminalizer config file, which is located at ~/.terminalizer/config.yml. This means that you can edit the configuration for individual recordings directly by editing the recording file (e.g. your-recording.yml). Alternatively, you can edit the global configuration, which will have an impact on all new recordings.

In this example you’ll edit the global configuration file, but the same guidance applies to individual recording configuration files as well.

Begin by opening the global Terminalizer configuration file in your text editor, such as nano:

  • nano ~/.terminalizer/config.yml

Each of the available configuration options within the file are commented in order to explain what they do.

There are several common configuration options that you may wish to adjust to your liking:

  • cols: Explicitly set the number of terminal columns used for your recording.
  • rows: Explicitly set the number of terminal rows used for your recording.
  • frameDelay: Override the delay between each keystroke during playback.
  • maxIdleTime: Specify a maximum time between keystrokes during playback.
  • cursorStyle: Specify the default terminal cursor style out of block, bar, and underline.
  • fontFamily: Specify a list of preferred playback fonts, in order of preference.
  • theme: Adjust the color scheme of the playback, for example to create a black-on-white terminal, etc.

As an example, you can achieve a white-on-black terminal display by configuring the following options:

config.yml

. . . theme:   background: "white"   foreground: "black" . . . 

This will produce a result similar to the following:

A screenshot of the Terminalizer website, showing an example of a recording with a black-on-white theme

You could adjust the cursor style to make the recording easier to understand, for example by swapping the default block-style cursor with an underlined one:

config.yml

. . . cursorStyle: underline . . . 

This produces a result similar to the following:

A screenshot of the Terminalizer website, showing an example of a recording with an underline-style cursor

Once you have made any desired changes, save the file and return to your terminal.

If you edited the global Terminalizer configuration, these settings will apply to all new recordings going forward. If you’re editing a specific recording configuration, Terminalizer will immediately apply the changes to that particular recording.

Note that custom playback styling only applies to shared recording sessions. Playing them back directly in your terminal will always use your default terminal styling and color scheme.

In this final step, you reviewed some of the advanced configuration options for Terminalizer.

Conclusion

In this article you used Terminalizer to record and share a terminal session. You now have the knowledge required to create recorded demos of your software for use in marketing material, or to share command-line tricks with friends.

If you wish to render and export Terminalizer recordings into GIF format, you can install Terminalizer on a machine with a graphical user interface/desktop and use the built-in rendering features:

  • Create GIFs Using Terminalizer

You may also wish to browse the Terminalizer website to see recorded terminal sessions shared by other users:

  • Explore Terminalizer Recordings