From 29a445f3f670c306bd93e1165561e0cbec5cd53d Mon Sep 17 00:00:00 2001 From: Niklas Date: Sun, 12 Jul 2020 17:40:33 +0200 Subject: [PATCH] added man macho script --- .local/share/scripts/macho.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 .local/share/scripts/macho.sh diff --git a/.local/share/scripts/macho.sh b/.local/share/scripts/macho.sh new file mode 100755 index 0000000..282f333 --- /dev/null +++ b/.local/share/scripts/macho.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env sh + +export FZF_DEFAULT_OPTS=' +--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 +