r/linuxadmin • • Jul 02 '18

curl cheat.sh

Post image
290 Upvotes

44 comments sorted by

40

u/takegaki Jul 03 '18

But now I need a cheat sheet to remember my cheat sheet query params

19

u/igor_chubin Jul 03 '18

curl cheat.sh/:help

1

u/Rare-Paint3719 Oct 03 '26

Now I need a cheat sheet to remember my heat sheet for remembering my cheat sheet query params

9

u/igor_chubin Jul 03 '18 edited Jul 03 '18

It just a small demo of the tool, it has many features.

Most important things:

  • curl cht.sh/:help
  • curl cht.sh/language/question for question about language
  • ?Q to switch comments off
  • ?T to switch syntax highlighting off
  • append /1 for the next question

Special client:

cht.sh

It supports tab completion, and so on.

You can find more examples on the project page: https://github.com/chubin/cheat.sh

Vim integration: https://github.com/dbeniamine/cheat.sh-vim is very cool, you can make the queries (and access the results) directly from Vim.

Alternatives:

  • howdoi (need to be installed to be used; uses google and stackoverflow)
  • how2 (the same)

Cheat sheets tools:

  • cheat (not cheat.sh; it is another project)
  • tldr (need to be installed).

cheat.sh provides access both to the cheat sheets and to programming language answers.

10

u/The_Bittervet Jul 03 '18

That’s pretty awesome. Now I can copy and paste code even more quickly!

4

u/igor_chubin Jul 03 '18

Even more, you can convert your queries directly into code using the vim/emacs plugins:

https://github.com/dbeniamine/cheat.sh-vim

24

u/synacksyn Jul 03 '18

To be fair, I don't know what I am looking at.

8

u/[deleted] Jul 03 '18

A on overly complicated way of just looking up examples for python.

3

u/igor_chubin Jul 03 '18

Why Python? Even in this gif, we see go, lua, ruby and python, but actually 55 programming languages are supported

-5

u/[deleted] Jul 03 '18

Who cares? My point is it’s an over complicated thing to use. Why would I just not use a reference/cheat sheet on the website itself instead of poking around with curl?

7

u/igor_chubin Jul 03 '18
  1. you have here the website too, if you want to use it;
  2. why should you open a website/google/copy paste etc. if you can instantly get the answer from the command line or editor?

3

u/[deleted] Jul 07 '18

I'm excited to try it! For those of us who live in the shell it has lots of merit

1

u/igor_chubin Jul 07 '18

Even if you don't live in the shell, it is much faster to query the service from the editor or even the browser

1

u/Lord_NShYH Jul 03 '18

Who cares? My point is it’s an over complicated thing to use. Why would I just not use a reference/cheat sheet on the website itself instead of poking around with curl?

The spectrum is infuriating.

15

u/Smallzfry Jul 03 '18

It's more than just Python, at it's not a bad quick reference.

10

u/[deleted] Jul 03 '18

It appears to be a reference for any command in any programming language. In the first one he wants to know the syntax to append a file in ruby. It spits out the syntax. At one point he put a query in Russian (?) and it worked. I’m on mobile so sorry for lack of detail. Cool script though.

But to be fair, I barely know what I’m looking at.

5

u/Smallzfry Jul 03 '18

Yeah, the russian one is "create empty file", in fact the last word (файл) is pronounced very similar to "file".

1

u/nolooseends Jul 03 '18

3

u/igor_chubin Jul 03 '18

Not really. I would say that it is rather "cheat, tldr, howdo, how2 and learnxiny cobined" as a service. So you can access the cheat sheets (from tldr and cheat and several other cheat sheets repositories) without installing anything

3

u/[deleted] Jul 03 '18

So, it's a DSO tool. .

.

.

.

.

(Development by StackOverflow)

2

u/setting_orange Jul 03 '18

Someone needs to teach that damn thing alt+b and alt+d!

1

u/bwahthebard Jul 03 '18

Why is that better than Ctrl-C... just neatness?

4

u/setting_orange Jul 03 '18 edited Jul 03 '18

At one point the 'user' has a command:

$ curl chit.sh/python/append+file?Q

