From 0f3d24a87c8117acbd05e3aae971cc9575f27e20 Mon Sep 17 00:00:00 2001 From: renato <145359396+renatowljacob@users.noreply.github.com> Date: Sat, 18 Jan 2025 06:18:10 -0300 Subject: [PATCH] Fix fzf-man-widget showing only the first section from man pages with multiple sections --- Examples.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Examples.md b/Examples.md index bff957f..6846d87 100644 --- a/Examples.md +++ b/Examples.md @@ -2213,9 +2213,10 @@ Same functionality as above ```sh fzf-man-widget() { - batman="man {1} | col -bx | bat --language=man --plain --color always --theme=\"Monokai Extended\"" + manpage="echo {} | sed 's/\([[:alnum:][:punct:]]*\) (\([[:alnum:]]*\)).*/\2 \1/'" + batman="${manpage} | xargs -r man | col -bx | bat --language=man --plain --color always --theme=\"Monokai Extended\"" man -k . | sort \ - | awk -v cyan=$(tput setaf 6) -v blue=$(tput setaf 4) -v res=$(tput sgr0) -v bld=$(tput bold) '{ $1=cyan bld $1; $2=res blue;} 1' \ + | awk -v cyan=$(tput setaf 6) -v blue=$(tput setaf 4) -v res=$(tput sgr0) -v bld=$(tput bold) '{ $1=cyan bld $1; $2=res blue $2; } 1' \ | fzf \ -q "$1" \ --ansi \ @@ -2223,7 +2224,7 @@ fzf-man-widget() { --prompt=' Man > ' \ --preview-window '50%,rounded,<50(up,85%,border-bottom)' \ --preview "${batman}" \ - --bind "enter:execute(man {1})" \ + --bind "enter:execute(${manpage} | xargs -r man)" \ --bind "alt-c:+change-preview(cht.sh {1})+change-prompt(ﯽ Cheat > )" \ --bind "alt-m:+change-preview(${batman})+change-prompt( Man > )" \ --bind "alt-t:+change-preview(tldr --color=always {1})+change-prompt(ﳁ TLDR > )"