1 # Requires colors autoload.
4 # Set up once, and then reuse. This way it supports user overrides after the
6 typeset -AHg less_termcap
9 less_termcap[mb]="${fg_bold[red]}"
10 less_termcap[md]="${fg_bold[red]}"
11 less_termcap[me]="${reset_color}"
13 less_termcap[so]="${fg_bold[yellow]}${bg[blue]}"
14 less_termcap[se]="${reset_color}"
16 less_termcap[us]="${fg_bold[green]}"
17 less_termcap[ue]="${reset_color}"
19 # Handle $0 according to the standard:
20 # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
21 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
22 0="${${(M)0:#/*}:-$PWD/$0}"
24 # Absolute path to this file's directory.
25 typeset -g __colored_man_pages_dir="${0:A:h}"
30 # Convert associative array to plain array of NAME=VALUE items.
32 for k v in "${(@kv)less_termcap}"; do
33 environment+=( "LESS_TERMCAP_${k}=${v}" )
36 # Prefer `less` whenever available, since we specifically configured
38 environment+=( PAGER="${commands[less]:-$PAGER}" )
41 if [[ "$OSTYPE" = solaris* ]]; then
42 environment+=( PATH="${__colored_man_pages_dir}:$PATH" )
45 command env $environment "$@"
48 # Colorize man and dman/debman (from debian-goodies)