如何在Ubuntu 18.04上使用Terminalizer记录和共享终端会话

The author selected the Electronic Frontier Foundation to receive a donation as part of the Write for DOnations program.

作者选择了电子前沿基金会来接受捐款,这是Write for DOnations计划的一部分。

介绍 (Introduction)

Terminalizer is a terminal recorder application that allows you to record your terminal session in real-time, and then play it back at a later date. It works in the same way as a desktop screen recorder, but instead runs in your terminal.

Terminalizer是一个终端记录器应用程序,可让您实时记录您的终端会话,然后在以后播放。 它的工作方式与台式机屏幕录像机相同,但是在您的终端上运行。

Recording your terminal session is useful if you want to review a particular activity again, or to help debug a particularly tricky error. Recordings made with Terminalizer can also be exported as animated GIFs, which are great for sharing online or adding to marketing material for your software.

如果您想再次查看特定活动或帮助调试特别棘手的错误,则记录终端会话非常有用。 使用Terminalizer录制的记录也可以导出为GIF动画,非常适合在线共享或为您的软件添加营销材料。

In this tutorial, you will install Terminalizer, use it to record and play back terminal sessions, customize your recordings, and then export them to share online.

在本教程中,您将安装Terminalizer,使用它来录制和播放终端会话,自定义录制内容,然后将其导出以在线共享。

先决条件 (Prerequisites)

To complete this tutorial, you will need:

要完成本教程,您将需要:

If you wish to share your recordings online, you’ll also need:

如果您想在线共享录音,则还需要:

Once you have these ready, log in to your server as your non-root user to begin.

准备就绪后,以非root用户身份登录到服务器以开始。

第1步-安装Terminalizer (Step 1 — Installing Terminalizer)

In this step, you will download and install Terminalizer on your system. Terminalizer is written using Node.js, and is available to install using the npm package manager.

在此步骤中,您将下载并在系统上安装Terminalizer。 Terminalizer是使用Node.js编写的,并且可以使用npm软件包管理器进行安装。

To install Terminalizer globally on your system, run the following command:

要在系统上全局安装Terminalizer,请运行以下命令:

  • sudo npm install --global --allow-root --unsafe-perm=true terminalizer

    sudo npm install --global --allow-root --unsafe-perm = true终端程序

Terminalizer uses the Electron application framework to export recorded terminal sessions into GIF format. The --unsafe-perms=true command argument is required in order to install Electron globally on your system.

Terminalizer使用Electron应用程序框架将记录的终端会话导出为GIF格式。 为了在系统上全局安装Electron,需要--unsafe-perms=true命令参数。

Once Terminalizer has been installed, you’ll see similar output to the following:

安装Terminalizer后,您将看到类似以下的输出:


   
   
Output
. . . /usr/local/lib └── terminalizer@0.7.1

Next, check your installation of Terminalizer by running:

接下来,通过运行以下命令检查您的Terminalizer安装:

  • terminalizer --version

    终端程序-版本

This will display something similar to the following:

这将显示类似于以下内容:


   
   
Output
0.7.1

Finally, generate a default Terminalizer configuration file, which you can use for Terminalizer’s advanced customization (detailed further in Step 4):

最后,生成一个默认的Terminalizer配置文件,您可以将其用于Terminalizer的高级自定义(在步骤4中进一步详细介绍):

  • terminalizer init

    终端初始化

This will produce output similar to the following:

这将产生类似于以下内容的输出:


   
   
Output
The global config directory is created at /home/user/.terminalizer

Now that you’ve installed Terminalizer, you can make your first terminal recording.

既然已经安装了Terminalizer,就可以进行第一个终端录制了。

步骤2 —录制和播放终端会话 (Step 2 — Recording and Playing Back a Terminal Session)

In this step, you will record and playback a terminal session.

在此步骤中,您将记录并回放终端会话。

To begin, set up a new Terminalizer recording using a name of your choice:

首先,使用您选择的名称设置新的Terminalizer记录:

  • terminalizer record your-recording

    终端程序记录您的记录

This will output the following to indicate that the recording has started:

这将输出以下内容,表明录制已开始:


   
   
Output
The recording session has started Press Ctrl+D to exit and save the recording

You can now proceed to do anything that you want within your terminal. Each key press and command will be recorded in real-time by Terminalizer.

现在,您可以在终端中继续执行所需的任何操作。 每个按键和命令将由Terminalizer实时记录。

For example:

例如:

  • pwd

    密码
  • date

    日期
  • whoami

    我是谁
  • echo "Hello, world!"

    回声“你好,世界!”

When you’d like to stop the recording, press CTRL+D. Terminalizer will then save the recording to the specified file in YAML format, for example, your-recording.yml.

当您想要停止录制时,请按CTRL+D 然后,Terminalizer将以YAML格式将记录保存到指定的文件,例如your-recording .yml


   
   
Output
Successfully Recorded The recording data is saved into the file: /home/user/your-recording.yml

You may be prompted by Terminalizer to share your recording online. Just press CTRL+C to cancel this for now, as you can playback the terminal recording locally first.

Terminalizer可能会提示您在线共享您的录音。 现在您只需按CTRL+C即可取消此操作,因为您可以先在本地播放终端记录。

Next, play your recorded terminal session with the followng command:

接下来,使用以下命令播放录制的终端会话:

  • terminalizer play your-recording

    终端机播放您的录音

This will replay the recorded session in real-time in your terminal:

这将在您的终端中实时重放录制的会话:


   
   
Output
user@droplet:~$ pwd /home/user user@droplet:~$ date Sun Mar 8 14:55:36 UTC 2020 user@droplet:~$ whoami user user@droplet:~$ echo "Hello, world!" Hello, world! user@droplet:~$ logout

You can also adjust the playback speed of your recording using the --speed-factor option.

您也可以使用--speed-factor选项调整录制的播放速度。

For example, the following will playback your recording twice as slowly (half speed):

例如,以下内容将以两倍的速度(半速)播放您的录音:

  • terminalizer play your-recording --speed-factor 2

    终端机播放您的录音 -速度因数2

Alternatively, you can play back your recording twice as fast (double speed):

或者,您可以以两倍快(两倍的速度)播放录音:

  • terminalizer play your-recording --speed-factor 0.5

    终端机播放您的录音 -速度系数0.5

You’ve recorded and played back a terminal session. Next, you can share a recorded terminal session online.

您已经录制并播放了一个终端会话。 接下来,您可以在线共享录制的终端会话。

步骤3 –共享录制的终端会话 (Step 3 — Sharing a Recorded Terminal Session)

In this step, you’ll share your recorded terminal session online on the Terminalizer Explore page.

在此步骤中,您将在Terminalizer Explore页面上在线共享录制的终端会话。

Begin by selecting a recorded session to share:

首先选择要共享的录制会话:

  • terminalizer share your-recording

    终端程序共享您的记录

You will then be prompted to provide some basic metadata about your recording, such as the title and description:

然后,系统将提示您提供有关录制的一些基本元数据,例如标题和说明:


   
   
Output
Please enter some details about your recording ? Title Title of Your Recording ? Description Description of Your Recording ? Tags such as git,bash,game Comma-separated Tags for Your Recording

Warning: Terminalizer recordings are shared publicly by default, so ensure that there are no personally identifiable or confidential details present in your terminal recording that you don’t want to share.

警告:默认情况下,Terminalizer记录是公开共享的,因此请确保您不想共享的终端记录中没有个人识别或机密信息。

If this is the first time that you’ve shared a recorded session using Terminalizer, you’ll need to link your Terminalizer account. Terminalizer will display a verification link if this is required:

如果这是您第一次使用Terminalizer分享录制的会话,则需要链接您的Terminalizer帐户。 如果需要,Terminalizer将显示一个验证链接:


   
   
Output
Open the following link in your browser and login into your account https://terminalizer.com/token?token=your-token When you do it, press any key to continue

Warning: Ensure that you keep your Terminalizer token private, as it will allow anyone in possession of it to access your Terminalizer account.

警告:请确保您对Terminalizer令牌保持私密,因为它将允许拥有它的任何人访问您的Terminalizer帐户。

Once you have visited the link in your web browser and signed in to your Terminalizer account, press any key to continue.

在Web浏览器中访问链接并登录到Terminalizer帐户后,请按任意键继续。

Terminalizer will now upload your recording and provide you the link to view it:

Terminalizer现在将上传您的录像,并提供查看链接:


   
   
Output
Successfully Uploaded The recording is available on the link: https://terminalizer.com/view/your-recording-id

Visiting the link in a desktop web browser will allow you to view your shared recording:

在桌面网络浏览器中访问链接将使您可以查看共享的记录:

You’ve shared a recorded terminal session on the Terminalizer website and viewed it in your web browser.

您已经在Terminalizer网站上共享了一个录制的终端会话,并在Web浏览器中进行了查看。

步骤4 —设置高级Terminalizer配置 (Step 4 — Setting Advanced Terminalizer Configuration)

Now that you’ve gained some familiarity with Terminalizer, you can begin to review some of the more advanced customization options, such as the ability to adjust the display colors and style.

既然您已经对Terminalizer有了一定的了解,那么您就可以开始查看一些更高级的自定义选项,例如调整显示颜色和样式的能力。

