vhs

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

VHS — Terminal Recorder

VHS — 终端录制工具

VHS records terminal sessions from declarative
.tape
files. Produces GIF, MP4, or WebM. No screen recording needed — deterministic and reproducible.
VHS 可通过声明式的
.tape
文件录制终端会话,输出格式支持GIF、MP4或WebM。无需屏幕录制——录制结果可预测且可重复生成。

Install

安装

bash
scoop install vhs    # Windows
brew install vhs     # macOS
Requires
ffmpeg
(for video encoding).
scoop install ffmpeg
if missing.
bash
scoop install vhs    # Windows
brew install vhs     # macOS
需要依赖
ffmpeg
(用于视频编码)。如果未安装,可执行
scoop install ffmpeg
进行安装。

Quick Start

快速开始

bash
undefined
bash
undefined

Create example tape

创建示例tape文件

vhs new demo.tape
vhs new demo.tape

Record

开始录制

vhs demo.tape
vhs demo.tape

Validate without running

验证tape文件(无需执行)

vhs validate demo.tape
vhs validate demo.tape

Publish to vhs.charm.sh (get shareable URL)

发布到vhs.charm.sh(获取可分享链接)

vhs publish demo.gif
undefined
vhs publish demo.gif
undefined

Tape File Syntax

Tape文件语法

Output

输出设置

tape
Output demo.gif                    # GIF (default, best for READMEs)
Output demo.mp4                    # MP4 video
Output demo.webm                   # WebM video
Multiple
Output
lines = multiple formats from one tape.
tape
Output demo.gif                    # GIF(默认格式,最适合README)
Output demo.mp4                    # MP4视频
Output demo.webm                   # WebM视频
多个
Output
配置行可让单个tape文件同时生成多种格式。

Settings

基础设置

tape
Set Shell "bash"                   # Shell to use
Set FontSize 14                    # Font size (default 22 — too large for most)
Set FontFamily "JetBrains Mono"    # Font family
Set Width 1200                     # Terminal width in pixels
Set Height 600                     # Terminal height in pixels
Set Padding 15                     # Padding around terminal
Set TypingSpeed 50ms               # Delay between keystrokes (default 50ms)
Set Theme "Dracula"                # Color theme (see Themes below)
Set Framerate 30                   # GIF framerate
Set PlaybackSpeed 1.0              # Playback speed multiplier
Set LoopOffset 80%                 # Where GIF loop restarts (% from end)
Set WindowBar "Colorful"           # Window bar: Rings, RingsRight, Colorful, ColorfulRight
Set WindowBarSize 40               # Window bar height in pixels
Set BorderRadius 8                 # Terminal border radius
Set MarginFill "#1a1a2e"           # Background color outside terminal
Set Margin 20                      # Margin size (needs MarginFill)
tape
Set Shell "bash"                   # 使用的Shell
Set FontSize 14                    # 字体大小(默认22,对大多数场景来说过大)
Set FontFamily "JetBrains Mono"    # 字体家族
Set Width 1200                     # 终端宽度(像素)
Set Height 600                     # 终端高度(像素)
Set Padding 15                     # 终端内边距
Set TypingSpeed 50ms               # 按键间隔(默认50ms)
Set Theme "Dracula"                # 配色主题(见下方主题列表)
Set Framerate 30                   # GIF帧率
Set PlaybackSpeed 1.0              # 播放速度倍数
Set LoopOffset 80%                 # GIF循环起始位置(从结尾算起的百分比)
Set WindowBar "Colorful"           # 窗口栏样式:Rings、RingsRight、Colorful、ColorfulRight
Set WindowBarSize 40               # 窗口栏高度(像素)
Set BorderRadius 8                 # 终端边框圆角
Set MarginFill "#1a1a2e"           # 终端外部背景色
Set Margin 20                      # 终端外边距(需配合MarginFill使用)

Commands

命令指令

