Termstovg is tool written in Python allowing to record your Linux terminal session. The interesting way is the render that it gives as standalone SVG animations. Then, you can use your web browser to play the animation after the recording. This tool has several themes available to record a terminal session using a specific color theme. It is a Github projecwhich is very interesting.

nstall termstovg

All you need as pre-requisite is python installed in your Linux computer. The good news is the compatibility with python 3.5 and more. On Ubuntu 18.04 for example, you have already python installed and the default version is python-3.6. You can check as below:

$ dpkg -l | grep python3.6
ii libpython3.6:amd64 3.6.5-3 amd64 Shared Python runtime library (version 3.6)
ii libpython3.6-minimal:amd64 3.6.5-3 amd64 Minimal subset of the Python language (version 3.6)
ii libpython3.6-stdlib:amd64 3.6.5-3 amd64 Interactive high-level object-oriented language (standard library, version 3.6)
ii python3.6 3.6.5-3 amd64 Interactive high-level object-oriented language (version 3.6)
ii python3.6-minimal 3.6.5-3 amd64 Minimal subset of the Python language (version 3.6)

Now you need to install also pip for python

$ sudo apt install python3-pip
Reading package lists... Done
Building dependency tree 
Reading state information... Done
The following additional packages will be installed:

Now install the requirements for termtosvg which are

  • pyte to render the terminal screen
  • svgwrite to create SVG animations
  • python-xlib to query the X server for color configuration and to parse Xresources data
  • base16-xresources for default color themes
$ pip3 install pyte python-xlib svgwrite
Collecting pyte
Collecting python3-xlib
 Downloading https://files.pythonhosted.org/packages/ef/c6/2c5999de3bb1533521f1101e8fe56fd9c266732f4d48011c7c69b29d12ae/python3-xlib-0.15.tar.gz (132kB)

Now for the default color themes, run the command below:

$ curl https://raw.githubusercontent.com/chriskempson/base16-xresources/master/xresources/base16-default-dark-256.Xresources >> ~/.Xresources
$ xrdb -load ~/.Xresources

A file ~/.Xressources is now present on your home and you can paste the termtosvg colors below.

$ vim ~/.Xresources

termtosvg.foreground: #f8f8f2
termtosvg.background: #272822
termtosvg.color0: #272822
termtosvg.color1: #f92672
termtosvg.color2: #a6e22e
termtosvg.color3: #f4bf75
termtosvg.color4: #66d9ef
termtosvg.color5: #ae81ff
termtosvg.color6: #a1efe4
termtosvg.color7: #f8f8f2
termtosvg.color8: #75715e
termtosvg.color9: #fd971f
termtosvg.color10: #383830
termtosvg.color11: #49483e
termtosvg.color12: #a59f85
termtosvg.color13: #f5f4f1
termtosvg.color14: #cc6633
termtosvg.color15: #f9f8f5

Then you can install termtosvg through pip

# pip3 install termtosvg
Collecting termtosvg
 Downloading https://files.pythonhosted.org/packages/04/43/dd755b9185f58c4a4cf49fa710a0966b32b68e930c33bab785cf926201bd/termtosvg-0.2.2-py3-none-any.whl
Collecting pyte (from termtosvg)
 Downloading https://files.pythonhosted.org/packages/66/37/6fed89b484c8012a0343117f085c92df8447a18af4966d25599861cd5aa0/pyte-0.8.0.tar.gz (50kB)
 100% |████████████████████████████████| 51kB 6.0MB/s 
Collecting python-xlib (from termtosvg)
 Downloading https://files.pythonhosted.org/packages/54/44/e56454e3ce8fd2333e635d704e157e9cc432a375ab6b680e3c98dd7c3bc0/python_xlib-0.23-py2.py3-none-any.whl (123kB)
 100% |████████████████████████████████| 133kB 5.5MB/s 
Collecting svgwrite (from termtosvg)
 Downloading https://files.pythonhosted.org/packages/9f/27/a29fc710b5fc4dc8031d55e903c1352a194df4014dccf8b507049dd754e6/svgwrite-1.1.12-py2.py3-none-any.whl (64kB)
 100% |████████████████████████████████| 71kB 6.5MB/s 
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from termtosvg)
Collecting wcwidth (from pyte->termtosvg)
 Downloading https://files.pythonhosted.org/packages/7e/9f/526a6947247599b084ee5232e4f9190a38f398d7300d866af3ab571a5bfe/wcwidth-0.1.7-py2.py3-none-any.whl
Requirement already satisfied: six>=1.10.0 in /usr/lib/python3/dist-packages (from python-xlib->termtosvg)
Requirement already satisfied: pyparsing>=2.0.1 in /usr/lib/python3/dist-packages (from svgwrite->termtosvg)
Building wheels for collected packages: pyte
 Running setup.py bdist_wheel for pyte ... done
 Stored in directory: /root/.cache/pip/wheels/c0/dd/4a/d0ec26b9d07a3b48e25ba3456dc9bcab875686af6da9e23fcd
Successfully built pyte
Installing collected packages: wcwidth, pyte, python-xlib, svgwrite, termtosvg
Successfully installed pyte-0.8.0 python-xlib-0.23 svgwrite-1.1.12 termtosvg-0.2.2 wcwidth-0.1.7

Record a terminal session

To start recording your session live terminal, just run the termstosvg command in your terminal and use the exit command to end the recording process.

Start the recording

$ termtosvg
Recording started, enter "exit" command or Control-D to end

Then enter the commands and work. When you have finished, you can end the recording live session. You can see that it indicates path (generally /tmp) and the name of the recorded file

$ exit
Recording ended, SVG animation is /tmp/termtosvg_ksz18r3y.svg


Was this answer helpful? 0 Users Found This Useful (0 Votes)