Skip to content

Instantly share code, notes, and snippets.

@dunkelstern
Created March 8, 2016 17:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dunkelstern/a290df2c6d43f964b8bb to your computer and use it in GitHub Desktop.
Save dunkelstern/a290df2c6d43f964b8bb to your computer and use it in GitHub Desktop.
Use the inline image functionality of iTerm2 3.0 to display an animated gif from giphy search
#!/usr/bin/python
from __future__ import print_function
import urllib
import json
import sys
import base64
search = urllib.quote(sys.argv[1])
json_data = urllib.urlopen("http://api.giphy.com/v1/gifs/search?q={searchterm}&api_key=dc6zaTOxFJmzC&limit=1".format(searchterm=search)).read()
data = json.loads(json_data)
gif = data["data"][0]["images"]["fixed_height"]["url"]
gif_data = urllib.urlopen(gif).read()
print("\033]1337;File=inline=1:"+base64.b64encode(gif_data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment