blob: 2f4fbb86cf9722fcadecdbd44b2431b3e015f1e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/bin/sh
# fzf-man: fuzzy search manual pages
if [ "$OPENFLAG" = 0 ]; then
input="$*"; page="${input%%)*}";
name="${page%%[ (]*}"; section="${page#*(}"
if [ "$name" = "$section" ]; then
man "$name"
else
man "$section" "$name"
fi; exit
fi
mkdir -pv "${XDG_DATA_HOME:=$HOME/.local/share}/fzf"
export FZF_HIST="${XDG_DATA_HOME:=$HOME/.local/share}/fzf/manual_history"
apropos -l "${@:-.}" | fzf --history="$FZF_HIST" --prompt="man: " \
--preview='MANWIDTH=$FZF_PREVIEW_COLUMNS OPENFLAG=0 fm {}' \
--preview-window="hidden" --tiebreak="begin" \
--bind 'ctrl-v:toggle-preview,ctrl-space:toggle-preview' \
--bind 'enter:execute(echo {1} >> "$FZF_HIST"; OPENFLAG=0 fm {})'
|