如何在linux下录制terminal操作?

相关包:

  • ttyrec:
    ttyrec is a tty recorder. Recorded data can be played back with the included ttyplay command.
    ttyrec is just a derivative of script command for recording timing information with microsecond accuracy as well.
    It can record emacs -nw, vi, lynx, or any programs running on tty.

  • imagemagick:
    Use ImageMagick to create, edit, compose, or convert bitmap images.
    It can read and write images in a variety of formats (over 200).
    Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.

  • python-opster:
    Opster is a command line options parser, intended to make writing command line applications easy and painless.

安装方法:

sudo apt-get install ttyrec

sudo apt-get install imagemagick

sudo apt-get install python-opster

tty2gif.py

下载地址:https://bitbucket.org/antocuni/tty2gif/raw/61d5596c916512ce5f60fcc34f02c686981e6ac6/tty2gif.py

注意:运行的python环境为python2(此为第一个坑)

执行过程

  • 运行命令ttyrec(不是ttyprec参考文章中写错了,此为第二个坑)
  • 回车开始录制,后台会运行记录工具
  • exit或ctrl+d停止录制
  • ttyrec 默认会在主目录下创建一个ttyrecord的文件

后续处理

  • 回放
    终端输入: ttyplay ttyrecord

  • 转成gif

python tty2gif.py typing ttyrecord

如果有错误,检查一下你是否有安装 python-opster 包

sudo apt-get install xdotool
export WINDOWID=$(xdotool getwindowfocus)
  • 将所有gif整合成一个example.gif
convert -delay 25 -loop 0 *.gif example.gif

注: convert有很多参数,在下一篇文章中详细分析,通过修改参数可以定制我们的转换出来的效果。

参考文章:
1、ttyrec & ttyplay - Linux记录播放终端会话
2、如何在 Linux 上录制你的终端操作

posted @ 2017-10-12 14:16  bingo彬哥  阅读(825)  评论(0编辑  收藏  举报
本站总访问量