So yesterday, me and some geeky friends were sitting and discussing the power of the Linux Terminal application. It boiled down to what is the most geekiest or Terminal-savvy thing we have ever done with our command line. A friend mentioned that he has played gifs “in” the Terminal. If he had said ‘through’ the Terminal, it was not a big deal, but how he played them inside the Terminal is what intrigued us. It is the GIF-for-CLI application he had used to do so; which only plays gifs in ASCII format-obviously they seem very low resolution and barely watchable. I tried the trick with various gifs and came to the conclusion that only some animated cartoon gifs could be watched and fairly interpreted in the Linux command line. Thus this trick is not what you can rely on but try once in a while just for fun.

In this article, we will explain how you can install the GIF for CLI tool on your Ubuntu and watch gifs through it inside the Terminal.

Why the Command Line?

If you are a Terminal-savvy person, you wouldn’t want to leave the comfort of the command line and go somewhere else to do any of your daily technical activities. There is always a way to do almost all of our stuff right inside the Terminal. So, why should gif viewing be any different! Using the Terminal makes certain tasks more efficient and, even faster. The command-line tools do not use too many resources and thus form great alternatives to the widely used graphical applications, especially if you are stuck up with older hardware.

We have run the commands and procedures mentioned in this article on a Ubuntu 18.04 LTS system.

Installing GIF-for-CLI through the Command Line

You can install the Gif for CLI tool via the Snap store through the Ubuntu command line. Open your Ubuntu Terminal either through the Application Launcher search or by using the Ctrl+Alt+T shortcut. Enter the following command in order to refresh the list of available packages:

$ sudo apt-get update

Update Ubuntu package lists

Since the Snap daemon comes by default in the latest versions of Ubuntu, we do not need to install it. If you are using an older version, you can use the following command to install the daemon:

$ sudo apt-get install snapd

Now type in the following command in order to install Gif for CLI to your Ubuntu:

$ sudo snap install --edge gif-for-cli

Install gif for cli package

The similar output as I got will indicate the completion of the installation and will also print the Gif for CLI version installed on your system.

If you ever want to remove Gif for CLI installed through this method, you can use the following command in the Terminal:

$ sudo snap remove gif-for-cli

Remove snap

Installing GIF-for-CLI through the Ubuntu UI

For a person who does not want to open the Command Line much, installing a software through the UI is very simple. Please follow these steps in order to install the Gif for CLI tool, available on the Snap store, through the Ubuntu UI:

On your Ubuntu desktop Activities toolbar/dock, click the Ubuntu Software icon.

Ubuntu Software center

Click the search icon and enter ‘gif-for-cli’ in the search bar. The search results will list the relevant entries as follows:

gif for cli

The gif-for-cli entry listed here is the one maintained by the Snap store. Click on this search entry to open the following view:

Install software

Click the Install button to begin the installation process. The following authentication dialog will appear for you to provide your authentication details as only an authorized user can install software on Ubuntu.

Authenticate as admin

Please note that only an authorized user can add/remove and configure software on Ubuntu. Enter your password and click the Authenticate button. After that, the installation process will begin, displaying a progress bar as follows:

Software install progress

gif-for-cli will then be installed on your system and you will get the following message after a successful installation:

Software installed

Through the above dialog, you cannot launch the tool directly but you can Remove it immediately for whatever reason.

Using Gif for CLI to view gifs

The gif for cli takes in a GIF, short video, or a query to the Tenor GIF API and converts it to animated ASCII art. Animation and color support are performed using ANSI escape sequences.

Open the Terminal application and use the following syntax to play a gif:

$ gif-for-cli filename.gif

This script will automatically detect how many colors the current terminal uses and display the correct version.

This is how my original gif looks like:

Test gif file

And, this is how it looks when I play it in the Terminal through the following command:

$ gif-for-cli sample.gif

Gif for CLI

Calling it “close enough” would be nothing short of exaggeration.

This, after all, was a fun trick and I would rather watch my gifs through the UI using all the modern image and video players.

How to display gif files in Ubuntu Terminal