tape
Type "echo hello"                  # Type characters
Type@100ms "slow typing"           # Type with custom speed
Enter                              # Press Enter
Enter 3                            # Press Enter 3 times
Sleep 2s                           # Wait 2 seconds
Sleep 500ms                        # Wait 500 milliseconds
tape
Type "echo hello"                  # 输入字符
Type@100ms "slow typing"           # 自定义输入速度
Enter                              # 按下回车键
Enter 3                            # 连续按3次回车键
Sleep 2s                           # 等待2秒
Sleep 500ms                        # 等待500毫秒

Special keys

特殊按键

Backspace 5 # Delete 5 chars Tab # Tab completion Ctrl+C # Interrupt Ctrl+L # Clear screen Up # Arrow up (history) Down # Arrow down Left 3 # Move cursor left 3 Right 3 # Move cursor right 3 Escape # Escape key Space # Space key PageUp # Page up PageDown # Page down
Backspace 5 # 删除5个字符 Tab # 制表补全 Ctrl+C # 中断当前操作 Ctrl+L # 清屏 Up # 上箭头(历史命令) Down # 下箭头 Left 3 # 光标左移3位 Right 3 # 光标右移3位 Escape # 退出键 Space # 空格键 PageUp # 上翻页 PageDown # 下翻页

Visibility

可见性控制

Hide # Hide commands from output Show # Show commands again
undefined
Hide # 隐藏命令,不显示在录制结果中 Show # 重新显示命令
undefined

Require

依赖检查

tape
Require git                        # Fail if git not in PATH
Require node
tape
Require git                        # 如果git不在PATH中则终止执行
Require node

Recommended Defaults

推荐默认配置

For README demos and documentation:
tape
Output demo.gif
Set Shell "bash"
Set FontSize 14
Set Width 1100
Set Height 600
Set Theme "Dracula"
Set TypingSpeed 30ms
Set Padding 15
Set WindowBar "Colorful"
Set BorderRadius 8
适用于README演示和文档编写的配置:
tape
Output demo.gif
Set Shell "bash"
Set FontSize 14
Set Width 1100
Set Height 600
Set Theme "Dracula"
Set TypingSpeed 30ms
Set Padding 15
Set WindowBar "Colorful"
Set BorderRadius 8

Patterns

常用场景示例

Simple command showcase

简单命令展示

tape
Output demo.gif
Set Shell "bash"
Set FontSize 14
Set Width 1100
Set Height 600
Set Theme "Dracula"
Set TypingSpeed 30ms
Set Padding 15

Type "my-tool --help"
Enter
Sleep 3s

Type "my-tool run --input data.json"
Enter
Sleep 5s
tape
Output demo.gif
Set Shell "bash"
Set FontSize 14
Set Width 1100
Set Height 600
Set Theme "Dracula"
Set TypingSpeed 30ms
Set Padding 15

Type "my-tool --help"
Enter
Sleep 3s

Type "my-tool run --input data.json"
Enter
Sleep 5s

Complex commands (use a wrapper script)

复杂命令处理(使用包装脚本)

VHS tape files don't support shell quoting well. For complex commands with quotes, pipes, or multi-line args, write a helper script:
bash
undefined
VHS的tape文件对Shell引号的支持不佳。对于包含引号、管道符或多行参数的复杂命令,建议编写辅助脚本:
bash
undefined

demo-run.sh

demo-run.sh

#!/bin/bash echo "Running analysis..." my-tool analyze --format json | jq '.results[] | .name'

```tape
Type "bash demo-run.sh"
Enter
Sleep 10s
#!/bin/bash echo "Running analysis..." my-tool analyze --format json | jq '.results[] | .name'

```tape
Type "bash demo-run.sh"
Enter
Sleep 10s

Hide setup, show the interesting part

隐藏准备步骤,展示核心内容

tape
undefined
tape
undefined

Setup (hidden from recording)

准备步骤(不会出现在录制结果中)

Hide Type "cd /tmp/demo-project" Enter Type "export DEMO_MODE=1" Enter Sleep 1s Show
Hide Type "cd /tmp/demo-project" Enter Type "export DEMO_MODE=1" Enter Sleep 1s Show

Visible demo starts here

可见的演示从这里开始

Type "my-tool init" Enter Sleep 3s
undefined
Type "my-tool init" Enter Sleep 3s
undefined

