News for hackers. Stuff that matters.
Re:An interactive cheatsheet tool for the command-line by kissgyorgy on Friday September 20, 2019 @08:46PM (#21032716)
Once I tried a tool like this, but just realized, there is already a method of that: the ~/bin folder.

You can write bash scripts, or scripts in any programming language with the proper shebang line, you can download other people's scripts, and you don't need bash history to keep them. Listing all of them is just an ls. I tend to not put file extensions of them and use good naming, so you can see everything without looking into them.

Re:An interactive cheatsheet tool for the command-line by AdieuToLogic on Friday September 20, 2019 @09:09PM (#21032815)
> Once I tried a tool like this, but just realized, there is already a method of that: the ~/bin folder.

One thing I'd add to this is that "crib notes" can be captured in man[0] pages. For example, having them in $HOME/man and ensuring MANPATH[1] includes it serves as a nice complement IMHO. There seems to be a markdown-based tool[2] which can assist in authoring them too.

EDIT: It looks like pandoc[3] can generate man pages from markdown as well.

0 - https://forums.freebsd.org/threads/howto-create-a-manpage-fr...

1 - https://www.freebsd.org/cgi/man.cgi?query=man&apropos=0&sekt...

2 - https://spin.atomicobject.com/2015/05/06/man-pages-in-markdo...

3 - https://pandoc.org/MANUAL.html

Re:An interactive cheatsheet tool for the command-line by nessunodoro on Saturday September 21, 2019 @01:13AM (#21033640)
to these great refs I would recommend the Ruby tool ronn

https://github.com/rtomayko/ronn

Re:An interactive cheatsheet tool for the command-line by crispyambulance on Saturday September 21, 2019 @09:29AM (#21035262)

    > ... there is already a method of that: the ~/bin folder.
More power to you if you can do that, but for me it's a memory problem and a problem of being able to figure out WTF options I need when I am in the middle of something.

man pages (and --help) are great if you have the time to sit down, ponder and experiment. But when you're trying to get stuff overwith, a massive wall of historically interesting text just isn't helpful.

The vast majority of invocations of any given command, I suspect, are limited to a not more than a handful of use-cases. In other words just enough combinations of arguments and options to perform a small number of different tasks. This is what people are typically interested in when they're on the command line. In that context getting massive dump of every possible option in a man page is frustrating and counter-productive.

For example, "tar". I use this command in 2 simple ways: archive a directory into a gzipped tar or extract a gzipped tar. This is what effectively everyone uses it for >99% of the time: toggle between a directory and a tar.gz file.

Basically... just 2 forms "tar -zxvf" and "tar ..." oh shit, I forgot how to tar/compress a directory, let's check the man page... ok "tar -cf" to create a tar, but wait I want it gzipped, and actually I forgot what the z, v and f stand for, now I need look each of those up, wait, do I really mean gzip? or bzip, oops more research.

To be fair, tar might be too easy an example but you can easily go down a manpage-rabbit-hole because of a lack of common usage examples.

Re:An interactive cheatsheet tool for the command-line by rmetzler on Saturday September 21, 2019 @09:57AM (#21035405)
I think it’s just a habit to turn these two or four versions of using tar into the same amount of one liner shell scripts. Or maybe a longer one with options and usage printing.
Re:An interactive cheatsheet tool for the command-line by kissgyorgy on Saturday September 21, 2019 @12:58PM (#21036444)
The perfect tool for your problem is https://tldr.sh/.

You don't even have to write the pages yourself, there are a lot of already pre-written.

Re:An interactive cheatsheet tool for the command-line by alanbernstein on Saturday September 21, 2019 @02:54AM (#21033927)
Great! Now, how does that bash syntax go again...?

This is why I have a similar tool for command line cheat sheet snippets - recalling bits of syntax to be combined into a command or a script.

Re:An interactive cheatsheet tool for the command-line by grenoire on Saturday September 21, 2019 @04:26AM (#21034154)
As GP, mentioned, you put the correct shebang. I write stuff in Python and make them as pipe-capable as possible. You don't have to bend hell and flip it upside down to write scripts.
Re:An interactive cheatsheet tool for the command-line by alanbernstein on Saturday September 21, 2019 @09:52AM (#21035373)
Sure - I use both bash and python for this purpose. Sometimes bash really is the right tool for the job, for example, when you need to use a lot of other complex CLI utilities, or when pipelines of simple commands get the job done in a simpler way.

I'm just explaining why a command line cheat sheet tool is useful to me. I don't need to be convinced that it isn't.

Re:An interactive cheatsheet tool for the command-line by alexryndin on Saturday September 21, 2019 @06:22AM (#21034486)
And then rofi for great good!
Re:An interactive cheatsheet tool for the command-line by imposterr on Friday September 20, 2019 @08:17PM (#21032592)
Wow, this is really cool. I assumed this was going to be written in go or rust, but taking a look it's actually all bash! I'm always surprised by how much people can get out of bash.

It's also some of the cleanest bash I've seen. Definitely going to be using some of these patterns for my own scripts.

Re:An interactive cheatsheet tool for the command-line by dnsfr on Saturday September 21, 2019 @07:38PM (#21038625)
Thanks! Actually it's written in bash because it started as a 25-line script. If it gets bigger, I'll consider rust.
Re:An interactive cheatsheet tool for the command-line by submeta on Saturday September 21, 2019 @01:46AM (#21033725)
Exactly my thoughts. Beautifully written and well organized bash code.
Re:An interactive cheatsheet tool for the command-line by OJFord on Friday September 20, 2019 @09:34PM (#21032912)
This looks cool, a common workflow of mine is `cmd --blah --blah ` ah damn I don't know the value for blah, okay, fzf ` --blah=(blahgen | fzf) ` oh I'm also missing [...]

This seems like it can help do the same thing more quickly, so I'm keen to give it a go.

I do like shell history though, a shame to just have a bunch of `navi` entries - I wonder if it could be faked; populated with the chosen command afterwards?

Re:An interactive cheatsheet tool for the command-line by dnsfr on Saturday September 21, 2019 @07:35PM (#21038615)
I could write a zsh/bash plug-in so that it fills the prompt instead of running the command, in the same manner as ctrl-r. What do you think?
Re:An interactive cheatsheet tool for the command-line by rroblak on Monday September 23, 2019 @11:23AM (#21049757)
That would make the difference between me using this tool and not using this tool. Losing my shell history isn't worth a momentary ergonomics gain.
Re:An interactive cheatsheet tool for the command-line by rmetzler on Saturday September 21, 2019 @10:03AM (#21035442)
Oh, you just gave me an idea of turning fzf into a filter for $CMD --help. I need to try this.
Re:An interactive cheatsheet tool for the command-line by dnsfr on Friday September 20, 2019 @06:57PM (#21032138)
navi allows you to browse through cheatsheets (that you may write yourself or download from maintainers) and execute commands, prompting for argument values.
Re:An interactive cheatsheet tool for the command-line by blondin on Friday September 20, 2019 @11:33PM (#21033328)
not only this looks super awesome but this is also the first time i have seen a shell program architected in such a nice way.
Re:An interactive cheatsheet tool for the command-line by lapnitnelav on Friday September 20, 2019 @09:34PM (#21032914)
Thanks for releasing that Denis.

Combining both cheatsheets and a better UX is brilliant. Wish I had this years ago when trying to wrap my head around the shell.

Re:An interactive cheatsheet tool for the command-line by obituary_latte on Saturday September 21, 2019 @06:33AM (#21034529)
Looks neat. I wish, though, there was a way to try it out in the browser as advertised without having to sign up or login. Might be a requirement of the site hosting the demo but whoever it is, forcing login is always and forever a deal breaker for me.
Re:An interactive cheatsheet tool for the command-line by dnsfr on Saturday September 21, 2019 @07:37PM (#21038617)
I didn't know it requires a login. Do you know any online free platform that can launch a given docker image?
Re:An interactive cheatsheet tool for the command-line by obituary_latte on Sunday September 22, 2019 @03:20AM (#21040093)
Sorry but I do not.
Re:An interactive cheatsheet tool for the command-line by faizshah on Friday September 20, 2019 @08:54PM (#21032756)
This is really cool, I remember a similar effort being posted here a few years ago: https://news.ycombinator.com/item?id=7121268

I really like this implementation!

Re:An interactive cheatsheet tool for the command-line by anchpop on Friday September 20, 2019 @11:10PM (#21033244)
Is there any way to run this on Windows, for people who use Cygwin or Git Bash? It seems really cool and useful
Re:An interactive cheatsheet tool for the command-line by dnsfr on Saturday September 21, 2019 @07:41PM (#21038633)
I think it should work out of the box. Did you get any error?
Re:An interactive cheatsheet tool for the command-line by superasn on Saturday September 21, 2019 @08:58AM (#21035081)
Looks like a really useful tool. Another tool I use like this is bropages or the `bro` command(1) which gives many examples similar to this for any command like ls, docker, etc. Sometimes it's useful when you don't have time to read the entire man page.

(1) https://www.ostechnix.com/3-good-alternatives-man-pages-ever...

Re:An interactive cheatsheet tool for the command-line by DavideNL on Saturday September 21, 2019 @08:00AM (#21034787)
Looks really nice;

I don't like the fact that an unknown command is executed before i can see/inspect what it is. Currently you won't even see what command was executed afterwards, you only see the result...

Would be nice to be able to also show the command below the item/result.

--print is possible, but it's cumbersome and not interactive: you can't "accept" the command after inspecting, and execute it.

Re:An interactive cheatsheet tool for the command-line by dnsfr on Saturday September 21, 2019 @07:32PM (#21038596)
Based on your input, the latest version has a preview window: https://user-images.githubusercontent.com/3226564/65380182-6...

I hope you like it!

Re:An interactive cheatsheet tool for the command-line by DavideNL on Sunday September 22, 2019 @10:55AM (#21041622)
That was fast, great!
Re:An interactive cheatsheet tool for the command-line by acoustep on Saturday September 21, 2019 @04:00AM (#21034086)
This looks really cool. I’ve been building something similar in Crystal to scratch my own itch - https://video.twimg.com/tweet_video/EEQqvAeWkAAx3-3.mp4
Re:An interactive cheatsheet tool for the command-line by oyebenny on Saturday September 21, 2019 @05:09AM (#21034283)
I want to use this, but I'm afraid of it be deprecated or not being maintained over time.
Re:An interactive cheatsheet tool for the command-line by davidjhall on Friday September 20, 2019 @10:49PM (#21033182)
Is there a key command or way to find out what's below the cheat? For instance, I tried the "local ip address" example in the demo and it gave the IP address but now 'how' -- ifconfig? was it in a text file? env var? script?
Re:An interactive cheatsheet tool for the command-line by mikelward on Saturday September 21, 2019 @12:01PM (#21036112)
Appears to be implemented here.

https://github.com/denisidoro/navi/blob/master/cheats/networ...

I'd nitpick on the implementation, but the point is you can change it. :)

Re:An interactive cheatsheet tool for the command-line by mikelward on Saturday September 21, 2019 @12:04PM (#21036124)
On Linux, you can do something more robust that also supports IPv6 based on

    ip -o a sh up primary scope global
Re:An interactive cheatsheet tool for the command-line by dnsfr on Saturday September 21, 2019 @07:46PM (#21038656)
Based on your input, the latest version has a preview window: https://user-images.githubusercontent.com/3226564/65380182-6....

Alternatively, you can use the --print option

I hope you like it!

Re:An interactive cheatsheet tool for the command-line by callmeschroeder on Saturday September 21, 2019 @10:49AM (#21035682)
Same idea as https://news.ycombinator.com/item?id=19436884 but more polished and faster.
Re:An interactive cheatsheet tool for the command-line by dnsfr on Saturday September 21, 2019 @07:47PM (#21038665)
I'll add it to the "alternatives" section
Re:An interactive cheatsheet tool for the command-line by pcr910303 on Friday September 20, 2019 @08:59PM (#21032782)
This is pretty cool! It’s great to see that lots of tools are trying to make the command line less intimidating, and adopting more friendly methods than the man pages.

About the cheatsheets itself, it might be great to share the cheatsheets with a project sharing somewhat similar goals, tldr.sh[0] (which focuses less on interactivity but more on completeness and practicality).

I’m more than excited to see the shell being more approachable. I have introduced the shell to quite a lot of my non-programmer friends with package managers and bulk renaming, but they don’t use the shell enough to memorize all of the commands. These efforts lower the barrier to use the shell... hence making the demonstration of the command line’s powers more easy.

[0] https://tldr.sh

Re:An interactive cheatsheet tool for the command-line by otroquecorre on Friday September 20, 2019 @08:53PM (#21032743)
Simply brilliant. Making bash easier
Re:An interactive cheatsheet tool for the command-line by apotheosis on Saturday September 21, 2019 @03:09PM (#21037260)
Would be neat if `navi git` started it up and applied a filter at the same time.
Re:An interactive cheatsheet tool for the command-line by dnsfr on Saturday September 21, 2019 @07:44PM (#21038643)
Cool! Will do it!

My only concern is that this way it would be impossible to add subcommands to navi

Let's say that in the future I want to add a command for removing a cheat (navi remove)

The way you described, it would look for snippets which contain "remove"

Any ideas?

Re:An interactive cheatsheet tool for the command-line by ozzmotik on Friday September 20, 2019 @10:43PM (#21033161)
oh this is really cool, thanks for sharing. i also really appreciate that you have links to other projects that offer similar features so people can contrast and compare and find what works best for them.
Re:An interactive cheatsheet tool for the command-line by rushi_agrawal on Friday September 20, 2019 @10:18PM (#21033085)
Similar concept: cheat.sh
Re:An interactive cheatsheet tool for the command-line by dnsfr on Saturday September 21, 2019 @07:47PM (#21038660)
I'll add it to the "alternatives" section
Re:An interactive cheatsheet tool for the command-line by kenshinji on Friday September 20, 2019 @08:55PM (#21032757)
Does it also work in zsh?
Re:An interactive cheatsheet tool for the command-line by OJFord on Friday September 20, 2019 @09:23PM (#21032868)
Not sure what you mean, the shebang line is bash, so you need bash installed, but invoking it from zsh shouldn't cause a problem any more than invoking anything else could.

If you meant 'why is the shebang line bash, isn't it POSIX compliant' - I don't know.

Looks nice though. Not sure I fully understand how the chaining/'prompts you for arguments' works (from UX perspective) but keen to give it a go.

Re:An interactive cheatsheet tool for the command-line by matthewtovbin on Saturday September 21, 2019 @02:57AM (#21033935)
Great tool!!!