I need to load a shell script from a raw gist but I can't find a way to get raw URL.
curl -L address-to-raw-gist.sh | bash
I need to load a shell script from a raw gist but I can't find a way to get raw URL.
curl -L address-to-raw-gist.sh | bash
And yet there is, look for the raw button (on the top-right of the source code).
The raw URL should look like this:
https://gist.githubusercontent.com/{user}/{gist_hash}/raw/{commit_hash}/{file}
Note: it is possible to get the latest version by omitting the {commit_hash} part, as shown below:
https://gist.githubusercontent.com/{user}/{gist_hash}/raw/{file}
February 2014: the raw url just changed.
See "Gist raw file URI change":
The raw host for all Gist files is changing immediately.
This change was made to further isolate user content from trusted GitHub applications.The new host is
https://gist.githubusercontent.com.
Existing URIs will redirect to the new host.
Before it was https://gist.github.com/<username>/<gist-id>/raw/...
Now it is https://gist.githubusercontent.com/<username>/<gist-id>/raw/...
For instance:
KrisWebDev adds in the comments:
If you want the last version of a Gist document, just remove the
<commit>/from URLhttps://gist.githubusercontent.com/VonC/9184693/raw/testNewGist
The raw host for all Gist files is changing immediately. But I found it not immediatelyOne can simply use the github api.
https://api.github.com/gists/$GIST_ID
Reference: https://miguelpiedrafita.com/github-gists
url = json_data["files"][filename]["raw_url"] where filename is the name of a specific file within the gist.Adding one note to @aymericbeaumet's answer ... It seems possible to also omit the file part in url if there's only one file in the gist. For example:
curl -s https://gist.githubusercontent.com/karpathy/d4dee566867f8291f086/raw
prints
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
...
as of 2025-02-28.