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