Terminalizer-在Linux上记录终端会话的工具

时间:2020-03-05 15:31:17  来源:igfitidea点击:

Terminalizer是一个精美且高度可定制的CLI工具,它可以记录并呈现终端活动,并可以从中制作动画GIF镜像。
它可以在Ubuntu,CentOS,Arch Linux,SUSE,RedHat,Fedora等上很好地工作。
在本教程中,我们将带我们了解如何安装和捕获/记录Linux终端。

在安装Terminalizer之前,请确保已安装Node.js和npm。

安装Node.js

要安装Node.js,首先,更新系统。
其中我正在使用Ubuntu 18.04版本。

apt update

接下来,运行以下命令从存储库中安装Node.js

apt install node.js

输出

The following NEW packages will be installed:
  libc-ares2 libhttp-parser2.7.1 libuv1 nodejs nodejs-doc
0 upgraded, 5 newly installed, 0 to remove and 490 not upgraded.
Need to get 5,671 kB of archives.
After this operation, 24.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

成功安装node.js后,我们可以使用如下命令验证Node.js的版本

nodejs --version

输出

v8.10.0

最后,我们将安装npm,它是Node.js的软件包管理器。

apt install npm

验证npm的版本运行

npm --version

输出

3.5.2

安装终端机

要安装终端程序,请运行

npm install -g terminalizer

输出示例

> [email protected] install /usr/local/lib/node_modules/terminalizer/node_modules/node-pty-prebuilt
> prebuild-install || node scripts/install.js

Terminalizer的安装应与Node.js版本9及更低版本一起正常工作。
如果我们运行的是较新版本,并且安装失败,则可能需要安装开发工具来构建C++加载项。
为了实现这一目标,

apt install build-essential

验证运行开发工具的安装

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)
make -v

输出

GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

使用终端机

要开始使用Terminalizer,我们首先要在当前目录中生成一个演示文件

terminalizer record demo

输出

The recording session is started
Press CTRL+D to exit and save the recording

此时,在终端上运行一些命令,然后按CTRL + D退出。
这会将记录另存为YAML文件,在本例中为demo.yml。

The recording data is saved into the file:
/root/demo.yml
You can edit the file and even change the configurations.

要播放录音,请运行

terminalizer play demo