asciinema是一套用于记录、重放和共享终端会话的工具
介绍
- 源码
- docs
- 核心
- asciicast v2 是一种基于newline-delimited JSON 的终端会话文件格式,由 asciinema CLI(2.0 及更高版本)记录,记录 the event stream,格式
- header包含记录元数据的 JSON 编码对象,包括- 
- Required header attributes
- Optional header attributes
- timestamp开始时间戳,秒
- duration
- idle_time_limit
- command
- title
- env键值对
- theme
 
 
- Event stream事件流- [time, code, data]- 
- time(浮点数)表示事件发生的时间,用录音会话开始后的秒数表示
- code(字符串)指定事件类型,可选- o、- i、- m、- r之一- 
- ooutput, data written to a terminal
- iinput, data read from a terminal
- mmarker, 参考
- rresize
 
- data(任意)事件特定数据
 
 
 
{"version": 2, "width": 80, "height": 24, "timestamp": 1504467315, "title": "Demo", "env": {"TERM": "xterm-256color", "SHELL": "/bin/zsh"}}
[0.248848, "o", "\u001b[1;31mHello \u001b[32mWorld!\u001b[0m\n"]
[1.001376, "o", "That was ok\rThis is better."]
[1.500000, "m", ""]
[2.143733, "o", "Now... "]
[4.050000, "r", "80x24"]
[6.541828, "o", "Bye!"]
安装
# ubuntu
sudo apt install asciinema
# mac
brew install asciinema
使用
# 录制
asciinema rec demo.cast
# 回放
asciinema play demo.cast
# 分享,支持公开和私有,执行后可以在公网访问
asciinema auth
asciinema upload demo.cast
- 支持将其嵌入 web 页面中,参考
- 支持自己搭建HTML、HTML另一个链接或服务器
- 生成 jif 图片 agg demo.cast first.gif
快捷键
播放时,支持使用快捷键,参考
- space播放/暂停
- f切换全屏模式
- ← / →倒带 5 秒 / 快进 5 秒
- Shift + ← / Shift + →倒带 10%/快进 10
- [左侧方括号,倒回上一个标记
- ]右方括号,快进到下一个标记
- 0, 1, 2 ... 9跳转到 0%、10%、20% … 90%
- .每次播放一帧录像(暂停时)