aboutsummaryrefslogtreecommitdiffstats
path: root/dmenu/man
blob: 1b29656c03bfabd16a6612a84107b18e8ac070f6 (plain) (blame)
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
33
34
35
36
37
38
39
#!/bin/dash

# Browse with dmenu if no page has been specified
if test $# = 0; then
	manpage="$(/usr/bin/man -k '' | dmenu -l 40 | sed 's/^\([^ ]*\) (\([^)]*\)).*$/\2 \1/')"
	if test -z "$manpage"; then
		exit 1
	fi
	set $manpage
fi


# Bold
export LESS_TERMCAP_md="$(printf '\033[01;34m')"
export LESS_TERMCAP_me="$(printf '\033[0m')"

# Italic
export LESS_TERMCAP_us="$(printf '\033[01;04;32m')"
export LESS_TERMCAP_ue="$(printf '\033[0m')"

# Reverse video
if test "$TERM" = linux; then
	export LESS_TERMCAP_so="$(printf '\033[07m')"
else
	export LESS_TERMCAP_so="$(printf '\033[07;01m')"
fi
export LESS_TERMCAP_se="$(printf '\033[0m')"


# Display, open new terminal if in the background
if isfg; then
	exec /usr/bin/man "$@"
elif test -x /usr/bin/terminator; then
	exec terminator -e "/usr/bin/man $*"
elif test -x /usr/bin/st; then
	exec st -e /usr/bin/man "$@"
else
	exec xterm -e /usr/bin/man "$@"
fi