Skip to content

Instantly share code, notes, and snippets.

@atenni atenni/README.md
Last active Nov 14, 2019

Embed
What would you like to do?
How to permalink to a gist's raw file
@raine

This comment has been minimized.

Copy link

raine commented Oct 20, 2015

You can't curl https://gist.github.com/[gist_user]/[gist_id]/raw/[file_name] without adding -L flag because it directs to gist.githubusercontent.com

@Asbra

This comment has been minimized.

Copy link

Asbra commented Oct 25, 2015

It seems to link to the first revision, not the latest one, right?
Could've used for UpdateURL in UserScript otherwise

@revolter

This comment has been minimized.

Copy link

revolter commented Jan 26, 2016

@Asbra, No, it links to the latest revision. But GreaseMonkey or TamperMonkey doesn't detect it as an userscript, so the install screen doesn't appear.

@wattcommunity

This comment has been minimized.

Copy link

wattcommunity commented Feb 29, 2016

No, this is definitely (initially) linked to the first revision, not reflecting any later changes to the file.

However, it seems this is because it is not be immediate - the change took at least 10 minutes!

@erm3nda

This comment has been minimized.

Copy link

erm3nda commented May 4, 2016

@raine You don't need to use -L if you know the final url, using a url like https://gist.githubusercontent.com/atenni/5604615/raw works perfectly. But, btw the -L flag works too.

Regarding to the url, I found that it's a nice way to use shorteners that can edit links to permanently link your script. This way users can update their scripts automatically. U can use a known shortener service or just create your own.

@Gerst20051

This comment has been minimized.

Copy link

Gerst20051 commented Jun 25, 2016

👍

@houtianze

This comment has been minimized.

Copy link

houtianze commented Mar 8, 2017

Cool 👍

@0xcrypto

This comment has been minimized.

Copy link

0xcrypto commented Apr 30, 2017

Or simply use https://rawgit.com

@beppe9000

This comment has been minimized.

Copy link

beppe9000 commented May 15, 2017

@multlurk

This comment has been minimized.

Copy link

multlurk commented Jul 8, 2017

👍

@inspector71

This comment has been minimized.

Copy link

inspector71 commented Aug 15, 2017

How did you get such short a gist_id in your examples? I realise git hashes can often be shortened but it's not happening for me:

https://gist.githubusercontent.com/inspector71/59e5598/raw/

returns a 404 whereas:

https://gist.githubusercontent.com/inspector71/59e559824edfead1b0d3366ce402a687/raw

returns expected result.

@aleclarson

This comment has been minimized.

Copy link

aleclarson commented Jan 2, 2018

Thanks! 👍

@avatar-lavventura

This comment has been minimized.

Copy link

avatar-lavventura commented Apr 25, 2018

Thanks mate!

@MatheusRV

This comment has been minimized.

Copy link

MatheusRV commented May 5, 2018

Tks

@yairEO

This comment has been minimized.

Copy link

yairEO commented Jul 5, 2018

Here's a related StackOverflow question which is of high-value to this thread

@LM1LC3N7

This comment has been minimized.

Copy link

LM1LC3N7 commented Feb 27, 2019

Thanks! 👍 👍

@Deledrius

This comment has been minimized.

Copy link

Deledrius commented May 15, 2019

@Asbra, No, it links to the latest revision. But GreaseMonkey or TamperMonkey doesn't detect it as an userscript, so the install screen doesn't appear.

@revolter -- As long as the file is correctly named (i.e., ending with .user.js or .user.css) the full format should work, even for single-file gists. I tested this with both Stylus and Greasemonkey, and they pick up the files correctly and automatically ask to install: https://gist.github.com/[gist_user]/[gist_id]/raw/scriptname.user.js

@KaKi87

This comment has been minimized.

Copy link

KaKi87 commented Jun 26, 2019

Thanks !!

@christo8989

This comment has been minimized.

Copy link

christo8989 commented Oct 23, 2019

I'm using https://gist.githubusercontent.com/[username]/[gist_id]/raw/[filename].

I use like so...
curl -o "$USERPROFILE/[filename]" -H "Cache-Control: no-cache" https://gist.githubusercontent.com/[username]/[gist_id]/raw/[filename]

Btw, this is like the only place that specifies the filename part so thank you!
👍

@Erquint

This comment has been minimized.

Copy link

Erquint commented Oct 25, 2019

An essential tip for those hosting their userscripts on GitHub Gist

Since userscript hosts (e.g. GreaseMonkey, Tampermonkey, ViolentMonkey) require the links to userscripts to end in user.js to automatically detect, install and update them, you should use https://gist.github.com/[gist_user]/[gist_id]/raw/[file_name] even for single file gists.
Don't forget to set the link as both @updateURL and @downloadURL in the file, otherwise the userscript host may assume the versioned download link as an override to updates link if a user downloads it by clicking on the Raw button on the gist page.

Example

Here's one of my userscripts that I managed to make updatable:
https://gist.githubusercontent.com/Erquint/ec4f688c7d6d9ea2ccddff8acb3a8415/raw/FWPMP.user.js
Notice the @updateURL and @downloadURL metadata. The rest is optional

@mochadwi

This comment has been minimized.

Copy link

mochadwi commented Nov 12, 2019

Awesome findings. With this, the permalink will always use the latest version

@guruskid

This comment has been minimized.

Copy link

guruskid commented Nov 14, 2019

I am building a project but am looking for a full-stack dev that will join me on the project, if anyone is interested should contact me on configureall@gmail.com with the title PROJECT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.