Last active
December 31, 2015 19:49
-
-
Save conspirator/8035808 to your computer and use it in GitHub Desktop.
Revisions
-
conspirator revised this gist
Dec 19, 2013 . 1 changed file with 15 additions and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,14 +17,21 @@ function jsonval { temp=`echo $json | sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"\:\"/\|/g' | sed 's/[\,]/ /g' | sed 's/\"//g' | grep -w $prop` echo ${temp##*|} } api="http://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC&tag=${*//-o/}" json=`curl -s -X GET $api` prop='data' dataCheck=`jsonval` if [[ ${dataCheck//data:/} == *[]* ]] then echo "No results" else prop='image_original_url' url=`jsonval` if [[ $* == *-o* ]] then open $url else echo $url | pbcopy echo "In clipboard: $url" fi fi -
conspirator created this gist
Dec 19, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #!/bin/sh # # Grab a random gif from giphy.com # # Example: # $ gif // places a gif url on your clipboard # $ gif -o // opens a gif url in your default browser # $ gif chicago+bulls // places a Bulls-related gif url on your clipboard # $ gif chicago+bulls -o // opens a Bulls-related gif url in your default browser # # Author: Christopher Webb <hello@conspirator.co> # Website: conspirator.co # Updated: 12/18/13 # function jsonval { temp=`echo $json | sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"\:\"/\|/g' | sed 's/[\,]/ /g' | sed 's/\"//g' | grep -w $prop` echo ${temp##*|} } url="http://api.giphy.com/v1/gifs/random?api_key=dc6zaTOxFJmzC&tag=${*//-o/}" json=`curl -s -X GET $url` prop='image_original_url' url=`jsonval` if [[ $* == *-o* ]] then open $url else echo $url | pbcopy echo "In clipboard: $url" fi