Each recording inherits the default configuration from the global Terminalizer config file, which is located at ~/.terminalizer/config.yml. This means that you can edit the configuration for individual recordings directly by editing the recording file (e.g. your-recording.yml). Alternatively, you can edit the global configuration, which will have an impact on all new recordings.

每个记录都从全局Terminalizer配置文件继承默认配置,该文件位于~/.terminalizer/config.yml 。 这意味着您可以直接通过编辑记录文件(例如your-recording .yml )来编辑单个记录的配置。 或者,您可以编辑全局配置,这将影响所有新的录音。

In this example you’ll edit the global configuration file, but the same guidance applies to individual recording configuration files as well.

在此示例中,您将编辑全局配置文件,但是相同的指南也适用于单个录制配置文件。

Begin by opening the global Terminalizer configuration file in your text editor, such as nano:

首先在文本编辑器中打开全局Terminalizer配置文件,例如nano

  • nano ~/.terminalizer/config.yml

    纳米〜/ .terminalizer / config.yml

Each of the available configuration options within the file are commented in order to explain what they do.

对文件中的每个可用配置选项都进行了注释,以解释它们的作用。

There are several common configuration options that you may wish to adjust to your liking:

您可能希望根据自己的喜好调整几种常见的配置选项:

  • cols: Explicitly set the number of terminal columns used for your recording.

    cols :明确设置用于记录的终端列数。

  • rows: Explicitly set the number of terminal rows used for your recording.

    rows :明确设置用于记录的终端行数。

  • frameDelay: Override the delay between each keystroke during playback.

    frameDelay :覆盖播放期间每次击键之间的延迟。

  • maxIdleTime: Specify a maximum time between keystrokes during playback.

    maxIdleTime :指定播放期间两次击键之间的最长时间。

  • cursorStyle: Specify the default terminal cursor style out of block, bar, and underline.

    cursorStyle :在blockbarunderline cursorStyle指定默认的终端光标样式。

  • fontFamily: Specify a list of preferred playback fonts, in order of preference.

    fontFamily :按首选项顺序指定首选播放字体的列表。

  • theme: Adjust the color scheme of the playback, for example to create a black-on-white terminal, etc.

    theme :调整播放的配色方案,例如创建黑白终端等。

As an example, you can achieve a white-on-black terminal display by configuring the following options:

例如,您可以通过配置以下选项来实现白色终端显示:

config.yml
配置文件
. . .
theme:
  background: "white"
  foreground: "black"
. . .

This will produce a result similar to the following:

这将产生类似于以下内容的结果:

You could adjust the cursor style to make the recording easier to understand, for example by swapping the default block-style cursor with an underlined one:

您可以调整光标样式,使记录更易于理解,例如,将默认的块样式光标替换为带下划线的光标:

config.yml
配置文件
. . .
cursorStyle: underline
. . .

This produces a result similar to the following:

这将产生类似于以下结果:

Once you have made any desired changes, save the file and return to your terminal.

进行所需的更改后,保存文件并返回到终端。

If you edited the global Terminalizer configuration, these settings will apply to all new recordings going forward. If you’re editing a specific recording configuration, Terminalizer will immediately apply the changes to that particular recording.

如果您编辑了全局Terminalizer配置,则这些设置将应用于以后的所有新录制。 如果您正在编辑特定的录音配置,Terminalizer将立即将更改应用于该特定的录音。

Note that custom playback styling only applies to shared recording sessions. Playing them back directly in your terminal will always use your default terminal styling and color scheme.

请注意,自定义播放样式仅适用于共享录制会话。 直接在终端中播放它们将始终使用默认的终端样式和配色方案。

In this final step, you reviewed some of the advanced configuration options for Terminalizer.

在最后一步中,您回顾了Terminalizer的一些高级配置选项。

结论 (Conclusion)

In this article you used Terminalizer to record and share a terminal session. You now have the knowledge required to create recorded demos of your software for use in marketing material, or to share command-line tricks with friends.

在本文中,您使用了Terminalizer来记录和共享终端会话。 现在,您已具备创建录制的软件演示以用于市场营销资料或与朋友共享命令行技巧所需的知识。

If you wish to render and export Terminalizer recordings into GIF format, you can install Terminalizer on a machine with a graphical user interface/desktop and use the built-in rendering features:

如果希望将Terminalizer录制内容渲染并导出为GIF格式,则可以在具有图形用户界面/桌面的计算机上安装Terminalizer,并使用内置的渲染功能:

You may also wish to browse the Terminalizer website to see recorded terminal sessions shared by other users:

您可能还希望浏览Terminalizer网站,以查看其他用户共享的录制的终端会话:

翻译自: https://www.digitalocean.com/community/tutorials/how-to-record-and-share-terminal-sessions-using-terminalizer-on-ubuntu-18-04

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值