Skip to content

Instantly share code, notes, and snippets.

@nrobinson2000
Created August 21, 2017 03:30
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 nrobinson2000/f77a32c04c2fb9540c658a17009276f4 to your computer and use it in GitHub Desktop.
Save nrobinson2000/f77a32c04c2fb9540c658a17009276f4 to your computer and use it in GitHub Desktop.
Get the GitHub URL for a Particle library
#!/bin/bash
getLibURL()
{
TOKEN="$(cat ~/.particle/particle.config.json | grep 'token' | grep -oE '([0-Z])\w+')"
DATA=$(curl -sLH "Authorization: Bearer $TOKEN" "https://api.particle.io/v1/libraries/$1" | json_pp)
LIBURL=$(echo "$DATA" | grep "url" | grep -oE '"((?:\\.|[^"\\])*)"' | grep "http" | tr -d '"')
}
getLibURL "$1"
if ( echo "$LIBURL" | grep "github" ) > /dev/null ;
then
echo "$LIBURL"
else
echo "Not Found"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment