89

curl cheat.sh — get an instant answer to any question on (almost) any programming language from the command line

tldr

do curl cht.sh/go/execute+external+program to see how to execute external program in go

And this question: why I actually should I start the browser, and the browser has to downloads tons of JS, CSS and HTML, render them thereafter, only to show me some small output,
some small text, number or even some plot. Why can't I do a trivial query from the command line
and instantly get what I want?

I decided to create some service that will work as I think such a service should work.
And that is how wttr.in was created.

Nowadays you probably know, how to check the weather from the command line, but if not:

curl wttr.in

or

curl wttr.in/Paris

(curl wetter in Paris if you want to know the weather in Paris)

After that several other services were created (the point was to check how good the console
can solve the task, so I tried to create services providing information
of various nature: text, numbers, plots, pseudo graphic etc.):

curl rate.sx/btc # to check exchange rate of any (crypto)currency
curl qrenco.de/google.com # to QRenco.de any text

And now last but not least, the gem in this collection: cheat.sh.

The original idea behind the service was just to deliver a various UNIX/Linux command line cheat sheets via curl. There are several beautiful community driven cheat sheet repositories such as tldr, but the problem is that to use them you have to install them first, and it is quite often that you have no time for it, you just want to quickly check some cheat sheet.

With cheat.sh you don't need to install anything, just do:

curl cheat.sh/tar (or whatever)

you will get a cheat sheet for this command (if such cheat sheet exists inf one of the most popular community-driven cheat sheet repositories; but it surely does).

But then I thought: why actually show only existing cheat sheets? Why not generate cheat sheets or better to say on the fly? And that is how the next major update of cheat.sh was created.

Now you can simply do:

curl cht.sh/python/copy+files
curl cht.sh/go/execute+external+program
curl cht.sh/js/async+file+read

or even

curl cht.sh/python/копировать+файл
curl cht.sh/ruby/Datei+löschen
curl cht.sh/lua/复制文件

and get your question answered
(cht.sh is an alias for cheat.sh).

And it does not matter what language have you used to ask the question. To be short, all pairs (human language => programming language) are supported.

One very important major advantage of console oriented interfaces is that they are easily
programmable and can be easily integrated with various systems.
For example, Vim and Emacs plugins were created by means of that you can
query the service directly from the editor so that you can just write your
questions in the buffer and convert them in code with a keystroke.

The service is of course far from the perfection,
there are plenty of things to be fixed and to be implemented,
but now you can see its contours and see the contours of this approach,
console oriented services.

The service (as well as the other mentioned above services) is opensource, its code is available here:
https://github.com/chubin/cheat.sh

What do you think about this service?
What do you think about this approach?
Have you already heard about these services before?
Have you used them?
If yes, what do you like about them and what are you missing?

