Hacker News new | past | comments | ask | show | jobs | submit login

Here's mine:

  examples ()
  {
    man $1 | less +/^EXAMPLES
  }
Usage:

  $ examples su
  EXAMPLES
       su -m man -c catman
              Starts a shell as user man, and runs the command catman.  You will
              be asked for man's password unless your real UID is 0.  Note that
              the -m option is required since user “man” does not have a valid
              shell by default.  In this example, -c is passed to the shell of
              the user “man”, and is not interpreted as an argument to su.
       su -m man -c 'catman /usr/share/man /usr/local/man'
              Same as above, but the target command consists of more than a
              single word and hence is quoted for use with the -c option being
              passed to the shell.  (Most shells expect the argument to -c to be
              a single word).
       su -m -c staff man -c 'catman /usr/share/man /usr/local/man'
              Same as above, but the target command is run with the resource
              limits of the login class “staff”.  Note: in this example, the
              first -c option applies to su while the second is an argument to
              the shell being invoked.
       su -l foo
              Simulate a login for user foo.
       su - foo
              Same as above.
       su -   Simulate a login for root.



You probably still want the MAN_KEEP_FORMATTING=1 part, to keep colorization and bolding etc. in the manual page. Also, your solution does not respect the user’s pager preference; the user might prefer to read man pages in “w3m”, for instance.


>You probably still want the MAN_KEEP_FORMATTING=1 part, to keep colorization and bolding etc. in the manual page

Underlining is the only formatting I care about and that works without MAN_KEEP_FORMATTING on FreeBSD.

I don't have colorization enabled in man pages on my laptop, and also I don't have bolding enabled either. I like it this way.

>your solution does not respect the user’s pager preference; the user might prefer to read man pages in “w3m”, for instance.

The pager preference of the user in this case is `less`. I know because the user happens to be myself :^)




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: