# um
`um` is a command-line utility for creating and maintaining your own set of
`man`-like help pages. It is available for MacOS (via
[Homebrew](https://brew.sh/)) and Linux (via AUR in Arch, otherwise via
Homebrew, which is [now on Linux](https://docs.brew.sh/Homebrew-on-Linux)).
### Why?
Have you seen how long `curl`'s man page is? How many times have you gone
through it trying to figure out how to make a POST request?
Man pages are written to be comprehensive, but what humans really need are the
bullet points. Use `um` to write your own `man`-like help pages that reflect
what you've learned about a command so far. That way you have an easy
reference for the things you already know are useful.
### An Example
Say you've just reminded yourself how `grep` works for the third time this
month. You'd like to hold on to that precious knowledge so you don't have to go
digging through the `grep` man page again. You can do that with `um`:
```
$ um edit grep
```
This will open your text editor, allowing you to record everything you want to
remember about `grep`. Once you've saved what you've written, you can pull it
up again as easily as you would any man page:
```
$ um grep
```
This will open your pager with whatever you might have for `grep`, say:
```
GREP(shell) GREP(shell)
NAME
grep -- Print lines matching a pattern
SYNOPSIS
grep [OPTIONS...] pattern [FILE...]
REGEX SYNTAX
. Matches any character.
^ Anchors pattern to beginning of line.
$ Anchors pattern to end of line.
[] Character set. ^ for negation, - for range.
OPTIONS
-r Recursively search listed directories.
-E Force grep to behave as egrep, accepting extended REGEXes.
Um Pages September 26, 2017 GREP(shell)
```
`um` supports several additional sub-commands. Among them are:
* `um list`, which lists all the um pages you already have.
* `um rm`, which removes an existing um page.
* `um topic`, which switches between topic namespaces for your pages, allowing
you to keep a separate set of um pages for css properties, for example.
### Um Page Format
Man pages were [historically typeset using the `roff` typesetting
system](http://twobithistory.org/2017/09/28/the-lineage-of-man.html). `roff`
was basically an early LaTeX. Writing man pages using `roff` today is not very
fun or intuitive.
Happily, the Kramdown library can be used to convert Markdown documents to
`roff`-like man pages. (Previously, `um` used Pandoc. See
[UPGRADE.md](/UPGRADE.md) if the switch to Kramdown has broken your um pages.)
By default, `um` expects you to write your um pages in Markdown so that it can
convert them and pass them to the `man` program to view. You can, however,
elect to just write your um pages as `.txt` files and view them without going
through the `man` program.
Below is the Markdown source that produced the `grep` listing above. Except for
the Kramdown-specific attribute syntax (all the fiddly curly brace bits), it's
all just Markdown:
```markdown
# grep -- Print lines matching a pattern
{:data-section="shell"}
{:data-date="September 26, 2017"}
{:data-extra="Um Pages"}
{::comment}
^ The Kramdown "attribute list" which provides metadata for the page.
The first heading must include the name of the command and a summary.
{:/}
## SYNOPSIS
{::comment}Top level Markdown headings become man section headings.{:/}
**grep** [OPTIONS...] *pattern* [FILE...]
## REGEX SYNTAX
{::comment}Here we're using a "definition list" to get that man page look.{:/}
`.`
: Matches any character.
`^`
: Anchors pattern to beginning of line.
`$`
: Anchors pattern to end of line.
`[]`
: Character set. ^ for negation, - for range.
## OPTIONS
`-r`
: Recursively search listed directories.
`-E`
: Force grep to behave as egrep, accepting extended REGEXes.
```
See [Configuration](#config) below for more information on changing the default
um page format. See the [Kramdown Man Converter
Documentation](https://kramdown.gettalong.org/converter/man.html) for more
information about Kramdown's flavor of Markdown and the formatting options
available to you when you are writing a man page.
`um`'s own [man pages](/doc) are written in Markdown and converted using
Kramdown, so they could also make a good reference.
## Installation
* **MacOS/Linux:** `um` is available via [Homebrew](http://brew.sh/):
```
$ brew install um
```
* **Arch Linux:** `um` is available via the AUR in two versions: the release version [`um`](https://aur.archlinux.org/packages/um/) and the latest master [`um-git`](https://aur.archlinux.org/packages/um-git/)
### Post-Installation
A bash completion script for `um` is installed to
`/usr/local/etc/bash_completion.d`, assuming you're using the default `brew`
prefix. You may need to add the following lines to your `~/.bash_profile` to
enable the completion:
```
if [ -f $(brew --prefix)/etc/bash_completion.d/um-completion.sh ]; then
. $(brew --prefix)/etc/bash_completion.d/um-completion.sh
fi
```
## Help
Refer to `um help` for comprehensive documentation of the sub-commands and
options available for `um`. Man pages are also available.
## Configuration
You can configure `um` using a file called `umconfig` placed in a folder called
`.um` in your home directory. The syntax for setting an option is as follows:
```