summaryrefslogtreecommitdiffstats
path: root/man/viewman
blob: ee9f313b9c9a17fdce01b3d7cb0db4da09e65e2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh

# Generate and view man page with less, for passed command name

# Note to get man to behave like this you can also:
# export MANROFFOPT=-P-i
# export LESS=-R
# export MANPAGER=less

unset GROFF_NO_SGR

hdir=$(dirname "$0")

CONFIG_HEADER="$hdir"/../lib/config.h

grep '^#define BOLD_MAN_REFS 1' $CONFIG_HEADER > /dev/null &&
  BOLD_REFS=--bold-refs

man="$1"; cmd="$1"
test "$1" = 'test' && cmd='['
test "$1" = '[' && man='test'
test "$1" = 'install' && cmd='ginstall'
test "$1" = 'ginstall' && man='install'

"$hdir"/help2man \
  --include="$hdir"/../man/$man.x \
  $BOLD_REFS \
  --loose-indent \
  "$hdir"/../src/$cmd |
preconv | # convert utf-8 chars like in Author names to groff compat
groff -Tutf8 -man -P-i -rLL=${MANWIDTH:-$COLUMNS}n |
less -R