How to record your terminal actions on Linux

Source: Internet
Author: User
Tags imagemagick

2016/07/21 · All  1 reviews · Linux

share to:4

    • JSP Custom Labels
    • Python Development Environment Building
    • PHP implementation file upload and download
    • PHP implementation of page static

Source: Bill Toulas translation Source: Mikecoder

Recording a terminal operation can be an easy way to help others learn Linux, display a series of correct command-line operations, and share knowledge. For whatever purpose, copying and pasting text from a terminal needs to be repeated many times, and the process of recording video is cumbersome and sometimes cannot be recorded. In this article, we'll take a simple look at how to record and share a terminal session in GIF format.

Pre-Request

If you just want to be able to record your terminal session and be able to play back at the terminal or share it with others, you only need a software called: Ttyrec. Ubuntu users can install by running this line of code:

Shell
1 sudo apt-get install ttyrec

If you want to convert the generated video into a GIF file so you can share it with people who don't use the terminal, you'll be able to post it to the website, or you just want to make a GIF easy to use without having to write commands. Then you need to install an additional two packages. The first one is ImageMagick, which you can install with the following command:

Shell
1 sudo apt-get install imagemagick

The second package is: tty2gif.py, access to its Project site download. This package requires the following dependencies to be installed:

Shell
1 sudo apt-get install python-opster

Recording

To start recording terminal operations, all you need to do is type ttyprec , then enter. This command will run a real-time logging tool in the background. We can stop by typing exit or ctrl+d . Ttyrec creates a file in the home directory by default ttyrecord .

Playback

It's very easy to play back this file. You just need to open the terminal and open the file with a ttyplay command ttyrecord . (In this example, we use Ttyrecord as the filename, of course, you can also change the file name you use)

You can then start playing the file. This video records all the actions, including your deletion, modification. This looks like a self-conscious terminal, but the process of executing this command is not just for the system to look at, but to show it to people better.

Note that the playback of this record is completely controllable and you can slow down by clicking + or - Speeding, or 0 1 pausing and resuming playback.

Export as GIF

For convenience, we usually convert video recording to GIF format, and this is very easy to do. Here's how:

Copy the previously downloaded tty2gif.py file to the same directory as the Ttyprecord file (or the video file you named), then open the terminal in this directory and enter the command:

Shell
1 Python tty2gif. py typing ttyrecord

If an error occurs, check to see if you have a Python-opster package installed. If you still have an error, use the following command to exclude it.

Shell
12 sudo apt-get install xdotool export Windowid=$(xdotool getwindowfocus)

Then repeat this command python tty2gif.py and you will see some more GIF files in the Ttyrecord directory.

The next step is to integrate all the GIF files and pack them into a GIF file. We do this by using the ImageMagick tool. Enter the following command:

Shell
1 Convert -delay -loop 0 *. gif example. gif

You can use any file name, I use Example.gif. And, you can change this delay and cycle time. Enjoy.

How to record your terminal actions on Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.