Man

Manual pages from the command line

Wednesday, Apr 1, 2020

man

Using Manpages

Useful man commands

macOS

brew install man-db
path=(/usr/local/opt/man-db/libexec/bin ${path})

Opening manpages using NeoVim

MANPAGER='nvim +Man!'

Caching manpages

Some manpages take forever to load, even on modern computers. The main culprit that inspired this post was zshall(1), which takes 8 seconds to load on my machine. I was able to get it down to 2 seconds by caching a processed version of each manpage on my computer. Even with over 8,000 manpages, the total size of the cache only ended up being 20MB large.

MANPATH

You shouldn’t need to set the MANPATH environment variable, but here are some useful commands

manpath
manpath -c

Random Notes

Making a PDF of a manpage

# Saving the produced manpage before opening it
man -t grep > ./grep.ps
open -a 'Preview' ./grep.ps

# Directly opening the file through a pipe
man -t grep | open -f -a 'Preview'

Useful statements macros

Making a table

Example:

.PP
.TS
l l l.
Macro	Meaning	Subsection
.T&
lB l l.
_
\&.B	Bold	Font style macros
\&.BI	Bold, italic alternating	Font style macros
\&.BR	Bold, roman alternating	Font style macros
\&.EE	Example end	Document structure macros
\&.EX	Example begin	Document structure macros
\&.I	Italic	Font style macros
\&.IB	Italic, bold alternating	Font style macros
\&.IP	Indented paragraph	Paragraph macros
\&.IR	Italic, roman alternating	Font style macros
\&.LP	(Left) paragraph	Paragraph macros
\&.ME	Mail-to end	Hyperlink and email macros
\&.MT	Mail-to start	Hyperlink and email macros
\&.OP	(Command-line) option	Command synopsis macros
\&.P	Paragraph	Paragraph macros
\&.PP	Paragraph	Paragraph macros
\&.RB	Roman, bold alternating	Font style macros
\&.RE	Relative-indent end	Document structure macros
\&.RI	Roman, italic alternating	Font style macros
\&.RS	Relative-indent start	Document structure macros
\&.SB	Small bold	Font style macros
\&.SH	Section heading	Document structure macros
\&.SM	Small	Font style macros
\&.SS	Subection heading	Document structure macros
\&.SY	Synopsis start	Command synopsis macros
\&.TH	Title heading	Document structure macros
\&.TP	Tagged paragraph	Paragraph macros
\&.TQ	Tagged paragraph continuation	Paragraph macros
\&.UE	URL end	Hyperlink and email macros
\&.UR	URL start	Hyperlink and email macros
\&.YS	Synopsis end	Command synopsis macros
.TE

Useful macros

Anatomy of a Manpage

  1. TH: Title heading
.TH "LS" "1" "March 2019" "GNU coreutils" "List Files"
  1. SH: Section Heading