Skip to main content

TermCap

测试 文档 PyPI

TermCap 是一个 Python 终端录制与渲染工具:把 PTY 会话保存为 asciicast v2,并输出 SVG 动画、静态 SVG 帧或 GIF。

核心能力

  • 交互 shell 与单命令 PTY 录制
  • exec wrapper:运行原命令时自动保存 CAST,并可直接渲染 SVG/GIF
  • ChatEnv profile 可管理默认执行环境,自动 source ChatArch 入口脚本
  • 兼容 asciinema 的 .cast 格式
  • ANSI 颜色、光标、文本样式和宽字符渲染
  • 模板化 SVG 动画与 16 套内置主题
  • CAST→SVG、CAST→GIF、SVG→GIF
  • 关键帧确定性采样和 Chrome viewport 自动校正

TermCap 终端录制导出 GIF 示例

查看 SVG · 查看完整生成命令

安装

TermCap 支持 Linux、macOS 和 BSD,需要 Python 3.10 或更高版本。GIF 导出需要 Google Chrome。

python -m pip install termcap
termcap --version

最短工作流

termcap record demo.cast -g 80x20
termcap render demo.cast demo.svg
termcap render demo.cast demo.gif --format gif

录制单条命令:

termcap record tests.cast -g 100x24 -c "python -m pytest -q"

像命令 wrapper 一样执行并录制,同时渲染 SVG:

termcap exec -g 96x16 --media-output hello.svg -- python3 -c 'print("hello")'

配置默认执行环境入口:

mkdir -p ~/.chatarch/config/termcap/exec-env.d
printf 'source ~/.nvm/nvm.sh\n' > ~/.chatarch/config/termcap/exec-env.sh
chatenv set TERMCAP_EXEC_ENV_SCRIPTS='~/.chatarch/config/termcap/exec-env.sh'

已有 SVG 转 GIF:

termcap svg2gif demo.svg demo.gif --speed 1 --loop 0

文档开发

python -m pip install -e '.[dev,docs]'
mkdocs serve
mkdocs build --strict

许可证

MIT License

Metadata

Release files for termcap 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for termcap 0.2.4
File Size Uploaded
termcap-0.2.4.tar.gz 149.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for termcap 0.2.4
File Interpreter ABI Platform
termcap-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 305.0 kB

Release files / termcap-0.2.4.tar.gz

Download URL termcap-0.2.4.tar.gz
Size 149.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8010d5ec96a3120c5dcdba2eeb1e992985f99cdabb9c94800c9d04daa3b2ed4b
BLAKE2b-256 checksum
How to use checksums
a586637017190767d196587e38505ad864cc85d520872e93787535ffbbc24c4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 20, 2026.

Transparency log

Release files / termcap-0.2.4-py3-none-any.whl

Download URL termcap-0.2.4-py3-none-any.whl
Size 155.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87cf90a7f385694a2bdea20ad372a70e59f39768d8f629b7dbfdb4a34b3f3cfb
BLAKE2b-256 checksum
How to use checksums
3e65b4819232bcee30e32f22de1019a4620c043c8fcde3d0dcf5c5ec4dfdb55a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 20, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page