Comments
  • 2
    @Brosyl

    Very happy to hear that you are a wttr.in user!

    Regarding cheat.sh:

    I've just checked your requests and they look quite good.

    curl cht.sh/c/run+external+program

    curl cht.sh/java/declare+array

    Can you please show your other requests that did not work?

    We had some problems because of the high load that we are currently experiencing, but I've already fixed those problems. Maybe that was the reason why it didn't work.

    Could you please retry + show your requests that do not work (if they still do not work)?
  • 1
    @Brosyl

    By the way, if you don't like some answer,

    you can see other ones by adding /1, /2 etc to the request:

    curl cht.sh/java/declare+array/1

    curl cht.sh/java/declare+array/2

    curl cht.sh/java/declare+array/3

    Please try different requests, even completely crazy, so that you don't get the impression that my requests are hand-picked.
  • 5
    @Brosyl

    As I said, the problem was on our side, we are trending on Github currently and it causes a high load on the service. But as I said, the problem was fixed, so it should work now.

    Your point with the terminal is fair, it is true, that it somehow perverse to open the browser only to see how do you convert a string into an int or something like that.

    Even more, the thing can be accessed directly from Vim/Emacs with a keystroke!

    Write a query and press <leader>KP (in Vim) to convert it into code. That's how it looks like:
  • 2
    God!!
  • 1
    For rate.sx, are there any plans to support a fiat currency other than US$ as the unit?
  • 2
    Holy shit.. 😯
  • 2
    Awesome
  • 2
    Favorited!
  • 3
    Looks really nice. Do you on the serverside check if it's an actual webbrowser or a commandline tool?
  • 1
  • 2
    Woah, this is cool.
  • 0
    @Pr0methean

    It is already supported actually.

    Just try:

    curl eur.rate.sx/btc

    curl gbp.rate.sx/eth

    curl chf.rate.sx/xrp

    And of course you know, that you can select the time interval using the @ notation:

    curl eur.rate.sx/btc@5w
  • 1
    @igor-chubin Cool! So is there some reason why fiat-to-fiat rates aren't also available?
  • 3
    @Wack

    Sure! In all cases (wttr.in, rate.sx, qrenco.de, cheat.sh) we do analyze the user agent of the query, and depending on that we generate ANSI sequences or HTML (or even PNG if needed).

    For example, for PNG:

    wget https://wttr.in/Berlin_0qp.png

    And you will get a PNG-file with the same output as for

    curl https://wttr.in/Berlin?0qp

    Try it.

    Even more than that: for cheat.sh we want to go even one step further and not only generate HTML output that looks like terminal output, but give a shell access to our shell client with the same name: cht.sh.

    Try to open this in browser to get some impression how it will look like after we activate it for all pages (now it is only accessible via this secret URL that is known only to our developers and the devrant users):

    https://cht.sh/:shell/

    type there help for more.
  • 1
    @Pr0methean

    They are available, but without plots.

    Try:

    curl eur.rate.sx/100usd

    curl gbp.rate.sx/100eur+200usd

    to know what is 100 USD in EUR and what is 100 EUR + 200 USD in GBP.

    You mean it would be great to have fiat to fiat conversion rates plots too?

    The only reason (I think) that they are not so volatile and probably nobody would use it, but why not? Actually it might be the only reason why we do not have it still. And if you ask about it, then there is at least one user who could need it
  • 1
    @igor-chubin you got me hooked instantly thx for the info and the awesome service.
  • 0
    OMG, I've just reread my post. So many typos!

    Sorry for that!

    I think that it is already too late to fix the post, at least I didn't find any method how it could be possible.

    I'm really sorry for that, that you had to use the embedded spell-checkers and correctors of your minds while reading the post.
  • 1
    @mee4895

    Thank you! It was my first post on devrant, and I'm very glad you liked it (I mean not the post itself but everything: the services and the curl oriented approach).

    (and devRant is cool. I discovered it for me a couple of weeks ago thanks to @RantSomeWhere and I'm totally fascinated with it)
  • 3
    Damn, I like what you did there!
  • 1
    I tried a few commands but they didn't work.

    I tried:

    curl cheat.sh/python/declare+array

    and

    curl cheat.sh/java/scanner

    and both gave an "unknown topic" error.
  • 0
    @Mathtauathogen

    The problem is that because of the extreme popularity of the service (it is currently number one on github.com/trending), we are getting an enormous stream of queries, that we can't handle.

    We are trying to fix the issues, but it will take some time.

    As soon as the problem is fixed, you can use both cheat.sh and cht.sh (cht.sh is an alias of cht.sh).

    (I've changed the error message from the ambiguous "unknown topic" to the clear "too much traffic").

    I hope that the service will be back soon
  • 0
    @RantSomeWhere

    No, no, they will work with both.

    The only difference between cheat.sh and cht.sh is that cht.sh support the experimental web shell mode I've mentioned above.

    https://cht.sh/:shell/

    And the second: command line client is called cht.sh (but the domain names are pointing to the same service).
  • 3
  • 0
    @ewpratten

    Hi! What does it mean? Does this dot have a special meaning?
  • 6
    @igor-chubin

    It's something that we used to do on rants to basically say "this is interesting"/"I'm saving this for later" also, it's a way of getting notifications for a rant's comments without having to write something yourself.

    I think people have switched over to using the pin emoji (📌) but I like the old way.
  • 2
    @ewpratten

    Ok, now I know it. Thank you.

    Actually it is something like "subscribed to the comments"

    (devRant is cool; can't say what magic does it have, but it has something in it)
Add Comment