added macho man page finder
This commit is contained in:
parent
d51e61d517
commit
9e6228e86a
26
.local/bin/tools/manf
Executable file
26
.local/bin/tools/manf
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# macho - an interactive man page finder using fzf
|
||||||
|
# from: https://hiphish.github.io/blog/2020/05/31/macho-man-command-on-steroids/
|
||||||
|
export FZF_DEFAULT_OPTS='
|
||||||
|
--height=30%
|
||||||
|
--layout=reverse
|
||||||
|
--prompt="Manual: "
|
||||||
|
--preview="echo {1} | sed -E \"s/^\((.+)\)/\1/\" | xargs -I{S} man -Pcat {S} {2} 2>/dev/null"'
|
||||||
|
|
||||||
|
while getopts ":s:" opt; do
|
||||||
|
case $opt in
|
||||||
|
s ) SECTION=$OPTARG; shift; shift;;
|
||||||
|
\?) echo "Invalid option: -$OPTARG" >&2; exit 1;;
|
||||||
|
: ) echo "Option -$OPTARG requires an argument" >&2; exit 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
manual=$(apropos -s ${SECTION:-''} ${@:-.} | \
|
||||||
|
grep -v -E '^.+ \(0\)' |\
|
||||||
|
awk '{print $2 " " $1}' | \
|
||||||
|
sort | \
|
||||||
|
fzf --query="$*" | \
|
||||||
|
sed -E 's/^\((.+)\)/\1/')
|
||||||
|
|
||||||
|
[ -z "$manual" ] && exit 0
|
||||||
|
man $manual
|
Loading…
Reference in New Issue
Block a user