Record terminal session as gif

ttyrec_comp

We mentioned ttyrec in one of our earlier articles. But wouldn’t it be cool if you could record a terminal session as a gif image and share with others? Here’s how to do it with simple cmdline tools.

Requirements

  1. ttyrec
    $ sudo apt-get install ttyrec
  2. tty2gif
    Download the python script from the Bitbucket project or from here.
  3. python-opster (tty2gif dependency)
    $ sudo apt-get install python-opster
  4. convert utility
    $ sudo apt-get install imagemagick

Procedure

  1. Run ttyrec. Start by typing <Ctrl-l> to clear the screen so that the command is also cleared. This is needed to ensure that the tty2gif.py command (in Step 3) isn’t added to your gif image. Continue doing your stuff …
    $ ttyrec
  2. Once done, press <Ctrl-d> to exit ttyrec recording session. You should have a ttyrecord file in the same location.
  3. Copy the tty2gif.py script in the same directory. Convert the ttyrec session to a sequence of gif images:
    $ ./tty2gif.py typing ttyrecord
  4. Now generate the final gif image from the sequence:
    $ convert -delay 25 -loop 0 *.gif terminal.gif

2 thoughts on “Record terminal session as gif”

Leave a Reply

Your email address will not be published. Required fields are marked *