docs: make Chinese README the default
build / build (push) Failing after 0s
lint / lint (push) Failing after 0s
build / snapshot (push) Failing after 0s
nightly / nightly (push) Failing after 1s

This commit is contained in:
wehub-resource-sync
2026-07-13 10:10:19 +00:00
parent e574f785d2
commit 74683d0295
+159 -200
View File
@@ -1,3 +1,9 @@
<!-- WEHUB_ZH_README -->
> [!NOTE]
> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
> [English](./README.en.md) · [原始项目](https://github.com/charmbracelet/vhs) · [上游 README](https://github.com/charmbracelet/vhs/blob/HEAD/README.md)
> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
# VHS
<p>
@@ -9,29 +15,27 @@
<a href="https://github.com/charmbracelet/vhs/actions"><img src="https://github.com/charmbracelet/vhs/workflows/build/badge.svg" alt="Build Status"></a>
</p>
Write terminal GIFs as code for integration testing and demoing your CLI tools.
以代码形式编写终端 GIF,用于集成测试和演示你的 CLI 工具。
<img alt="Welcome to VHS" src="https://stuff.charm.sh/vhs/examples/neofetch_3.gif" width="600" />
The above example was generated with VHS ([view source](./examples/neofetch/neofetch.tape)).
上面的示例由 VHS 生成([查看源码](./examples/neofetch/neofetch.tape))。
## Tutorial
## 教程
To get started, [install VHS](#installation) and create a new `.tape` file.
要开始使用,请[安装 VHS](#installation),并创建一个新的 `.tape` 文件。
```sh
vhs new demo.tape
```
Open the `.tape` file with your favorite `$EDITOR`.
使用你喜欢的 `$EDITOR` 打开 `.tape` 文件。
```sh
vim demo.tape
```
Tape files consist of a series of [commands](#vhs-command-reference). The commands are
instructions for VHS to perform on its virtual terminal. For a list of all
possible commands see [the command reference](#vhs-command-reference).
Tape 文件由一系列[命令](#vhs-command-reference)组成。这些命令是 VHS 在其虚拟终端上执行的指令。要查看所有可用命令,请参阅[命令参考](#vhs-command-reference)。
```elixir
# Where should we write the GIF?
@@ -55,14 +59,13 @@ Enter
Sleep 5s
```
Once you've finished, save the file and feed it into VHS.
完成后,保存文件并将其输入 VHS
```sh
vhs demo.tape
```
All done! You should see a new file called `demo.gif` (or whatever you named
the `Output`) in the directory.
全部完成!你应该会在目录中看到名为 `demo.gif` 的新文件(或你命名的 `Output`)。
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/demo.gif">
@@ -70,14 +73,14 @@ the `Output`) in the directory.
<img width="600" alt="A GIF produced by the VHS code above" src="https://stuff.charm.sh/vhs/examples/demo.gif">
</picture>
For more examples see the [`examples/`](https://github.com/charmbracelet/vhs/tree/main/examples) directory.
更多示例请参阅 [`examples/`](https://github.com/charmbracelet/vhs/tree/main/examples) 目录。
## Installation
## 安装
> [!NOTE]
> VHS requires [`ttyd`](https://github.com/tsl0922/ttyd) and [`ffmpeg`](https://ffmpeg.org) to be installed and available on your `PATH`.
> VHS 需要安装 [`ttyd`](https://github.com/tsl0922/ttyd) [`ffmpeg`](https://ffmpeg.org),并确保它们在你的 `PATH` 上可用。
Use a package manager:
使用包管理器:
```sh
# macOS or Linux
@@ -93,25 +96,25 @@ nix-env -iA nixpkgs.vhs
scoop install vhs
```
Or, use Docker to run VHS directly, dependencies included:
或者,使用 Docker 直接运行 VHS(已包含依赖):
```sh
docker run --rm -v $PWD:/vhs ghcr.io/charmbracelet/vhs <cassette>.tape
```
Or, download it:
或者,直接下载:
- [Packages][releases] are available in Debian and RPM formats
- [Binaries][releases] are available for Linux, macOS, and Windows
- [Packages][releases] 提供 Debian RPM 格式
- [Binaries][releases] 提供适用于 LinuxmacOS Windows 的版本
Or, just install it with `go`:
或者,使用 `go` 安装:
```sh
go install github.com/charmbracelet/vhs@latest
```
<details>
<summary>Windows, Debian, Ubuntu, Fedora, RHEL, Void Instructions</summary>
<summary>WindowsDebianUbuntuFedoraRHELVoid 安装说明</summary>
- Debian / Ubuntu
@@ -155,94 +158,85 @@ scoop install vhs
[releases]: https://github.com/charmbracelet/vhs/releases
## Record Tapes
## 录制 Tape
VHS has the ability to generate tape files from your terminal actions!
VHS 可以根据你的终端操作生成 tape 文件!
To record to a tape file, run:
要录制到 tape 文件,请运行:
```bash
vhs record > cassette.tape
```
Perform any actions you want and then `exit` the terminal session to stop
recording. You may want to manually edit the generated `.tape` file to add
settings or modify actions. Then, you can generate the GIF:
执行你想要的任何操作,然后 `exit` 终端会话以停止录制。你可能需要手动编辑生成的 `.tape` 文件,以添加设置或修改操作。然后,你可以生成 GIF:
```bash
vhs cassette.tape
```
## Publish Tapes
## 发布 Tape
VHS allows you to publish your GIFs to our servers for easy sharing with your
friends and colleagues. Specify which file you want to share, then use the
`publish` sub-command to host it on `vhs.charm.sh`. The output will provide you
with links to share your GIF via browser, HTML, and Markdown.
VHS 允许你将 GIF 发布到我们的服务器,以便与朋友和同事轻松分享。指定要分享的文件,然后使用 `publish` 子命令将其托管到 `vhs.charm.sh`。输出会提供通过浏览器、HTML 和 Markdown 分享 GIF 的链接。
```bash
vhs publish demo.gif
```
## The VHS Server
## VHS 服务器
VHS has an SSH server built in! When you self-host VHS you can access it as
though it were installed locally. VHS will have access to commands and
applications on the host, so you don't need to install them on your machine.
VHS 内置了 SSH 服务器!当你自行托管 VHS 时,可以像本地安装一样访问它。VHS 将能够访问主机上的命令和应用程序,因此你无需在自己的机器上安装它们。
To start the server run:
要启动服务器,请运行:
```sh
vhs serve
```
<details>
<summary>Configuration Options</summary>
<summary>配置选项</summary>
- `VHS_PORT`: The port to listen on (`1976`)
- `VHS_HOST`: The host to listen on (`localhost`)
- `VHS_GID`: The Group ID to run the server as (current user's GID)
- `VHS_UID`: The User ID to run the server as (current user's UID)
- `VHS_KEY_PATH`: The path to the SSH key to use (`.ssh/vhs_ed25519`)
- `VHS_AUTHORIZED_KEYS_PATH`: The path to the authorized keys file (empty, publicly accessible)
- `VHS_PORT`:监听的端口(`1976`
- `VHS_HOST`:监听的主机(`localhost`
- `VHS_GID`:运行服务器时使用的组 ID(当前用户的 GID
- `VHS_UID`:运行服务器时使用的用户 ID(当前用户的 UID
- `VHS_KEY_PATH`:要使用的 SSH 密钥路径(`.ssh/vhs_ed25519`
- `VHS_AUTHORIZED_KEYS_PATH`authorized keys 文件路径(为空,可公开访问)
</details>
Then, simply access VHS from a different machine via `ssh`:
然后,只需通过 `ssh` 从另一台机器访问 VHS
```sh
ssh vhs.example.com < demo.tape > demo.gif
```
## VHS Command Reference
## VHS 命令参考
> [!NOTE]
> You can view all VHS documentation on the command line with `vhs manual`.
> 你可以在命令行中使用 `vhs manual` 查看所有 VHS 文档。
There are a few basic types of VHS commands:
VHS 命令有几种基本类型:
- [`Output <path>`](#output): specify file output
- [`Require <program>`](#require): specify required programs for tape file
- [`Set <Setting> Value`](#settings): set recording settings
- [`Type "<characters>"`](#type): emulate typing
- [`Left`](#arrow-keys) [`Right`](#arrow-keys) [`Up`](#arrow-keys) [`Down`](#arrow-keys): arrow keys
- [`Backspace`](#backspace) [`Enter`](#enter) [`Tab`](#tab) [`Space`](#space): special keys
- [`ScrollUp`](#scroll-up--down) [`ScrollDown`](#scroll-up--down): scroll terminal viewport
- [`Ctrl[+Alt][+Shift]+<char>`](#ctrl): press control + key and/or modifier
- [`Sleep <time>`](#sleep): wait for a certain amount of time
- [`Wait[+Screen][+Line] /regex/`](#wait): wait for specific conditions
- [`Hide`](#hide): hide commands from output
- [`Show`](#show): stop hiding commands from output
- [`Screenshot`](#screenshot): screenshot the current frame
- [`Copy/Paste`](#copy--paste): copy and paste text from clipboard.
- [`Source`](#source): source commands from another tape
- [`Env <Key> Value`](#env): set environment variables
- [`Output <path>`](#output):指定文件输出
- [`Require <program>`](#require):为 tape 文件指定所需程序
- [`Set <Setting> Value`](#settings):设置录制参数
- [`Type "<characters>"`](#type):模拟输入
- [`Left`](#arrow-keys) [`Right`](#arrow-keys) [`Up`](#arrow-keys) [`Down`](#arrow-keys):方向键
- [`Backspace`](#backspace) [`Enter`](#enter) [`Tab`](#tab) [`Space`](#space):特殊按键
- [`ScrollUp`](#scroll-up--down) [`ScrollDown`](#scroll-up--down):滚动终端视口
- [`Ctrl[+Alt][+Shift]+<char>`](#ctrl):按下 Control + 键和/或修饰键
- [`Sleep <time>`](#sleep):等待一定时间
- [`Wait[+Screen][+Line] /regex/`](#wait):等待特定条件
- [`Hide`](#hide):在输出中隐藏命令
- [`Show`](#show):停止在输出中隐藏命令
- [`Screenshot`](#screenshot):截取当前帧
- [`Copy/Paste`](#copy--paste):从剪贴板复制和粘贴文本
- [`Source`](#source):从另一个 tape 导入命令
- [`Env <Key> Value`](#env):设置环境变量
### Output
The `Output` command allows you to specify the location and file format
of the render. You can specify more than one output in a tape file which
will render them to the respective locations.
`Output` 命令允许你指定渲染的位置和文件格式。你可以在 tape 文件中指定多个输出,它们将被渲染到相应位置。
```elixir
Output out.gif
@@ -253,12 +247,9 @@ Output frames/ # a directory of frames as a PNG sequence
### Require
The `Require` command allows you to specify dependencies for your tape file.
These are useful to fail early if a required program is missing from the
`$PATH`, and it is certain that the VHS execution will not work as expected.
`Require` 命令允许你为 tape 文件指定依赖项。如果 `$PATH` 中缺少所需程序,这些依赖项有助于尽早失败,因为可以确定 VHS 执行将无法按预期工作。
Require commands must be defined at the top of a tape file, before any non-
setting or non-output command.
Require 命令必须在 tape 文件顶部定义,位于任何非 setting 或非 output 命令之前。
```elixir
# A tape file that requires gum and glow to be in the $PATH
@@ -268,24 +259,21 @@ Require glow
### Settings
The `Set` command allows you to change global aspects of the terminal, such as
the font settings, window dimensions, and GIF output location.
`Set` 命令允许你更改终端的全局属性,例如字体设置、窗口尺寸和 GIF 输出位置。
Setting must be administered at the top of the tape file. Any setting (except
`TypingSpeed`) applied after a non-setting or non-output command will be
ignored.
Setting 必须在 tape 文件顶部设置。任何在非 setting 或非 output 命令之后应用的设置(`TypingSpeed` 除外)都将被忽略。
#### Set Shell
#### 设置 Shell
Set the shell with the `Set Shell <shell>` command
使用 `Set Shell <shell>` 命令设置 shell。
```elixir
Set Shell fish
```
#### Set Font Size
#### 设置字体大小
Set the font size with the `Set FontSize <number>` command.
使用 `Set FontSize <number>` 命令设置字体大小。
```elixir
Set FontSize 10
@@ -296,24 +284,24 @@ Set FontSize 40
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/font-size-10.gif">
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/vhs/examples/font-size-10.gif">
<img width="600" alt="Example of setting the font size to 10 pixels" src="https://stuff.charm.sh/vhs/examples/font-size-10.gif">
<img width="600" alt="将字体大小设置为 10 像素的示例" src="https://stuff.charm.sh/vhs/examples/font-size-10.gif">
</picture>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/font-size-20.gif">
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/vhs/examples/font-size-20.gif">
<img width="600" alt="Example of setting the font size to 20 pixels" src="https://stuff.charm.sh/vhs/examples/font-size-20.gif">
<img width="600" alt="将字体大小设置为 20 像素的示例" src="https://stuff.charm.sh/vhs/examples/font-size-20.gif">
</picture>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/font-size-40.gif">
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/vhs/examples/font-size-40.gif">
<img width="600" alt="Example of setting the font size to 40 pixels" src="https://stuff.charm.sh/vhs/examples/font-size-40.gif">
<img width="600" alt="将字体大小设置为 40 像素的示例" src="https://stuff.charm.sh/vhs/examples/font-size-40.gif">
</picture>
#### Set Font Family
#### 设置字体族
Set the font family with the `Set FontFamily "<font>"` command
使用 `Set FontFamily "<font>"` 命令设置字体族。
```elixir
Set FontFamily "Monoflow"
@@ -322,12 +310,12 @@ Set FontFamily "Monoflow"
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/font-family.gif">
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/vhs/examples/font-family.gif">
<img width="600" alt="Example of changing the font family to Monoflow" src="https://stuff.charm.sh/vhs/examples/font-family.gif">
<img width="600" alt="将字体族更改为 Monoflow 的示例" src="https://stuff.charm.sh/vhs/examples/font-family.gif">
</picture>
#### Set Width
#### 设置宽度
Set the width of the terminal with the `Set Width` command.
使用 `Set Width` 命令设置终端宽度。
```elixir
Set Width 300
@@ -336,12 +324,12 @@ Set Width 300
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/width.gif">
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/vhs/examples/width.gif">
<img width="300" alt="Example of changing the width of the terminal" src="https://stuff.charm.sh/vhs/examples/width.gif">
<img width="300" alt="更改终端宽度的示例" src="https://stuff.charm.sh/vhs/examples/width.gif">
</picture>
#### Set Height
#### 设置高度
Set the height of the terminal with the `Set Height` command.
使用 `Set Height` 命令设置终端高度。
```elixir
Set Height 1000
@@ -350,13 +338,12 @@ Set Height 1000
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/height.gif">
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/vhs/examples/height.gif">
<img width="300" alt="Example of changing the height of the terminal" src="https://stuff.charm.sh/vhs/examples/height.gif">
<img width="300" alt="更改终端高度的示例" src="https://stuff.charm.sh/vhs/examples/height.gif">
</picture>
#### Set Letter Spacing
#### 设置字间距
Set the spacing between letters (tracking) with the `Set LetterSpacing`
Command.
使用 `Set LetterSpacing` 命令设置字母间距(tracking)。
```elixir
Set LetterSpacing 20
@@ -365,12 +352,12 @@ Set LetterSpacing 20
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/letter-spacing.gif">
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/vhs/examples/letter-spacing.gif">
<img width="600" alt="Example of changing the letter spacing to 20 pixels between characters" src="https://stuff.charm.sh/vhs/examples/letter-spacing.gif">
<img width="600" alt="将字符间字间距更改为 20 像素的示例" src="https://stuff.charm.sh/vhs/examples/letter-spacing.gif">
</picture>
#### Set Line Height
#### 设置行高
Set the spacing between lines with the `Set LineHeight` Command.
使用 `Set LineHeight` 命令设置行间距。
```elixir
Set LineHeight 1.8
@@ -379,20 +366,19 @@ Set LineHeight 1.8
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/line-height.gif">
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/vhs/examples/line-height.gif">
<img width="600" alt="Example of changing the line height to 1.8" src="https://stuff.charm.sh/vhs/examples/line-height.gif">
<img width="600" alt="将行高更改为 1.8 的示例" src="https://stuff.charm.sh/vhs/examples/line-height.gif">
</picture>
#### Set Typing Speed
#### 设置打字速度
```elixir
Set TypingSpeed 500ms # 500ms
Set TypingSpeed 1s # 1s
```
Set the typing speed of seconds per key press. For example, a typing speed of
`0.1` would result in a `0.1s` (`100ms`) delay between each character being typed.
设置每次按键的打字速度(单位为秒)。例如,打字速度为 `0.1` 时,每输入一个字符之间会有 `0.1s``100ms`)的延迟。
This setting can also be overwritten per command with the `@<time>` syntax.
也可以按命令使用 `@<time>` 语法覆盖此设置。
```elixir
Set TypingSpeed 0.1
@@ -403,32 +389,30 @@ Type@500ms "500ms delay per character"
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/typing-speed.gif">
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/vhs/examples/typing-speed.gif">
<img width="600" alt="Example of using the Type command in VHS" src="https://stuff.charm.sh/vhs/examples/typing-speed.gif">
<img width="600" alt="在 VHS 中使用 Type 命令的示例" src="https://stuff.charm.sh/vhs/examples/typing-speed.gif">
</picture>
#### Set Theme
#### 设置主题
Set the theme of the terminal with the `Set Theme` command. The theme value
should be a JSON string with the base 16 colors and foreground + background.
使用 `Set Theme` 命令设置终端主题。主题值应为包含 base 16 颜色以及前景色和背景色的 JSON 字符串。
```elixir
Set Theme { "name": "Whimsy", "black": "#535178", "red": "#ef6487", "green": "#5eca89", "yellow": "#fdd877", "blue": "#65aef7", "magenta": "#aa7ff0", "cyan": "#43c1be", "white": "#ffffff", "brightBlack": "#535178", "brightRed": "#ef6487", "brightGreen": "#5eca89", "brightYellow": "#fdd877", "brightBlue": "#65aef7", "brightMagenta": "#aa7ff0", "brightCyan": "#43c1be", "brightWhite": "#ffffff", "background": "#29283b", "foreground": "#b3b0d6", "selection": "#3d3c58", "cursor": "#b3b0d6" }
```
<img alt="Example of changing the theme to Whimsy" src="https://stuff.charm.sh/vhs/examples/theme.gif" width="600" />
<img alt="将主题更改为 Whimsy 的示例" src="https://stuff.charm.sh/vhs/examples/theme.gif" width="600" />
You can also set themes by name:
也可以按名称设置主题:
```elixir
Set Theme "Catppuccin Frappe"
```
See the full list by running `vhs themes`, or in [THEMES.md](./THEMES.md).
运行 `vhs themes` 可查看完整列表,或在 [THEMES.md](./THEMES.md) 中查看。
#### Set Padding
#### 设置内边距
Set the padding (in pixels) of the terminal frame with the `Set Padding`
command.
使用 `Set Padding` 命令设置终端边框的内边距(单位为像素)。
```elixir
Set Padding 0
@@ -437,12 +421,12 @@ Set Padding 0
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/padding.gif">
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/vhs/examples/padding.gif">
<img width="600" alt="Example of setting the padding" src="https://stuff.charm.sh/vhs/examples/padding.gif">
<img width="600" alt="设置内边距的示例" src="https://stuff.charm.sh/vhs/examples/padding.gif">
</picture>
#### Set Margin
#### 设置外边距
Set the margin (in pixels) of the video with the `Set Margin` command.
使用 `Set Margin` 命令设置视频的外边距(单位为像素)。
```elixir
Set Margin 60
@@ -452,12 +436,12 @@ Set MarginFill "#6B50FF"
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://vhs.charm.sh/vhs-1miKMtNHenh7O4sv76TMwG.gif">
<source media="(prefers-color-scheme: light)" srcset="https://vhs.charm.sh/vhs-1miKMtNHenh7O4sv76TMwG.gif">
<img width="600" alt="Example of setting the margin" src="https://vhs.charm.sh/vhs-1miKMtNHenh7O4sv76TMwG.gif">
<img width="600" alt="设置外边距的示例" src="https://vhs.charm.sh/vhs-1miKMtNHenh7O4sv76TMwG.gif">
</picture>
#### Set Window Bar
#### 设置窗口栏
Set the type of window bar (Colorful, ColorfulRight, Rings, RingsRight) on the terminal window with the `Set WindowBar` command.
使用 `Set WindowBar` 命令设置终端窗口的窗口栏类型(ColorfulColorfulRightRingsRingsRight)。
```elixir
Set WindowBar Colorful
@@ -466,12 +450,12 @@ Set WindowBar Colorful
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://vhs.charm.sh/vhs-4VgviCu38DbaGtbRzhtOUI.gif">
<source media="(prefers-color-scheme: light)" srcset="https://vhs.charm.sh/vhs-4VgviCu38DbaGtbRzhtOUI.gif">
<img width="600" alt="Example of setting the margin" src="https://vhs.charm.sh/vhs-4VgviCu38DbaGtbRzhtOUI.gif">
<img width="600" alt="设置外边距的示例" src="https://vhs.charm.sh/vhs-4VgviCu38DbaGtbRzhtOUI.gif">
</picture>
#### Set Border Radius
#### 设置圆角半径
Set the border radius (in pixels) of the terminal window with the `Set BorderRadius` command.
使用 `Set BorderRadius` 命令设置终端窗口的圆角半径(单位为像素)。
```elixir
# You'll likely want to add a Margin + MarginFill if you use BorderRadius.
@@ -483,20 +467,20 @@ Set BorderRadius 10
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://vhs.charm.sh/vhs-4nYoy6IsUKmleJANG7N1BH.gif">
<source media="(prefers-color-scheme: light)" srcset="https://vhs.charm.sh/vhs-4nYoy6IsUKmleJANG7N1BH.gif">
<img width="400" alt="Example of setting the margin" src="https://vhs.charm.sh/vhs-4nYoy6IsUKmleJANG7N1BH.gif">
<img width="400" alt="设置外边距的示例" src="https://vhs.charm.sh/vhs-4nYoy6IsUKmleJANG7N1BH.gif">
</picture>
#### Set Framerate
#### 设置帧率
Set the rate at which VHS captures frames with the `Set Framerate` command.
使用 `Set Framerate` 命令设置 VHS 捕获帧的速率。
```elixir
Set Framerate 60
```
#### Set Playback Speed
#### 设置播放速度
Set the playback speed of the final render.
设置最终渲染的播放速度。
```elixir
Set PlaybackSpeed 0.5 # Make output 2 times slower
@@ -506,8 +490,7 @@ Set PlaybackSpeed 2.0 # Make output 2 times faster
#### Set Loop Offset
Set the offset for when the GIF loop should begin. This allows you to make the
first frame of the GIF (generally used for previews) more interesting.
设置 GIF 循环开始的偏移量。这样可以让 GIF 的第一帧(通常用于预览)更有趣。
```elixir
Set LoopOffset 5 # Start the GIF at the 5th frame
@@ -516,7 +499,7 @@ Set LoopOffset 50% # Start the GIF halfway through
#### Set Cursor Blink
Set whether the cursor should blink. Enabled by default.
设置光标是否闪烁。默认启用。
```elixir
Set CursorBlink false
@@ -525,18 +508,14 @@ Set CursorBlink false
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://vhs.charm.sh/vhs-3rMCb80VEkaDdTOJMCrxKy.gif">
<source media="(prefers-color-scheme: light)" srcset="https://vhs.charm.sh/vhs-3rMCb80VEkaDdTOJMCrxKy.gif">
<img width="600" alt="Example of setting the cursor blink." src="https://vhs.charm.sh/vhs-3rMCb80VEkaDdTOJMCrxKy.gif">
<img width="600" alt="设置光标闪烁的示例。" src="https://vhs.charm.sh/vhs-3rMCb80VEkaDdTOJMCrxKy.gif">
</picture>
### Type
Use `Type` to emulate key presses. That is, you can use `Type` to script typing
in a terminal. Type is handy for both entering commands and interacting with
prompts and TUIs in the terminal. The command takes a string argument of the
characters to type.
使用 `Type` 模拟按键。也就是说,你可以使用 `Type` 在终端中脚本化输入。Type 命令既适合输入命令,也适合在终端中与提示符和 TUI(终端用户界面)交互。该命令接受一个字符串参数,表示要输入的字符。
You can set the standard typing speed with [`Set TypingSpeed`](#set-typing-speed)
and override it in places with a `@time` argument.
你可以通过 [`Set TypingSpeed`](#set-typing-speed) 设置标准输入速度,并在特定位置用 `@time` 参数覆盖。
```elixir
# Type something
@@ -546,7 +525,7 @@ Type "Whatever you want"
Type@500ms "Slow down there, partner."
```
Escape single and double quotes with backticks.
用反引号转义单引号和双引号。
```elixir
Type `VAR="Escaped"`
@@ -555,13 +534,12 @@ Type `VAR="Escaped"`
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/type.gif">
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/vhs/examples/type.gif">
<img width="600" alt="Example of using the Type command in VHS" src="https://stuff.charm.sh/vhs/examples/type.gif">
<img width="600" alt="在 VHS 中使用 Type 命令的示例" src="https://stuff.charm.sh/vhs/examples/type.gif">
</picture>
### Keys
Key commands take an optional `@time` and optional repeat `count` for repeating
the key press every interval of `<time>`.
Key 命令接受可选的 `@time` 和可选的重复 `count`,用于每隔 `<time>` 间隔重复按键。
```
Key[@<time>] [count]
@@ -569,7 +547,7 @@ Key[@<time>] [count]
#### Backspace
Press the backspace key with the `Backspace` command.
使用 `Backspace` 命令按下退格键。
```elixir
Backspace 18
@@ -578,13 +556,12 @@ Backspace 18
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/backspace.gif">
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/vhs/examples/backspace.gif">
<img width="600" alt="Example of pressing the Backspace key 18 times" src="https://stuff.charm.sh/vhs/examples/backspace.gif">
<img width="600" alt="按下 Backspace 18 次的示例" src="https://stuff.charm.sh/vhs/examples/backspace.gif">
</picture>
#### Ctrl
You can access the control modifier and send control sequences with the `Ctrl`
command.
你可以通过 `Ctrl` 命令访问 Control 修饰键并发送控制序列。
```elixir
Ctrl+R
@@ -593,12 +570,12 @@ Ctrl+R
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/ctrl.gif">
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/vhs/examples/ctrl.gif">
<img width="600" alt="Example of pressing the Ctrl+R key to reverse search" src="https://stuff.charm.sh/vhs/examples/ctrl.gif">
<img width="600" alt="按下 Ctrl+R 键进行反向搜索的示例" src="https://stuff.charm.sh/vhs/examples/ctrl.gif">
</picture>
#### Enter
Press the enter key with the `Enter` command.
使用 `Enter` 命令按下回车键。
```elixir
Enter 2
@@ -607,12 +584,12 @@ Enter 2
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/enter.gif">
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/vhs/examples/enter.gif">
<img width="600" alt="Example of pressing the Enter key twice" src="https://stuff.charm.sh/vhs/examples/enter.gif">
<img width="600" alt="按下 Enter 键两次的示例" src="https://stuff.charm.sh/vhs/examples/enter.gif">
</picture>
#### Arrow Keys
Press any of the arrow keys with the `Up`, `Down`, `Left`, `Right` commands.
使用 `Up``Down``Left``Right` 命令按下任意方向键。
```elixir
Up 2
@@ -628,12 +605,12 @@ Type "A"
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/arrow.gif">
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/vhs/examples/arrow.gif">
<img width="600" alt="Example of pressing the arrow keys to navigate text" src="https://stuff.charm.sh/vhs/examples/arrow.gif">
<img width="600" alt="按下方向键在文本中导航的示例" src="https://stuff.charm.sh/vhs/examples/arrow.gif">
</picture>
#### Tab
Enter a tab with the `Tab` command.
使用 `Tab` 命令输入制表符。
```elixir
Tab@500ms 2
@@ -642,12 +619,12 @@ Tab@500ms 2
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/tab.gif">
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/vhs/examples/tab.gif">
<img width="600" alt="Example of pressing the tab key twice for autocomplete" src="https://stuff.charm.sh/vhs/examples/tab.gif">
<img width="600" alt="按下 Tab 键两次进行自动补全的示例" src="https://stuff.charm.sh/vhs/examples/tab.gif">
</picture>
#### Space
Press the space bar with the `Space` command.
使用 `Space` 命令按下空格键。
```elixir
Space 10
@@ -656,12 +633,12 @@ Space 10
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/space.gif">
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/vhs/examples/space.gif">
<img width="600" alt="Example of pressing the space key" src="https://stuff.charm.sh/vhs/examples/space.gif">
<img width="600" alt="按下空格键的示例" src="https://stuff.charm.sh/vhs/examples/space.gif">
</picture>
#### Page Up / Down
Press the Page Up / Down keys with the `PageUp` or `PageDown` commands.
使用 `PageUp``PageDown` 命令按下 Page Up / Page Down 键。
```elixir
PageUp 3
@@ -670,9 +647,7 @@ PageDown 5
#### Scroll Up / Down
Scroll the terminal viewport directly with `ScrollUp` and `ScrollDown`.
Both commands use the same optional `@time` and repeat count shape as other
repeatable key commands: `ScrollUp[@<time>] [count]`.
使用 `ScrollUp``ScrollDown` 直接滚动终端视口。两个命令都使用与其他可重复按键命令相同的可选 `@time` 和重复次数形式:`ScrollUp[@<time>] [count]`
```elixir
ScrollUp 10
@@ -682,13 +657,7 @@ ScrollDown@100ms 12
### Wait
The `Wait` command allows you to wait for something to appear on the screen.
This is useful when you need to wait on something to complete, even if you don't
know how long it'll take, while including it in the recording like a spinner or
loading state.
The command takes a regular expression as an argument, and optionally allows to
set the duration to wait and if you want to check the whole screen or just the
last line (the scope).
`Wait` 命令允许你等待屏幕上出现某些内容。当你需要等待某事完成(即使不知道需要多久),同时又想在录制中包含它(例如旋转指示器或加载状态)时,这会很有用。该命令接受一个正则表达式作为参数,并可选择设置等待时长,以及是检查整个屏幕还是仅检查最后一行(范围)。
```elixir
Wait
@@ -699,15 +668,11 @@ Wait@10ms /World/
Wait+Line@10ms /World/
```
The default regular expression is `/>$/`, the wait timeout is `15s`, and the
default scope is `Line`.
默认正则表达式为 `/>$/`,等待超时为 `15s`,默认范围为 `Line`
### Sleep
The `Sleep` command allows you to continue capturing frames without interacting
with the terminal. This is useful when you need to wait on something to
complete while including it in the recording like a spinner or loading state.
The command takes a number argument in seconds.
`Sleep` 命令允许你在不与终端交互的情况下继续捕获帧。当你需要等待某事完成,同时又想在录制中包含它(例如旋转指示器或加载状态)时,这会很有用。该命令接受以秒为单位的数字参数。
```elixir
Sleep 0.5 # 500ms
@@ -718,16 +683,13 @@ Sleep 1s # 1s
### Hide
The `Hide` command instructs VHS to stop capturing frames. It's useful to pause
a recording to perform hidden commands.
`Hide` 命令指示 VHS 停止捕获帧。适用于暂停录制以执行隐藏的命令。
```elixir
Hide
```
This command is helpful for performing any setup and cleanup required to record
a GIF, such as building the latest version of a binary and removing the binary
once the demo is recorded.
该命令有助于执行录制 GIF 所需的任何设置和清理工作,例如构建二进制文件的最新版本,并在演示录制完成后删除该二进制文件。
```elixir
Output example.gif
@@ -751,8 +713,7 @@ Enter
### Show
The `Show` command instructs VHS to begin capturing frames, again. It's useful
after a `Hide` command to resume frame recording for the output.
`Show` 命令指示 VHS 重新开始捕获帧。在 `Hide` 命令之后很有用,可恢复输出画面的帧录制。
```elixir
Hide
@@ -764,12 +725,12 @@ Type "You will see this being typed."
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://stuff.charm.sh/vhs/examples/hide.gif">
<source media="(prefers-color-scheme: light)" srcset="https://stuff.charm.sh/vhs/examples/hide.gif">
<img width="600" alt="Example of typing something while hidden" src="https://stuff.charm.sh/vhs/examples/hide.gif">
<img width="600" alt="在隐藏状态下输入内容的示例" src="https://stuff.charm.sh/vhs/examples/hide.gif">
</picture>
### Screenshot
The `Screenshot` command captures the current frame (png format).
`Screenshot` 命令捕获当前帧(png 格式)。
```elixir
# At any point...
@@ -778,7 +739,7 @@ Screenshot examples/screenshot.png
### Copy / Paste
The `Copy` and `Paste` copy and paste the string from clipboard.
`Copy` `Paste` 从剪贴板复制和粘贴字符串。
```elixir
Copy "https://github.com/charmbracelet"
@@ -789,7 +750,7 @@ Paste
### Env
`Env` command sets the environment variable via key-value pair.
`Env` 命令通过键值对设置环境变量。
```elixir
Env HELLO "WORLD"
@@ -801,7 +762,7 @@ Sleep 1s
### Source
The `source` command allows you to execute commands from another tape.
`source` 命令允许你执行来自另一条 tape 的命令。
```elixir
Source config.tape
@@ -811,53 +772,51 @@ Source config.tape
## Continuous Integration
You can hook up VHS to your CI pipeline to keep your GIFs up-to-date with
the official VHS GitHub Action:
你可以将 VHS 接入 CI 流水线,通过官方 VHS GitHub Action 保持 GIF 与代码同步更新:
> [⚙️ charmbracelet/vhs-action](https://github.com/charmbracelet/vhs-action)
VHS can also be used for integration testing. Use the `.txt` or `.ascii` output
to generate golden files. Store these files in a git repository to ensure there
are no diffs between runs of the tape file.
VHS 也可用于集成测试。使用 `.txt` `.ascii` 的输出
来生成黄金文件(golden files)。将这些文件存放在 git 仓库中,以确保
多次运行磁带文件时不会出现 diff。
```elixir
Output golden.ascii
```
## Syntax Highlighting
## 语法高亮
Theres a tree-sitter grammar for `.tape` files available for editors that
support syntax highlighting with tree-sitter:
面向支持 tree-sitter 语法高亮的编辑器,现已提供 `.tape` 文件的 tree-sitter 语法:
> [🌳 charmbracelet/tree-sitter-vhs](https://github.com/charmbracelet/tree-sitter-vhs)
It works great with Neovim, Emacs, and so on!
NeovimEmacs 等编辑器中效果很好!
## Contributing
## 参与贡献
See [contributing][contribute].
请参阅 [参与贡献][contribute]
[contribute]: https://github.com/charmbracelet/vhs/contribute
## Feedback
## 反馈
Wed love to hear your thoughts on this project. Feel free to drop us a note!
我们很想听听你对本项目的想法。欢迎随时给我们留言!
- [Twitter](https://twitter.com/charmcli)
- [The Fediverse](https://mastodon.social/@charmcli)
- [Discord](https://charm.sh/chat)
## License
## 许可证
[MIT](https://github.com/charmbracelet/vhs/raw/main/LICENSE)
---
Part of [Charm](https://charm.sh).
属于 [Charm](https://charm.sh).
<a href="https://charm.sh/">
<img
alt="The Charm logo"
alt="Charm 标志"
width="400"
src="https://stuff.charm.sh/charm-badge.jpg"
/>