Skip to content

Instantly share code, notes, and snippets.

@thingsiplay
Last active June 8, 2023 04:22
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thingsiplay/f71383569c10da17f772b9967f5a5767 to your computer and use it in GitHub Desktop.
Save thingsiplay/f71383569c10da17f772b9967f5a5767 to your computer and use it in GitHub Desktop.
woman - Preview list for man documents
#!/bin/env bash
# Lookup section meaning in `man man`.
sections='1,8,6,5,7'
show_manual () {
man -- "${1%% *}" 2> /dev/null
}
export -f show_manual
if selection=$(man -k . --sections="${sections}" \
| sort -t ' ' -k 2,2 -k 1,1 \
| fzf -q "${*}" \
--cycle \
--border=none \
--bind change:first \
--bind tab:down \
--bind shift-tab:up \
--bind esc:cancel+clear-selection \
--tiebreak=begin,chunk,length \
--reverse \
--preview='show_manual {}' \
--preview-window=down:70%:wrap:border-rounded)
then
show_manual "${selection}"
fi
#!/bin/sh
# Alternate portable POSIX version
# by SleepingProcess:
# https://www.reddit.com/r/bash/comments/13z41ji/woman_preview_list_for_man_documents/jmvdyry/
sections='1,8,6,5,7'
rc=$(
man -k . --sections="${sections}" | sort -t ' ' -k 2,2 -k 1,1 |
fzf -q "${*}" \
--cycle \
--border=none \
--bind change:first \
--bind tab:down \
--bind shift-tab:up \
--bind esc:cancel+clear-selection \
--tiebreak=begin,chunk,length \
--reverse \
--preview='s={}; man -- "${s%% *}" 2> /dev/null' \
--preview-window=down:70%:wrap:border-rounded
)
[ -z "${rc}" ] && exit || man -- "${rc%% *}" 2> /dev/null
@thingsiplay
Copy link
Author

This command is taken from this users suggestion and modified to my needs: https://www.reddit.com/r/bash/comments/13xz1kc/the_only_cheat_sheet_you_need/jmmvn6v/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment