lm – list manual pages

I have wanted this for… probably half of my life?

lm (see https://woozle.org/papers/plan9.html) apparently existed in Plan 9 many years ago; it wraps apropos (and is similar to man -k) so that instead of just listing names and sections of manual pages, it sets up the line to have the man section whatever command at the start of the line, so that the gentle user may copy and paste this to a command line, because that’s almost certainly what the gentle user intends to do next.

I reimplemented it as a zsh function, because, well, why not?

(|N/A:default)cbbrowne@cbbrowne2 /tmp> lm ()
{
  apropos -l "$@" | sed 's/(.) ((.)) * - /man \2 \1 # /'
}

So, how does this work?

(|N/A:default)cbbrowne@cbbrowne2 /> lm dockerfile
man 1 docker-build # Build an image from a Dockerfile
man 1 docker-builder-build # Build an image from a Dockerfile
man 1 docker-image-build # Build an image from a Dockerfile
man 5 Dockerfile # automate the steps of creating a Docker image
(|N/A:default)cbbrowne@cbbrowne2 />

Awesome, no?