Home Arch Terminalizer – Record your terminal sessions in Linux and generate gif images

Terminalizer – Record your terminal sessions in Linux and generate gif images

0
335
(Last Updated On: July 30, 2018)

Well, you got this fancy command output from your terminal and want to make an animated image out of it?. Terminalizer is a tool that is gonna help you do this. In this article, we are going to learn how to install and use Terminalizer to generate animated gifs on Ubuntu 16.04, Ubuntu 18.04, CentOS 7. Terminalizer can record your terminal and generate animated gif images.

Installing Terminalizer on Ubuntu 18.04 / Ubuntu 16.04 / CentOS 7 / Arch Linux

To install terminalizer, follow the following procedure.

Step 1. Install Nodejs

Installation of Nodejs on Ubuntu, CentOS, and Arch Linux is available on Install Node.js on CentOS 7 / Ubuntu 16.04 / Arch Linux / macOS

If you’re an Ubuntu user, quick installation of Nodejs can be done by updating your local package index and then install Nodejs and its package manager from the repositories with the following command:

sudo apt-get update -y
sudo apt-get install nodejs npm -y

On CentOS, install EPEL repository and enable Nodejs v8 LTS repository as well after which you install Nodejs;

sudo yum install epel-release -y && sudo yum update -y
curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
sudo yum install nodejs -y

For Arch Linux, install Nodejs using:

sudo pacman -S nodejs npm

Install Nodejs with nvm

Nodejs can also be installed and managed using nvm.

$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

If you have a different shell like zsh, add the following lines to the end of ~/.zshrc file:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

To download, compile, and install the latest release of node, do this:

$ nvm install node 
Downloading and installing node v10.7.0...
Downloading https://nodejs.org/dist/v10.7.0/node-v10.7.0-linux-x64.tar.xz...
################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v10.7.0 (npm v6.1.0)
Creating default alias: default -> node (-> v10.7.0)
$ nvm use node
$ node -v
v10.7.0

Or, you can run any arbitrary command in a subshell with the desired version of node:

nvm exec 4.2 node --version

Step 2: Install build tools for Terminalizer

Terminalizer uses some C++ addons that require building. This needs to be installed before you can start installing and using Terminalizer.

For CentOS and other RHEL derivatives;

sudo yum install gcc-c++ make -y

For Ubuntu and other Debian derivatives;

sudo apt-get install build-essential -y

For Arch Linux / Manjaro execute the following commands on your terminal:

$ sudo pacman -S gcc make cmake

You can confirm the versions of packages installed using gcc -v  and make -v

$ gcc -v

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-16ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --with-as=/usr/bin/x86_64-linux-gnu-as --with-ld=/usr/bin/x86_64-linux-gnu-ld --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)

Step 3. Install Terminalizer on Ubuntu 18.04 / Ubuntu 16.04 / CentOS 7 / Arch Linux

Once all dependencies have been installed, proceed to install Terminalizer on your Ubuntu 18.04 / Ubuntu 16.04 / CentOS 7 / Arch Linux system using npm package manager. It is recommended to first install node-gyp using npm to avoid later issues.

$ sudo npm install -g node-gyp
/usr/bin/node-gyp -> /usr/lib/node_modules/node-gyp/bin/node-gyp.js
+ [email protected]
added 1 package and updated 6 packages in 4.127s

Its binary will be available on /usr/bin/node-gyp

Now install terminalizer:

$ npm install -g terminalizer
...
+ [email protected]
added 266 packages from 186 contributors in 43.086s

if you encounter issues during installation, try to install Nodejs using nvm method provided earlier instead of installing for a repository.

Using Terminalizer

To start recording your terminal sessions, just type:

$ terminalizer record <session-name>

E.g

$ terminalizer record  test-demo
The recording session is started
Press CTRL+D to exit and save the recording

The recording will start in the background and a file called test-demo.yml is created in the current directory.

You can open it using any editor to edit the configurations and the recorded frames. To replay your recording using the terminalizer play command.

$ terminalizer play  test-demo

When done, you can render the recording as an animated gif using render command:

$ terminalizer render test-demo
Rendering frame 24/24 100% [==============================] 0.0s
Merging frame 24/24 100% [==============================] 0.0s

Successfully Rendered
The animated GIF image is saved into the file:
/home/jmutai/render1532867073991.gif

To generate a web player for a recording file

$ terminalizer generate <recordingFile>

To upload a recording file and get a link for an online player

$ terminalizer share <recordingFile>

The default config.yml file is stored at root directory the of the project. Execute the below command to copy it to your current directory.

Use any editor to edit the copied config.yml, then use the -c option to override the default one.

$ terminalizer config