当前位置:网站首页>asciinema 搭配 asciicast2gif 实现高效的命令行终端录制能力
asciinema 搭配 asciicast2gif 实现高效的命令行终端录制能力
2022-06-24 15:33:00 【独家雨天】
官网地址 https://asciinema.org/
对于程序员来说,有些时候需要分享下代码操作:
常规的录屏软件分享痛点:
- 录屏软件录制的视频存储大小很大,并且操作麻烦,录制效果还容易不清晰
- 通常需要额外的启动一个比较大的应用,系统资源占用大
而 asciinema 软件专注于命令行终端的录制效果,简直是终端录屏神器,这次碰到感觉有种相见恨晚的感觉。
先放几张官网上的录制效果图:
具体如何的操作asciinema工具 ,就不赘述,可以参考GitHub地址说明。asciinema/asciinema: Terminal session recorder 熟悉各个命令行参数的用法。
痛点
虽然 asciinema 很棒,但是cast的格式,在编写Markdown的时候,并不是很通用。虽然官网提供了一些播放方案,但是终究不是很友好。
无奈…只能选择Gif这种,更加通用的形式。
解决方案
好在,网上已经有大神,提供了将cast这种文件格式,转换成gif的命令行工具。
asciinema/asciicast2gif: Generate GIF animations from asciicasts (asciinema recordings)
感兴趣的同学可以下载体验一番。
由于asciicast2gif 的安装依赖了不少的npm仓库,个人感觉配置起来不是特别的顺利,因此采用了易用性更高的Docker安装方式。
编写脚本实现自动化
希望能够在每次录制完终端命令后,自动的转换为gif文件。编写一个脚本,在录制之后,自动的利用asciicast2gif 工具转换成 gif 格式。
#!/bin/bash
rec_date_time=$(date +%F_%H-%M-%S)
asciinema rec ${rec_date_time}.cast
# the next line only needed when you install asciicast2gif by docker
alias asciicast2gif='docker run --rm -v $PWD:/data asciinema/asciicast2gif -S 1'
asciicast2gif -S 1 ${rec_date_time}.cast ${rec_date_time}.gif
如果再傻瓜一点,就在 ‘~/.bashrc’ 文件中,增加一个别名rec来执行上面的这个bash
脚本。比如:
alias rec='sh /opt/script/auto_rec_asciinema_to_gif.sh'
最终实现效果
只要在终端输入 rec 命令,就可以实现录屏和自动的gif图片转换能力。

如果觉得对你有帮助,点个赞再走呗~
边栏推荐
- Two way combination of business and technology to build a bank data security management system
- Oracle RAC configuration multipathing
- Do you really know the difference between H5 and applet?
- Improving the classification of motor imagery by combining EEG and MEG signals in BCI
- Design of CAN bus controller based on FPGA (Part 2)
- 兴业证券靠谱吗?开证券账户安全吗?
- 还在担心漏测吗?快来使用jacoco统计下代码覆盖率
- Which securities company is better and safer for great wisdom to choose when opening an account
- At? Let's blow the air conditioner together!
- 手机注册股票开户 炒股开户安全吗
猜你喜欢

CVPR 2022 - Interpretation of selected papers of meituan technical team

Left hand code, right hand open source, part of the open source road

刚刚阿里面软件测试回来,3+1面任职阿里P7,年薪28*15薪

Wide measuring range of jishili electrometer
Step by step introduction to sqlsugar based development framework (9) -- Realizing field permission control with WinForm control

【C语言刷题——Leetcode12道题】带你起飞,飞进垃圾堆
Oracle RAC configuration multipathing

Do you really know the difference between H5 and applet?

为什么企业实施WMS仓储管理系统很容易失败

List of PostgreSQL
随机推荐
The 30 pictures bring the network protocol layer by layer to life. It's really fragrant!
How to modify the login user name of easynvr video monitoring system?
安装wireshark时npcap怎么都安装不成功,建议先用winpcap
Redis highly available
Monitoring and warning | is the website attacked?
Is it safe to open an account in flush? What preparation is needed
Arrays API
东方财富哪个开户更安全,更好点
Remember: never use UTF-8 in MySQL
Working with collections
CVPR 2022 - Interpretation of selected papers of meituan technical team
Kubernetes practical tips: using ksniff to capture packets
[parameter configuration tutorial] how should the parameters in the RTMP streaming camera be configured?
Allwinner a40i industrial Internet gateway design scheme, smart site, smart city core gateway
[log service CLS] initial experience of Tencent cloud CLS log service
Record the range of data that MySQL update will lock
CVPR2022 | 可精簡域適應
Laravel8 uses faker to call factory to fill data
大智慧开户要选什么证券公司比较好,更安全一点
FPGA based analog I ² C protocol system design (medium)