Um – Create your own man pages so you can remember how to do stuff
github.com
github.com
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?
This could be the one time I actually find a good way to note down examples for later reuse. Thanks!
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
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!"
umedit() { mkdir -p ~/notes; vim ~/notes/"$1.txt"; }
um() { less ~/notes/"$1.txt"; } 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`.function mdless pandoc -s -f markdown -t man $argv[1] | groff -T utf8 -man | less -c end function umedit mkdir -p ~/.notes; nvim ~/.notes/$argv[1]; end function um mdless ~/.notes/"$argv[1]" end function umls ls ~/.notes/ end
(reminder, to make them permanent just: `funcsave mdless umedit um umls`)
I can share my man pages with git/github, but nobody will notice them, nobody will fix my spelling errors or contribute additional information.
Is there something like wiki, but for man pages?
yes. it's the source repo for whatever app you want improved man pages on. Everyone can submit changes to it. All the good ones get merged in. It's effectively a wiki curated by the most knowledgeable people on the subject.
um solves a different problem though. It's not trying to make a _common_ man page. It's trying to make a man page that works _for you_. What _you_ need to be highlighted is likely different from what _I_ need to be highlighted.
Personally I don't _want_ a generic wiki man page for stuff. I like the man pages written by the creators of the code (because i know they're correct), combined with my notes highlighting what's important to me.
function umedit() {
mkdir -p ~/.notes
if [ ! -f ~/.notes/$1.md ]; then
echo "% $(echo $1 | tr '[:lower:]' '[:upper:]')(shell) Um Pages | Um Page" >> ~/.notes/$1.md
echo "\n# NAME\n$1 - $(whatis $1 2> /dev/null | cut -d '-' -f 2 | awk '{$1=$1};1')\n\n# COMMANDS" >> ~/.notes/$1.md
fi
vim ~/.notes/$1.md
}sphinx.builders.manpage: http://www.sphinx-doc.org/en/master/_modules/sphinx/builders...
What happened to ‘info’ pages. I hated it, but wasn’t that supposed to address these kinds of issues with examples?
$ info grepThe info for gcc is a printed book, which is also accessible in the shell as hypertext (which predates html).
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).
lrf, guvf vf n cha
See e.g. https://metacpan.org/pod/release/PHRED/Archive-Zip-1.62/lib/...
Those who can't, teach
Those who can't teach, write
Those who can't write, write man pages
Rather a disappointment.
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)
> The time you spend on the man page is time taken away from more useful work.
Making sure your users know how your program works, how to use it and what it's capable of seems incredibly important and useful to me.
If it weren't for Arch Linux's fantastic focus on documenting everything to do with Linux, I wouldn't be using Linux at all.
See https://www.gnu.org/prep/standards/html_node/GNU-Manuals.htm...
https://www.gnu.org/prep/standards/html_node/Documentation.h...
1. One account for manifesting your chosen identity, which you likely already have.
2. One common way of getting the source code and sending diffs/patches (read: PRs).
The workflow is quite similar, in the abstract. But GitHub and friends solve important pain points.You also have an email address, so. You need an email address to get a GitHub account, so technically it's harder to set up GitHub.
2. One common way of getting the source code and sending diffs/patches (read: PRs).
This is built into git. Don't need GitHub for either.
Perhaps the last argument I have is that I've heard a number of times about moving a project to GitHub (for example: the Go language or Vim the editor), but decidedly less often one hears of projects moving away from GitHub towards older forms (such as the wonderfully documented https://gcc.gnu.org/contribute.html). Despite the great documentation, I'm somehow not drawn to hacking on it to fix a small glitch, due to the overhead that entails. Mind, some of that overhead would be incurred just once, as it is general to the mailing list approach to collaboration. That, I believe, is another advantage of a project being on GitHub: for almost all projects there's a standard way of sending your patch: make a pull request.
About your counterpoints:
1. True. I was thinking of the bug trackers many mailing-list oriented projects have, which often require creating accounts just to file a bug. 2. I was more referring to things like (1) where to find the clone URL and (2) how to send a patch (the make a PR button is always the same).
Removing friction (even small frictions) will enable fishing for the long tail of small fixes. On the other side, I do not believe large contributions are greatly affected by the differences between these systems.
That’s not to say that Github pull requests and the like are perfect (far from it) but it’s undeniable that they smooth the process quite considerably and make contribution far more accessible.
This other response says it better: https://news.ycombinator.com/item?id=17801788
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!
tar xzf $file
- xtract
- ze (actually gzip but fake-accent "the" is more memorable)
- fileThe history of tar is quite long, but the short version is that it was first released as part of 7th edition Unix. It was a successor to tp[1] which was introduced in 4th edition Unix, which was a successor to tap[2] which was released in 1st edition Unix. In 1st edition Unix (as far as I could tell from looking through the man pages), no command had '-abc'-style flag support at all (so tap's semantics made sense). I imagine that quite a few users did something like 'alias tap=tp' and 'alias tp=tar' when upgrading, and so CLI backwards compatibility was required. As a result, everyone learned to use tar that way and it stuck.
[1]: http://man.cat-v.org/unix-6th/1/tp [2]: http://man.cat-v.org/unix-1st/1/tap
I guess the lack of '-' with tar is more apparent because POSIX didn't create a different syntax, and so most people omit the '-' for terseness -- while with ps it would require learning a different syntax.
I too use the BSD form but came from the Linux world. Probably it is just a matter of taste (a common answer to everything!).
> I guess the lack of '-' with tar is more apparent because POSIX didn't create a different syntax, and so most people omit the '-' for terseness -- while with ps it would require learning a different syntax.
I argue the ps situation is worse than tar exactly because of that reason. There are three different classes of options in ps, often with slightly different meanings and sometimes with two different long-form options only distinguished by their cases...
Make is another famous victim of this:
> Why the tab in column 1? Yacc was new, Lex was brand new. I hadn't tried either, so I figured this would be a good excuse to learn. After getting myself snarled up with my first stab at Lex, I just did something simple with the pattern newline-tab. It worked, it stayed. And then a few weeks later I had a user population of about a dozen, most of them friends, and I didn't want to screw up my embedded base. The rest, sadly, is history.
Bad example, since tar still works with a dash:
tar -ztvf foo.tar.gz
> Make is another famous victim of this:Now that is a much better example.
- all unix commands support both short and long options
- option letters/names are, at least to a much greater extent than currently, common across different commands
tar caf $archive $file... to create
tar xf $archive to extract
"x" will automatically recognize the compression format, and "ca" will automatically infer the desired compression format from the extension in $archive, e.g. tar caf backup.tar.xz /home/user
makes an xz-compressed tarball. 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.
bomb 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.