aboutsummaryrefslogtreecommitdiffstats
path: root/basics/.local/bin/macho
diff options
context:
space:
mode:
Diffstat (limited to 'basics/.local/bin/macho')
-rwxr-xr-xbasics/.local/bin/macho25
1 files changed, 25 insertions, 0 deletions
diff --git a/basics/.local/bin/macho b/basics/.local/bin/macho
new file mode 100755
index 0000000..2566d7d
--- /dev/null
+++ b/basics/.local/bin/macho
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+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 | \
+ sed -E 's/^\((.+)\)/\1/')
+
+[ -z "$manual" ] && exit 0
+man $manual