Man

From wikinotes

Unix manual pages.

Tutorials

gentoo wiki https://wiki.gentoo.org/wiki/Man_page

Locations

${XDG_CONFIG_HOME}/.lesskey user custom keybindings
${PREFIX}/etc/syslesskey
C:\_syslesskey
C:\syslesskey.ini
global custom keybindings

Configuration

keybindings

Keybindings are set in your pager. Chances are you are interested in gnu less.

Width

Set manpage width with $MANWIDTH.

man() {
    local width
    local default_width

    default_width=100
    width=$(tput cols)
    test "$width" -gt "$default_width" && width=$default_width

    env MANWIDTH=$width man "$@"
}

Colours

export MANROFFOPT="-P -c"

# on linux, you can control less colours using -D
#  -D{what}{modifier}{color}
env MANPAGER='less -R -DdY -Duw --mouse --wheel-lines=5' man man

# across linux and BSD, you can set environment variables for less colours
# https://superuser.com/questions/117841/when-reading-a-file-with-less-or-more-how-can-i-get-the-content-in-colors
export LESS_TERMCAP_mb=$'\E[1;31m'     # begin bold
export LESS_TERMCAP_md=$'\E[1;36m'     # begin blink
export LESS_TERMCAP_me=$'\E[0m'        # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;44;33m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m'        # reset reverse video
export LESS_TERMCAP_us=$'\E[1;32m'     # begin underline
export LESS_TERMCAP_ue=$'\E[0m'        # reset underline

Tips/Tricks

Table of Contents

#!/usr/bin/env bash
# choose from table-of-contents in FZF for a man-page.

header="$(man $@ | grep -n -E '^[A-Z]' | fzf +m)"
[ $? -ne 0 ] && exit 1

linenum=$(echo $header | awk -F':' '{ print $1 }')
env MANPAGER="${MANPAGER} +${linenum}G" man "$@"