在 Linux 下保存 cmatrix 的截图,常见有几种方式,按是否保存为图片和是否保留动画效果来区分。
scrot(推荐)适合保存当前终端中 cmatrix 的运行画面。
sudo apt install scrot # Debian/Ubuntu
# 或
sudo dnf install scrot # Fedora
# 或
sudo pacman -S scrot # Arch
运行 cmatrix 后,在另一个终端执行:
scrot cmatrix.png
或延迟截图(给你时间切回 cmatrix):
scrot -d 3 cmatrix.png
gnome-screenshot如果你用的是 GNOME 桌面:
gnome-screenshot -d 3
-d 3 表示 3 秒后截图。
import(ImageMagick)sudo apt install imagemagick
import cmatrix.png
然后点击 cmatrix 所在窗口即可。
如果你只想要字符内容(而不是图片):
cmatrix > cmatrix.txt
⚠️ 注意:
asciinema(推荐,字符终端录制)sudo apt install asciinema
asciinema rec cmatrix.cast
结束后按 Ctrl+D,可回放:
asciinema play cmatrix.cast
或上传到 https://asciinema.org
使用 ffmpeg + x11grab:
ffmpeg -video_size 800x600 -framerate 15 -f x11grab \
-i :0.0+100,200 -t 5 cmatrix.gif
参数说明:
800x600:窗口大小+100,200:屏幕偏移-t 5:录制 5 秒如果你是在 Ctrl+Alt+F3 这种纯终端:
fbcatsudo apt install fbcat
fbcat > cmatrix.ppm
然后用 ImageMagick 转换:
convert cmatrix.ppm cmatrix.png
| 需求 | 推荐方式 |
|---|---|
| 保存静态截图 | scrot |
| 保留动画 | asciinema |
| 想要 GIF | ffmpeg |
| 纯 TTY | fbcat |
| 只要字符 | 重定向 > |
如果你愿意,可以告诉我:
我可以给你一条最适合你环境的命令。