Created
March 8, 2016 17:15
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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