Created
May 4, 2018 23:08
-
-
Save twobitlabs/68d44b5a61f8b349a2fad688a282f82f to your computer and use it in GitHub Desktop.
Command line script to capture json, pretty print it, and publish as a gist
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/env bash | |
# Make sure you have the gist commandline tool installed. | |
# gem install gist | |
# or brew install gist | |
# | |
# Example usage: gistjson weather "https://api.weather.gov/points/37.7628,-122.4398" | |
# Creates https://gist.github.com/twobitlabs/b9aec0c1508d21b09dd98139a5ef3ff9 | |
if [ -z "$1" ] | |
then | |
echo "No name supplied" | |
fi | |
if [ -z "$2" ] | |
then | |
echo "No url supplied" | |
fi | |
URL=`curl "$2" | python -mjson.tool | gist -p -f "$1.json" -d "$2"` | |
open $URL | |
echo $URL | pbcopy | |
echo $URL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment