你有没有想过如何记录你的Linux终端? 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
最后,我们将安装Node.js,它是的包管理器,apt install npm
验证npm运行的版本npm --version
输出3.5.2
安装terminalizer
安装terminalizer,运行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
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
使用Terminalizer
为了开始使用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
这将播放一个记录,显示最近运行过的几个命令的历史记录,
从上面的例子中已经看到,terminalizer是一个方便的工具,可以用来录制你的终端,
资源引用: