Terminalizer – 在 Linux 上記錄終端會話的工具

你有沒有想過如何記錄你的 Linux 終端? Terminalizer 是一個花哨且高度可定制的 CLI 工具,它記錄和呈現終端活動,並可以從中製作動畫 GIF 圖像。 它可以在 Ubuntu、CentOS、Arch Linux、SUSE、RedHat、 Fedora等。在本教程中,我們將帶您了解如何安裝和捕獲/記錄您的 Linux 終端。

在安裝終端機之前,請確保您有 節點.js高於海平面 安裝。

安裝 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

終端器的安裝應該適用於 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 <https://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

這將播放一段錄音,顯示您剛剛運行的最後幾個命令的歷史記錄

另請閱讀:

  • Termtosvg – 在 Linux 中記錄終端會話的工具
  • Tlog – 記錄/播放終端 IO 和會話的工具
  • 8 個流行且鮮為人知的 Linux 終端錄音工具
  • 如何使用 Asciinema 記錄和共享 Linux 終端活動
  • 如何使用“腳本”命令記錄 Linux 終端會話

正如從上面的例子中已經看到的,終端器是一個方便的工具,用來記錄你的終端。 請隨意嘗試並繼續關注這些內容豐富的文章!

資源參考:

Github—— 終結者