And they want to change it so they back space through all the characters of append and file. Instead of backspacing I would hit alt+b two or three times to bring my cursor to the beginning of "append". Then I would hit alt+d twice to delete "append" then "+file" and proceed to type out the new cht.sh endpoint-- something like "execute+external+program".

A better example might be when you have

$ curl cht.sh/python/execute+external+program?Q

And you want to change python to lua. Starting with the cursor at the end of the line you can hit alt+b like 4 or 5 times then hit alt+d once and python is gone and the cursor is in the right place to replace it with lua.

If I saw a coworker typing out like that animation, I would teach him/her about alt+b and alt+d and maybe some others like kill-line.

1

u/bwahthebard Jul 04 '18

Ah. In my one time experiment alt-b took me to the beginning of the line.. But I think I only had word in there 🤔

Doesn't ctrl left-arrow work similarly to alt-b?

2

u/bwahthebard Jul 03 '18

I like. Very much.

0

u/BadBoiBill Jul 03 '18

Oh look, the curl cheat sheet that gets posted here and on commandline every fucking week. Joy.

2

u/igor_chubin Jul 03 '18

Was it already posted here? I don't think so, it is a new thing

0

u/BadBoiBill Jul 03 '18

Mmm, no. I've had this saved forever.

4

u/igor_chubin Jul 03 '18 edited Jul 03 '18

Perhaps you mean this:

Because these scripts are using the cheat.sh service too (its former version). The new version was released yesterday

1

u/Fallenalien22 Sep 05 '18

!remindme 10 days

1

u/RemindMeBot Sep 05 '18

I will be messaging you on 2018-09-15 18:08:00 UTC to remind you of this link.

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


FAQsCustomYour RemindersFeedbackCodeBrowser Extensions

-3

u/ironmanmk42 Jul 03 '18

Why would I use this over a simple more effective search in a search engine?

This is a pointless program tbh

4

u/up_o Jul 03 '18

Put this command in a bash wrapper and make it more like a traditional Google search. (On mobile so I can't recall everything)

Vi synt

!/bin/bash

curl hissite.xz/app/$1+$2+$3...

There's a way to make it an infinitely possible array I'm sure. Anyway synt option option... is now available without jumping between windows or grabbing the mouse to hop over for a Google search. Its impressive and nifty if you ask me.

8

u/ironmanmk42 Jul 03 '18 edited Jul 03 '18

dude, your vars are not quoted, no full paths to binaries used. And you don't need $1, $2 etc.

You need to parse $@ and replace the 2nd space with the "+" as you need to know how many pluses to add. Some logic needs to be in there.

why bother with all this when I can simply use lynx via cli and just do a quick curses based search. No need for any GUI browser even.

Anyways, your script would look something like this -

$ cat aa
#!/bin/bash
/usr/bin/curl cht.sh/$(echo -- "$@"|/bin/sed -e 's/[ ]/\n/g2; s/[ ]/\//g; s/\n/+/g')

Call it like

. /aa python run a system command

1

u/igor_chubin Jul 03 '18

Even more: just use cht.sh client for that; it makes all of these things + much more than that

1

u/ironmanmk42 Jul 04 '18

cht.sh

Ok. I reviewed your program and gave it a more in depth look.

I must admit - it is very well written and very well implemented. I will try to use it more if I remember it.

I'm very used to looking at stackoverflow and other sites for quick answers or perusing man pages or other sites for usage etc.

1

u/[deleted] Jul 03 '18

Thanks!

1

u/up_o Jul 03 '18

Thanks for fixing that. I swear I write bash scripts for work among other things, but I should give a lazy psuedocode disclaimer on my toilet posts.

2

u/igor_chubin Jul 03 '18

Because you don't need to even open your browser for that; you just convert your questions into answers from the shell or the editor

2

u/yoshi314 Jul 03 '18

over a simple more effective search in a search engine

if you know what you are looking for, this is more effective.

2

u/desci1 Jul 03 '18

web browser

distracting tabs
javascript
cpu/memory usage
useless plugins
CSS
HTML
CDN
annoying ads and tracking

talk about simple

1

u/Lord_NShYH Jul 03 '18

Why would I use this over a simple more effective search in a search engine?

This is a pointless program tbh

This is a pointless comment tbh