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! π
Top comments (1)
Executing random Gists may have really bad consequences, use this with trusted sources only!
See news.ycombinator.com/item?id=12766049 for examples