Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
November 20, 2021 09:54 am GMT

Executing Github Gist files from Linux Shell via cURL

We have two different URL options to fetch a Github Gist file via cURL:

  1. gist.githubusercontent.com
  2. api.github.com

The second one is a bit more work, but always instant up-to-date!

1 gist.githubusercontent.com

curl -s https://gist.githubusercontent.com/[user]/[gist_id]/raw/[gist_file]?_=$(uuidgen) \| bash
 Hello World!

But this can run a older version of the file

2 api.github.com

Fix limitations of api.github.com

Using api.github.com comes with rate-limiting per hour:

curl -I -s https://api.github.com/users/[user] | grep x-ratelimit
x-ratelimit-limit: 60x-ratelimit-remaining: 59x-ratelimit-reset: 1636928776x-ratelimit-resource: corex-ratelimit-used: 1

However, we can get around this strong limitation by using a PAT:

curl -I -s -u <user>:<pat> \    https://api.github.com/users/[user] | grep x-ratelimit
x-ratelimit-limit: 5000x-ratelimit-remaining: 4999x-ratelimit-reset: 1636928894x-ratelimit-used: 1x-ratelimit-resource: core

Executing the Gist file!

curl -s -u <user>:<pat> \    "https://api.github.com/gists/[gist_id]?_=$(uuidgen)" \    | jq --raw-output '.files."<GIST_FILE>".content' | bash
 Hello World!

Until now it was always up-to-date!


Original Link: https://dev.to/tgotwig/executing-github-gist-files-from-linux-shell-via-curl-10fe

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To