JMM’s notes on

Man pages

Format a man page as XHTML:

man -Txhtml ls > ls.xhtml

Here’s how to output plain ASCII without ANSI escape sequences:

MANWIDTH=80 man -Z -Tascii ls | grotty -c

Here’s how to find out where a manpage is located:

$ man --where ls
/nix/store/jmy11m3c935yyvs4njz3s52p9azgvg6f-coreutils-full-9.3/share/man/man1/ls.1.gz

You can format this local file like so:

man -l /nix/store/jmy11m3c935yyvs4njz3s52p9azgvg6f-coreutils-full-9.3/share/man/man1/ls.1.gz

If you use Nix shells a lot, here’s a script that’ll open a man page within Emacs:

#!/usr/bin/env bash
# This just looks up a man page but opens it with emacs.
# I use this within nix shells, where man paths aren't visible in the global environment.
set -euo pipefail

theloc="$(man --where "$1")"
emacsclient --create-frame --no-wait --eval "(man \"$theloc\")"