Last active
June 8, 2023 04:22
-
-
Save thingsiplay/f71383569c10da17f772b9967f5a5767 to your computer and use it in GitHub Desktop.
woman - Preview list for man documents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/