chubin / cheat.sh

the only cheat sheet you need
https://cheat.sh/
MIT License
38.41k stars 1.79k forks source link

How to get original url form cht.sh cli? #83

Open rabbitear opened 6 years ago

rabbitear commented 6 years ago

Hello, I always find myself wanting to add more to many of the sheets, specially the unix commands. In the readme it says one way to do that is find the url and use the browser. I'm using the cli cht.sh, wondering how to find the url of the specific sheet I'm looking at?

Thanks.

sullivant commented 5 years ago

I don't currently believe there is a way to do this via the command line "curl" of cht.sh however, if you open the same cheat sheet in the browser, it'll have an "edit" link in the top right side.

You can see that if you visit https://cht.sh/bash for instance. However, not all cheat sheets have that link, because, IIRC, they can come from other sources. (ie: https://cht.sh/vim ) - in that case, all the way at the bottom there is a link to the github repo that contained the sheet, as well.

I reckon the difference is because @chubin knows which ones are hosted under his github acct, so he can directly add an edit link to them.

chubin commented 5 years ago

That's a very good question. Actually, we should have the url anyway, at least for the license purposes (as we have it for stackoverflow answers). What would be even cooler, and we will implement it, that it would be possible to edit cheat sheets directly with cht.sh -e:

$ cht.sh -e tar
dbeniamine commented 5 years ago

It's definitely a feature that be nice on editors plugin

abitrolly commented 4 years ago

Implement ?src option that will show where the cheat sheet comes from?

$ curl cht.sh/btrfs\?src
https://github.com/chubin/cheat.sheets/edit/master/sheets/btrfs
chubin commented 4 years ago

I think, it should be either a short option (like S) or a long option (like show_src=true); otherwise it will be misinterpreted as a group of three short options (s, r, and c)

TamaMcGlinn commented 3 years ago

I now get a little marking at the bottom of the cheatsheet; e.g. [so/q/3418231]. Unfortunately, that is not a url, so I can't just do gx on it from within vim. Can we make that an actual url?

chubin commented 3 years ago

@TamaMcGlinn yes, we will make it. I think the best way would be to add a special action, like action=url for that, so it will be possible to get the URL with

curl cht.sh/QUESTION?action=url

or a similar query

tplk commented 3 years ago

I'm currently using sed to transform StackOverflow references into working links.

Example script:

curl -s https://cht.sh/sed+capture+group | sed -r 's_so/q/([0-9]+)_https://stackoverflow.com/questions/\1_g'