Skip to content

Instantly share code, notes, and snippets.

@twobitlabs
Created May 4, 2018 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twobitlabs/68d44b5a61f8b349a2fad688a282f82f to your computer and use it in GitHub Desktop.
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
#!/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