This content originally appeared on DEV Community and was authored by Thomas Gotwig
We have two different URL options to fetch a Github Gist file via cURL:
- gist.githubusercontent.com
- 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: 60
x-ratelimit-remaining: 59
x-ratelimit-reset: 1636928776
x-ratelimit-resource: core
x-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: 5000
x-ratelimit-remaining: 4999
x-ratelimit-reset: 1636928894
x-ratelimit-used: 1
x-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! ๐
This content originally appeared on DEV Community and was authored by Thomas Gotwig
Thomas Gotwig | Sciencx (2021-11-20T09:54:11+00:00) ๐ Executing Github Gist files from Linux Shell via cURL. Retrieved from https://www.scien.cx/2021/11/20/%f0%9f%9a%80-executing-github-gist-files-from-linux-shell-via-curl/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.