apt install ttyrec ttygif
ttyrec
now record working until press CTRL+D
this produces a tty.gif
files
open a terminal window with size you need
export WINDOWID=$(xdotool getwindowfocus)
now you can create tty.gif
using
ttygif ttyrecord
if you receive cache resource exhausted
error may need to tune /etc/ImageMagick-6/policy.xml
file as described in this issue