asciinema

安装

1
brew install asciinema

使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
❯ asciinema --help
usage: asciinema [-h] [--version] {rec,play,cat,upload,auth} ...

Record and share your terminal sessions, the right way.

positional arguments:
{rec,play,cat,upload,auth}
rec Record terminal session
play Replay terminal session
cat Print full output of terminal session
upload Upload locally saved terminal session to asciinema.org
auth Manage recordings on asciinema.org account

optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit

example usage:
Record terminal and upload it to asciinema.org:
asciinema rec
Record terminal to local file:
asciinema rec demo.cast
Record terminal and upload it to asciinema.org, specifying title:
asciinema rec -t "My git tutorial"
Record terminal to local file, limiting idle time to max 2.5 sec:
asciinema rec -i 2.5 demo.cast
Replay terminal recording from local file:
asciinema play demo.cast
Replay terminal recording hosted on asciinema.org:
asciinema play https://asciinema.org/a/difqlgx86ym6emrmd8u62yqu8
Print full output of recorded session:
asciinema cat demo.cast

For help on a specific command run:
asciinema <command> -h

生成的cast文件,是unicode编码的纯文本文件

分享与展示

asciinema上传后,会生成分享连接
嵌入播放器,注意id和src的设置:

1
<script src="https://asciinema.org/a/Jxm2xa1EAZEaohDP3816av5is.js" id="asciicast-Jxm2xa1EAZEaohDP3816av5is" data-speed="5" data-theme="monokai" data-rows="20" async></script>

许多参数可以调节,比如调节速度和主题为data-speed="2” data-theme="tango”

1
<script src="https://asciinema.org/a/Jxm2xa1EAZEaohDP3816av5is.js" id="asciicast-Jxm2xa1EAZEaohDP3816av5is" data-speed="2" data-theme="tango" data-rows="20" async></script>

参考链接:https://asciinema.org/docs/embedding