H11Y BLOG Logo

How to Download a .gif file from Giphy

11/21/2022

You can download a gif from giphy.com with curl.

curl <giphyUrl> --output ~/Desktop/gifs/yourgif.gif

The gif above was downloaded using curl from giphy.com

Making a Custom Giphy Downloader Script

As a mini-project, we’re going to build a custom bash script.

This can be wrapped in a custom shell script and called like:

> giphy https://media.giphy.com/media/twxoPjMpsijwPFBVqs/giphy.gif ~/Desktop/mygif.gifs

Create a script called giphy or giphy.sh containing the following script:

#!/bin/bash

curl `$1` --output `$2`

Make it executable with chmod +x giphy.

Add the script to your PATH variable in your bashrc or zshrc via export PATH="path/to/bin-dir-containing/giphy:$PATH" or just export PATH="path/to/bin-dir-containing:$PATH" for multiple cli scripts you write.

I keep my personal binary files in ~/dotfiles/scripts. If you’re curious, you can find my dotfiles at github.com/hkievet/dotfiles.