There are various ways to create animated GIFs for terminal output. Three methods that can be used on Linux (in this case Ubuntu) are described below.
This is probably the easiest way. The disadvantage of this method is that when I tried to record an animation of a progress bar created with the Python Rich library, it didn't show up.
Asciinema can be be installed with pip install asciinema