Before/after comparison

前后对比展示

tape
Type "# Before:"
Enter
Type "cat config.yaml"
Enter
Sleep 3s

Type "# After running fix:"
Enter
Type "my-tool fix config.yaml"
Enter
Sleep 3s

Type "cat config.yaml"
Enter
Sleep 3s
tape
Type "# Before:"
Enter
Type "cat config.yaml"
Enter
Sleep 3s

Type "# After running fix:"
Enter
Type "my-tool fix config.yaml"
Enter
Sleep 3s

Type "cat config.yaml"
Enter
Sleep 3s

Recording live (interactive)

交互式实时录制

bash
undefined
bash
undefined

Record your terminal actions into a tape file

将终端操作录制为tape文件

vhs record > my-session.tape
vhs record > my-session.tape

Then edit the tape to clean up timing, add sleeps, etc.

之后可以编辑tape文件,调整时间、添加等待等

vhs my-session.tape
undefined
vhs my-session.tape
undefined

Themes

配色主题

Popular themes for demos:
ThemeStyle
Dracula
Dark purple — high contrast, popular
Catppuccin Mocha
Dark warm — modern, easy on eyes
Tokyo Night
Dark blue — clean
Nord
Dark muted — professional
Gruvbox Dark
Dark warm/retro
Solarized Dark
Classic
GitHub Dark
Familiar to devs
One Dark
VS Code-like
List all:
vhs themes
适用于演示的热门主题:
主题风格
Dracula
深紫色系——高对比度,广受欢迎
Catppuccin Mocha
深暖色调——现代风格,护眼
Tokyo Night
深蓝色系——简洁干净
Nord
深暗色系——专业感
Gruvbox Dark
深暖复古风
Solarized Dark
经典深色主题
GitHub Dark
开发者熟悉的GitHub深色风格
One Dark
类似VS Code的深色主题
查看所有主题:
vhs themes

Tips

实用技巧

  1. FontSize 14 — default 22 is way too large for most demos
  2. TypingSpeed 25-40ms — 50ms default feels slow; 25ms is snappy
  3. Sleep after Enter — always add
    Sleep
    after commands to let output render
  4. Long commands — use wrapper scripts, VHS quoting is fragile
  5. GIF size — keep under 5MB for GitHub READMEs; reduce Framerate, Height, or duration
  6. Multiple outputs — one tape can produce
    .gif
    +
    .mp4
    simultaneously
  7. Publish
    vhs publish demo.gif
    gives a shareable URL on vhs.charm.sh
  8. Validate first
    vhs validate demo.tape
    catches syntax errors without recording
  1. 字体大小设为14——默认22对大多数演示来说过大
  2. 输入速度设为25-40ms——默认50ms偏慢,25ms更流畅
  3. 执行命令后添加Sleep——命令执行后务必添加
    Sleep
    ,等待输出完全渲染
  4. 复杂命令用脚本——VHS的引号支持有限,复杂命令建议用包装脚本
  5. 控制GIF大小——GitHub README中建议保持在5MB以内;可通过降低帧率、高度或时长来压缩
  6. 多格式输出——单个tape文件可同时生成
    .gif
    .mp4
    格式
  7. 分享录制结果——
    vhs publish demo.gif
    可生成vhs.charm.sh上的可分享链接
  8. 先验证再录制——
    vhs validate demo.tape
    可提前检查语法错误,无需实际录制
  9. 终端尺寸适配——如果输出换行异常,可增大Width或减小FontSize

Gotchas

  • No shell expansion in Type
    Type "echo $HOME"
    types the literal string; variable expansion happens when bash executes it, not in the tape
  • Quoting — avoid nested quotes in Type. Use wrapper scripts for complex commands
  • Windows paths — use forward slashes in Type strings (
    C:/dev/...
    not
    C:\dev\...
    )
  • Long recordings — GIFs get huge fast. Keep demos under 30 seconds. Use
    Set PlaybackSpeed 2.0
    to compress
  • Terminal size — if output wraps weird, increase Width or reduce FontSize