It can’t hurt to share some of you current helpers. Either someone else might get inspired by or in some cases you get suggestions how to make it better. Bash, Zsh, Fish or whatever shell script, command or alias (or abbreviation) you have, share here. Always fun to do so! I share mine in the comments, just like everybody else.

  • thingsiplay@lemmy.mlOP
    link
    fedilink
    arrow-up
    1
    ·
    3 hours ago

    There is a bit to unpack here. I particularly like the m() function here, to search for specific options in a man page. The grep_browser() is quiet involved and need to test it out myself. Meanwhile here is an “old” function of mine related to man pages, just searching all available pages, not their content:

    woman

    #!/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