Navigate back to the homepage

How To Play GIF In Your Terminal

Ayush Gupta
June 27th, 2019 · 1 min read

You might have seen ASCII arts on your terminal like the ones below when installing a new module/library in your system. Some developers (or even you might have) configure a static ASCII art which appear when they open their terminal. But have you ever seen a GIF running in your Swiss Army knife like terminal? 👀 That would give life and a personality to your terminal!

Alt text

Nothing is impossible. Now even playing a GIF on your terminal is possible. GIF has been around us for long 31 years (seriously? 😲) and what better time it is to see GIF in your terminal.

Getting Started

Requires Python 3 (with setuptools and pip), zlib, libjpeg, and ffmpeg, other dependencies are installed by

Install dependencies

1# Debian based distros
2sudo apt-get install ffmpeg zlib* libjpeg* python3-setuptools
4# Mac
5brew install ffmpeg zlib libjpeg python

Your Python environment may need these installation tools -

1sudo easy_install3 pip
3# This should enable a pre-built Pillow wheel to be installed, otherwise
4# you may need to install Python, zlib, and libjpeg development libraries
5# so Pillow can compile from source.
7pip3 install --user wheel

Install gif-for-cli

1pip3 install --user gif-for-cli

Or download this repo and run:

1python3 install --user

The gif-for-cli command will likely be installed into ~/.local/bin or similar, you may need to put that directory in your $PATH by adding this to your .profile:

1# Linux
2if [ -d "$HOME/.local/bin" ] ; then
3 PATH="$HOME/.local/bin:$PATH"
6# Mac, adjust for Python version
7if [ -d "$HOME/Library/Python/3.6/bin/" ] ; then
8 PATH="$HOME/Library/Python/3.6/bin/:$PATH"

GIF in action

I’ll be using my favorite SlackmojiParty Parrot for playing in the terminal.

Alt text

Don’t know about Party Parrot? It’s quite an interesting story. Read it out here.

After the installation, run the following command in your terminal and enjoy the party 😉. The following command queries the Tenor’s GIF API and returns the top GIF.

1gif-for-cli "party parrot"

For exploring more gif-for-cli usage options, check the gif-for-cli repo.

What about Windows users? 😕

Currently, this is not supported on Windows platform. Though, there is an open issue on GitHub’s repo for Windows Command Prompt and PowerShell support. You can subscribe to that issue or keep a watch on the repository. Or a much better initiative, switch to Linux 😎 as soon as possible or just wait forever.

Let’s see what GIF you have put up on your terminal. Comment down below your terminal images with GIF in action 📷.

More articles from Ayush Gupta's Blog

How To Play GIF In Your Terminal

A tutorial on playing GIF in your terminal using gif-for-cli in Linux or Mac OS.

June 27th, 2019 · 1 min read

Beginner’s Guide To CSS Grid And Flexbox

An overview and comparison between CSS Grid and Flexbox layout techniques in CSS.

June 15th, 2019 · 3 min read
© 2019–2020 Ayush Gupta's Blog
Link to $ to $ to $ to $