628 points · by lordgrenville · 6y ago · 167 comments
curl cht.sh/trI would also say though that this cheat sheet looks great as well - cheat sheets absolutely have their place next manuals.
function cht() { curl cht.sh/$1 }
Note that https://cheat.sh works too (I find that easier to remember than cht.sh)
cheat () {
curl "cheat.sh/$1"
}e.g. http://cht.sh/tar
$ curl cht.sh/ls?style=bw
Or if you do like colors but not the defaults you can try other styles, see http://cht.sh/:styleshttps://zealdocs.org is another great source, similar to https://devdocs.io
cheat() {
curl "http://cheat.sh/$1"
}
man2txt() {
man "$1" | col -bx
}
manflags(){
man "$1" | awk '{$1=$1;print}' | grep "^\-"
} #man pages just the flags more or less, captures some extra
ubuman() {
w3m -dump "https://manpages.ubuntu.com/manpages/bionic/en/man1/"$1".1.html"
} # ubuntu web manpages note bionic, update with do release up
ubumanflags() {
w3m -dump "https://manpages.ubuntu.com/manpages/bionic/en/man1/$1.1.html" | \
awk '{$1=$1;print}' | grep "^\-"
} # ubuntu web manpages
explain () {
if [ "$#" -eq 0 ]; then
while read -p "Command: " cmd; do
curl -Gs "https://www.mankier.com/api/v2/explain/?cols="$(tput cols) --data-urlencode "q=$cmd"
done
echo "Bye!"
elif [ "$#" -eq 1 ]; then
curl -Gs "https://www.mankier.com/api/v2/explain/?cols="$(tput cols) --data-urlencode "q=$1"
else
echo "Usage"
echo "explain interactive mode."
echo "explain 'cmd -o | ...' one quoted command to explain it."
fi
}
# notetoself: check ```info``` check ```help``` check ```apropos``` check ```whatis``` ubuman() {
w3m -dump "https://manpages.ubuntu.com/manpages/$(lsb_release -cs)/en/man1/"$1".1.html"
}It would make a straightforward gui app for rofi or zenity or yad etc, with only one input and just a list of output.
man() {
(tldr $1 ; man $1) | cat | less
}
Edit: rewrote without the `&&` conditional tldr-web() {
w3m -dump "https://raw.githubusercontent.com/tldr-pages/tldr/master/pages/common/$1.md"
w3m -dump "https://raw.githubusercontent.com/tldr-pages/tldr/master/pages/linux/$1.md"
}Typical man pages are well, like learning a language by studying a dictionary, alphabetically. It may contain all information, but a clear F on UX. Some packages get slightly better with starting from the most common use cases, with examples (and digestible errors).
However, I would be even more interested to see what is the actual usage pattern (e.g. from .bash_history / .zsh_history). Do you know any datasets with longer such?
What I find annoying is the number of command line programs that don't even have man pages anymore. Or maybe that's just an artifact of installing them with brew?
What I find interesting is that for the most part (there are exceptions), the older the man page, the more useful it is. Realistic examples. Succinct descriptions. User-friendly terminology. Too many of the newer man pages seem inflated and full of jargon to make themselves seem important or worthy.
Ubuntu pull most of its packages from Debian, and Debian Policy says that every package that provides binaries should provide manpages for them as well. It is not a hard requirement but their absence is considered a bug.
A messed-up MANPATH environment variable can also cause man pages to not be found. In ‘man’ used on many flavors of Linux, MANPATH behaves differently from, say, PATH: an empty colon-delimited section means something like “use the system’s regular ‘man’ configuration for finding man pages”. Without that, it seems like a bad MANPATH setting will cause default mannpages not to be found.
It's simply a lot harder to explain things in simple language, so I'd hesitate to ascribe such intent.
One of the best things that ever happened in my career was having a desk across from the entire SunOS manual set. I'd pull them down one at a time and read them, cover to cover. It paid off, big time, and I strongly recommend it.
One day I saw “type ‘man man’” and “apropos” written on a chalk board.
That is how I learned Unix.
* https://unix.stackexchange.com/a/448799/5132
There was also "learn", in BSD as I recall.
tldr caters to an entirely different heuristic: I have this use case, give me a list of use cases and the corresponding combination of switches, options and arguments for each respective use case. tldr won't explain to you what each individual switch, option or argument does, turning the provided commands into black boxes.
Here's the trade off:
The former has a steep learning curve and figuring out how a tool works doesn't solve your immediate problem. But if you commit the meaning of switches, options and arguments for common tools such as awk, sed, tar, ls,... to memory, you will become proficient at solving any problem with a few tools over time.
The latter has a low learning curve and you just have to copy/paste a command to solve your problem. But tldr won't tell you how those switches and options work. And you will just use them as incantations that magically help you to solve a limited number of cases. If you end up with a use case that isn't listed, you are left in the dark as far as tldr is concerned.
So, is tldr a bad tool then? No! If you are confronted with the command line sparingly, then tldr helps to lower the bar and solve your immediate problem. But if you hope to grow into a proficient shell user, then you're still going to have to grok the man pages one switch, option and argument at a time.
I'm a polyglot. Studying a language by opening a dictionary and starting alphabetically, is arguably, the worst way to get there. You would start with learning a set of common words and basic grammatical rules, and then expand over time through practice and instruction: speaking, reading and writing.
The same applies to command line tools and man pages: they are reference materials first and foremost.
Man pages for newer tools, like all of the lvm utilities, include examples at the end.
I would like to see it similar to what powershell has with their examples built into the documentation.
No, thankfully.
Try `man man | col -b | grep EXAMPLES`
(As an example, grep was finding EX but not EXA. Man told me I could pipe to col -b to strip formatting, hinting the issue might be special characters. This was quite helpful of them, even if it isn't strictly "man's responsibility".
OTOH, sometimes I'll copy-paste some perl or awk dark magic from Stack Overflow, and then try modify it piecemeal to fit my case. That's an incantation :)
I think that largely depends on who's using the tools and how acquainted they are with command line tools. An absolute beginner likely will not know what tar's 'f' flag does, or assume something else.
> OTOH, sometimes I'll copy-paste some perl or awk dark magic from Stack Overflow, and then try modify it piecemeal to fit my case. That's an incantation :)
And I absolutely have no qualms doing the same when push comes to shove. Ain't nobody always got the time. ;-)
The man pages are community driven, too. If you think they can be improved, instead of investing in rapidly decaying third-party documentation, please take your improvements upstream. The maintainers would be thrilled to have them.
Man pages are a reference/spec on all options and parameters, aimed at those who already have use a tool/technology/concept.
This is something different. It's a tutorial of how to do the most common things using that tool.
It's a bit like learning a programming language: would you read the formal spec, or would you learn from code examples?
Unless you've read formal specs for other languages with a similar paradigm before, it's way easier to learn from examples first, which gets you to the level of understanding where the formal specs start to make sense.
Improvements to man pages should be made, but not at the cost of beginner-friendly projects.
Many man pages contain examples and common usages. See for example the rsync man page, with complete examples of how to backup common file systems.
An examples section in a manpage is a fine idea which I would certainly encourage, but that wouldn't render tldr obsolete.
I agree, but I'm also painfully aware of man page incompleteness every time I'm on a non-OpenBSD system. I'd be grateful to anyone who chipped away at proper tagging for any GNU software. One should be able to :t to jump to the reference for any flag.
For tagging, the formatting would need to be redone to be mdoc, which breaks both the OSes mentioned above and would be an immensely arduous task at this point. Probably not going to happen.
Note GNU and and the Linux man-pages project are mostly outliers; everyone else that lives in BSD/illumos land has long since moved on to mdoc since like the 80s. See also https://www.usenix.org/system/files/login/articles/141-dzons...
Also, a gentle, human oriented intro can be a part of man page I think.
I don't see why they could not serve both purposes.
Man pages should start with a tldr section followed by the full reference/spec.
Looking at some examples of tldrs, it mostly boils down to the most common use cases as examples. So well written man pages already have an "examples" section, and that really helps!
Have you tried talking to any of the projects?
The focus has been making it easier for the developers to write literally anything. One thing uses sphynx another uses man another uses doxygen or what the hell ever. Users aren't developers. This is why everyone ends up on google and ends up on stackoverflow or random blog or watching youtube.
The barrier to entry is much lower with some simple markdown thing. Hell, I was thinking about how to abuse this thing to make my own notes about commands.
While some man pages have examples, I don't know if man page writers see their job as teaching readers how to use a utility. The goal of man pages more often seems to be _reminding_ a person already familiar with the tool how to use a tool.
I'm, umm, _reminded_ of project READMEs. I've come to assume that when I go to a project on GitHub, I'm going to get everything I need (or pointers to everything I need) to get started with a project, but often there's a project web site that is intended to serve that purpose. I just ran into this yesterday with Falcor.
Not all man pages are like this obviously. Specifically, the section three man pages on C functions do a good job fully documenting functions.
1. Including tar -cf and tar -xf probably the two you want to run in most cases. See: https://linux.die.net/man/1/tar
Would they?
The tldr.sh site prominently offers a sample of usage examples for a command; tar specifically. If one checks the tar man page there are no examples. This is policy, apparently promulgated by GNU et al. in favor of "info". I haven't the time right now to hunt down the official position, but here[1] is a SO discussion.
Should this TLDR thing correct that long standing mistake I'm all for it. Also, info is one of the most hostile TUI programs I've ever encountered and I resent using it.
[1] https://unix.stackexchange.com/questions/306189/why-dont-man...
* https://www.freebsd.org/cgi/man.cgi?query=tar#EXAMPLES
* https://man.openbsd.org/tar#EXAMPLES
* https://illumos.org/man/1/tar#examples
* https://www.ibm.com/support/knowledgecenter/ssw_aix_72/t_com...
* http://osr507doc.sco.com/cgi-bin/man?mansearchword=/usr/man2...
You are clearly very limited in your user manuals. (-:
(and one currently can't, given the unmodified man page from the most recent 1.32 release)
And when I shell into an OpenBSD server their man page for tar has several examples at the bottom of the page.
Man, IMO, is a lot like Linux distros in that they are not all created equal, pull from a lot of different sources and can be inconsistent if you're not looking at the correct ones for whatever system you are on.
I too think TLDR is a good idea but that's no reason not to encourage that some of their work be ported back to man pages in their examples' sections.
1.23 March, 2012: no examples (RHEL 6)
1.26 March, 2015: no examples (OpenSUSE 13.1)
1.26 February, 2016: no examples (CentOS 7)
1.29 March, 2016: limited examples (Ubuntu 1804)
The last has no actual "EXAMPLES" section in the man page; only some incidental examples appearing among a discussion of "Option styles." I suspect this is also what you see; it's in the same position in the page. So there is some evidence that examples aren't entirely prohibited in GNU man pages, at least in recent years. Progress, I guess. The latest work on this man page (release 1.32) shows no further progress.TLDR goes well beyond those incidental examples and is far closer to what I'd hope to see; first class, worked example forms eagerly supplied. Without suffering info.
Something definitely can't be both first-party and community.
Whether documentation gets read or not probably depends on its Google ranking more than anything.
Remember, these are the same people that claim the Emacs and Vim are better to code in, and that IDEs are for inexperienced/lazy coders.
With a man page you know you're getting the right info because it came bundled with the tool.
If I type "man ps" I see
Man: find all matching manual pages (set MAN_POSIXLY_CORRECT to avoid this)
* ps (1)
ps (1p)
Man: What manual page do you want?
What if I instead saw Man: find all matching manual pages (set MAN_POSIXLY_CORRECT to avoid this)
* ps (1)
ps (1.tldr)
ps (1p)
Man: What manual page do you want?
where the man command retrieved that information from the TLDR-pages site?In the last years we have seen many innovative Rust re-implementations of classical commands such as cat, find, grep. Maybe the man command is next up?
However, realistically at the moment I don't see man pages competing with the spirit of tldr/bro/whatever, and I suspect that PRs geared towards making them compete would in fact be rejected by most projects.
Since they don't, we use bropages, tldr, etc.
EDIT: My idea is of course not new, see https://github.com/joelekstrom/tldr-man for a way to convert these docs to man pages.
This is a good opportunity for me to compare the out-of-the-box results from tldr vs man:
https://linux.die.net/man/1/man
"Why not just install these as man pages in their own section and read them with man?" Because downloading the default program is much easier, most users aren't that concerned about adding a small CLI program on their computer, and most aren't that purist about right way to read documentation is through manpages.
And I also don't see why installing that is easier than installing man pages, if appropriately packaged. (I'm not claiming they are currently appropriately packaged, I'm just saying that's what they could have done instead of writing a client.)
I just found that and installed it after reading this thread. It looks like on first run, like "tldr tar", it calls "git clone" on some repo. Thereafter, other incantations like "tldr grep" use the already local repo. And the repo can be updated with tldr --update. Seems very fast.
There are a large number of clients listed here
"Bro pages: like man pages, but with examples only"
I can find simple instructions for almost any tool with a search like "Convert flac to opus ffmpeg"
Is there a simple way to install it without having to install Node.js or Haskell or Ruby? (I don't want to install Node.js just for it)
Is there a
apt-get install tldr
solution on recent Debian / Ubuntu distros without installing another additional package manager?I mean even the bash solution:
bpkg ...
does not work out of the box.(bpkg or brew or npm aren't installed by default)
2) Is TLDR linked with the project cht.sh? e.g curl cht.sh/tar? Does it share a common source of documentation are they two totally different projects?
3) Few people won't remember tldr.ostera.io (I won't)... Ok we have bookmarks, but still, it would be more convenient if we could just do:
tldr.sh/tar
tldr.sh/git_push
instead of having to remember ostera.tldr.io oh no ostera.tldr.sh oh no tldr.ostera.sh no...* http://www.gnu.org/software/tar/manual/
BSD systems, for example, have much better man pages that have an actual "EXAMPLES" section near the bottom.
man man | grep -A 10 EXAMPLES
man tar | awk -F , '/-v,/ {print $2}'
Related from 2014: https://news.ycombinator.com/item?id=7166257
For a code equivalent, Rust encourages function level documentation. This gives you detailed information on the full API surface and is vital, but if you only had that you wouldn't know where to start. Rust also has the 'examples' directory (I'm talking about a library project) which usually has a few executables that use the library.
I go to man once or twice for tools that are entirely new to me. Then, I use tldr until I have muscle memory or using a feature that is new to me.
I would expect such a tool to work so that whenever `man X` produces a long document, searching for X in the tool produces a shortened, example-focused documentation. This is not the case.
Fortunately, there are other clients, some of which are much faster. My current favorite is tealdeer:https://github.com/dbrgn/tealdeer
I think they've improved greatly, but man pages on Debian, Ubuntu et al. still feel a bit like second-class citizens.
What TLDR pages seem to be getting right is putting EXAMPLES first or second rather than last, and/or having a command to bring up EXAMPLES.
Also I want to put in a plug for AUTHORS/HISTORY and BUGS sections. The former can create a sense of community and context and the latter can point out annoying gotchas.
* http://cr.yp.to/daemontools/multilog.html
* http://jdebp.uk./Softwares/djbwares/guide/commands/multilog....
Now please someone do something similar with Apple developer documentation.
brew install tldr
EDIT to add: and so can the faster (caching) Rust version (note: install one or the other, not both, since they use the same `tldr` command) brew install tealdeer- this is advertising dressed up as a "community man page"