Created
December 9, 2015 13:15
-
-
Save flou/b85406d72745147c3440 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/sh | |
# requires imgcat (https://github.com/gnachman/iTerm2/blob/master/tests/imgcat) | |
xkcd_issue=$1 | |
TMP_FILE=$(mktemp /tmp/xkcd-$xkcd_issue.json.XXXXXXXX) | |
curl -s http://xkcd.com/$xkcd_issue/info.0.json > $TMP_FILE | |
imgurl=$(jq '.img' $TMP_FILE | tr -d \") | |
imgtitle=$(jq '.title' $TMP_FILE | tr -d \") | |
imgalt=$(jq '.alt' $TMP_FILE | tr -d \") | |
imgnum=$(jq '.num' $TMP_FILE | tr -d \") | |
curl -s $imgurl -o /tmp/$xkcd_issue.png | |
echo "#$imgnum: $imgtitle" | |
imgcat /tmp/$xkcd_issue.png | |
echo $imgalt | |
echo | |
rm /tmp/$xkcd_issue.png | |
rm $TMP_FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment