647 points · by quickthrower2 · 8y ago · 165 comments
If you don't want to install anything new, you can also write your own man pages with a personal "man section". Just do something like this in your shell:
export MANPATH="$MANPATH:$HOME/man"
export MANSECT="1:n:l:8:3:2:3posix:3pm:3perl:5:4:9:6:7:pj"
Here I've added the "pj" section (my initials).Then I have files like ~/man/manpj/postgres.pj or ~/man/manpj/ssl.pj. I can say `man pj postgres` to see my own notes. My own collection goes back to 2001 or so. I feel lucky that early on I started putting notes into something so portable. It's one of the few things that has always moved with me to new machines. It is here: https://github.com/pjungwir/manpj/
You don't even need to use proper man formatting if you don't want to. I find that a plain text file comes out pretty well. And when you want to start adding sections/etc, there are only a handful of formatting codes to learn (or copy/paste). I got started from a tiny chapter in O'Reilly's Unix in a Nutshell. You're welcome to steal from my own repo above. (I'm sure the formatting is nowhere close to best practice, but it's good enough for personal use.)
To be fair, sometimes it's just because the usual tool is unfriendly. I've just spent 30 mins to extend my manpath as parent suggested (on osx), and it's not working. I have my variables, I have my directories, I have my text files, and still man can't find them. For a tool as old as man, there is precious little debugging information available. It shouldn't be this hard.
It looks to me like OS X will only search for sections named 1-9 (and maybe "n" too). The MANSECT variable doesn't override this behavior. (I guess it just changes the priority then?)
But you can have a custom suffix after a number. So if you have ~/man/man7/postgres.7pj (note just a 7 for the folder, but 7pj for the file extension), you can open that file by saying `man 7pj postgres`. This is how other programs with a lot of man pages work, e.g. `man 3perl open`. It's not as nice to type a 7 too, but it's the best I can find that works. So I guess on OS X you'd still set MANPATH but can leave MANSECT alone. (You could also probably usurp section 9 or something, and omit your initials entirely.)
Or maybe you could compile a better `man` and put it in ~/bin. :-/
. . . In fact, I find that if I have ~/man/man7/postgres.7pj, I can even type `man xpj postgres` to get my page. Maybe OS X man is just buggy?
Literally so, if you consider that "ум" in Russian means "mind / intelligence", and "um" is the transliteration of that into Latin alphabet, making it a bilingual pun.
"Just use your Um!"
1:1p:8:2:3:3p:4:5:6:7:9:0p:tcl:n:l:p:o
I guess one should really have a script that first greps out that default value, and then appends your custom section before exporting the variable.
EDIT: something like:
export MANSECT=$(pcregrep -o1 MANSECT\\s\{2,\}\(.*\) /etc/man.conf):pj
umedit() { mkdir -p ~/notes; vim ~/notes/"$1.txt"; }
um() { less ~/notes/"$1.txt"; }sphinx.builders.manpage: http://www.sphinx-doc.org/en/master/_modules/sphinx/builders...
umedit() { mkdir -p ~/notes; vim ~/notes/"$1.md" }
um() { pandoc -s -t man ~/notes/"$1.md" | tbl | groff -Wall -mtty-char -man -Tascii -c | less -R }
Not sure if pandoc creates tbl tables ;). function mdless() {
pandoc -s -f markdown -t man $1 | groff -T utf8 -man | less
}
umedit() { mkdir -p ~/.notes; vim ~/.notes/$1; }
um() { mdless ~/.notes/"$1"; }
umls() { ls ~/.notes }
This way I can write the notes in markdown and view them as such in `less`.Example provided on the FreeBSD man page of cut.
Examples provided on the Linux man page of xargs.
More examples provided on the Linux man page of find.
The xargs man page is ought to have some examples, I agree.
The find manual is lengthy (as it has a bunch of options) but not excessively so and it also has a good bunch of examples.
Edit: it also helps to be familiar with the pager, like using the search feature (hit / , n, n, Shift+n, ...) and the jump keys (G and g).
Those who can't, teach
Those who can't teach, write
Those who can't write, write man pages
Rather a disappointment.
What happened to ‘info’ pages. I hated it, but wasn’t that supposed to address these kinds of issues with examples?
$ info grepSee e.g. https://metacpan.org/pod/release/PHRED/Archive-Zip-1.62/lib/...
This other response says it better: https://news.ycombinator.com/item?id=17801788
This is an honest question. Friction and barriers to entry reduce contributions.
I've tried in the past, it doesn't work out (not man pages, but I was fixing a bug and yeah, three, four submissions was enough for me to quit trying)
lrf, guvf vf n cha
1. You need Pandoc. On Debian, Ubuntu, etc. this is: `sudo apt-get install pandoc`. I'm sure there's a similar incantation for Arch and so forth, but I can't be arsed. If you don't already have Ruby installed in your system, you'll need that too.
2. cd into your favorite personal toolbox directory and `git clone https://github.com/sinclairtarget/um.git`
3. Add a symlink to um in /usr/local/bin: `sudo ln -s /your/path/to/um/bin/um /usr/local/bin/um`. Make sure you're symlinking to the um script, not the um directory.
That's it. Enjoy.
Nice little widget. I like it.
Hahaha, exactly. There are some commands that I just don't use enough for them to properly stick in my mind. Awk is another one. This utility would be helpful for me. Thanks!
cp a.txt b/c/d
Will this create a new file "b/c/d/a.txt", or will it create a new file "b/c/d"? It's not clear, and depends on the circumstances (if a directory b/c/d exists). There's a flag to control the behavior, but nobody uses it often, so nobody remembers that flag. The best way to assert that "d" is a directory is by adding a trailing slash, but there's no similar way to assert that "d" should be a file. I suspect that there are many bash scripts that are essentially broken because of this problem.Rsync has a similar problem.
tar xzf $file
- xtract
- ze (actually gzip but fake-accent "the" is more memorable)
- filebomb disarmed
Right now, I usually grep the man pages to search for things relevant to specific context. Something like,
man find | grep -i --color=always -C10 "file name"
Worked well in most cases. So, for figuring out how to send a POST request, I would try man curl | grep -C10 --color=always POST
If that bombs, I would then immediately try curl --help | grep --color=always POST
If I end up using certain set of flags frequently, I will set up a bash command like most others. Or, make a weird joke out of the flags, for example, ls -lionshit- open a real manpage `um grep`.
- add a custom field to it, like "personal notes", at the beginning or at the end, whatever.
- save the new manpage in my home directory, so each time I do `man grep` that custom manpage is used and I see my own notes.
Usually I’ll have two or three konsole windows open at the same time, and I’ve noticed that only one of them appears in the bash history...is there an easy way to have it store all the history from all the windows?
https://askubuntu.com/questions/23630/how-do-you-share-histo...
It is possible to get similar effects by kludging around with bash, but it's a built-in feature in zsh.
shopt -s histappend
In your .bashrc. Note that history is only saved when the shell exits, so new shells will only see history from other shells that have already exited.Depends on who you ask: for me the best part of delivering software which I wrote is writing the manual pages in straight nroff in vi, with lots of examples. Seeing the engine typeset my documentation exactly the way I want is always an awesome feeling.
It looks like to me that “um” is a reactionary effort because of the notoriously poor quality of GNU/Linux manual pages which often lack examples; if so, then the solution is to switch to a higher quality operating system like FreeBSD or SmartOS / illumos.
You are always free to install manpages, however only one manpage per name IIRC.
In this case, I'd just namespace it so you avoid any conflicts.
i.e.
man git
And man um.git
So both are preserved.(Because I can't be bothered installing Ruby or dealing with it at all. I've never had a good experience. Sorry if that upsets you.)
Why are there no scriptreplay/asciinema 'videos' available within normal man pages? I mean yes, just a few more basic examples would certainly help more, but for some more complicated commands a video might help too.
I can see myself running `um git` literally before every invocation.
This needs integration with voice assistants.
vim ~/doc/nginx-snippets.txt # edit
vim ~/doc/nginx-snippets.txt # consult
I actually have more files, config samples and source code templates, so it’s not just ~/doc/.txt, but having them all in man registry would require yet another better apropos(3) replacement. I also have my own vim colors format that is much better looking to me than md^. I know that my argument may turn similar to ‘dropbox is easy via ftp mount’, but I can’t see any need for a tool even for my relatively big snippet-base. Moreover, with vim I can gf, grep -r, edit :w, etc. And with just files it is subject to svn/sh/make, unleashing the full power of unix. --^ just two levels of section headers, and :tags, all readable without color. Based on dead-simple regexps, so in theory I could |sed them into terminal escapes in five minutes.
“Um, how do I use this tool again?”
CLI tool to show simple examples instead of a full man page http://tldr.sh
View programming language and library documentation offline and in a single place http://devdocs.io
Cheat sheets for command line tools, programming languages, and libraries https://devhints.io
(Perhaps using a git repository, and GitLab?)
I can see that there may be instances where you/your company would like to have internal docs that should not be public and this utility would would work for it
I’ve never found actual help at the command line, delving any deeper beyond the --help switch.