2021-07-02 16:33:30 +00:00
|
|
|
#!/bin/sh
|
2021-09-29 16:38:57 +00:00
|
|
|
# open info-page, man-page or command help
|
2021-09-16 12:18:26 +00:00
|
|
|
set -o pipefail
|
|
|
|
paginate="${PAGER:-less} +Gg"
|
2021-09-29 16:38:57 +00:00
|
|
|
test "$1" = "-d" && browse=1 && shift
|
2021-07-02 16:33:30 +00:00
|
|
|
case $1 in
|
2021-07-06 22:48:35 +00:00
|
|
|
(zsh|zmv) # https://unix.stackexchange.com/questions/19290/zmv-for-zsh-dry-runs-and-man-pages
|
2021-09-16 12:18:26 +00:00
|
|
|
search="${@:$#}"
|
|
|
|
# need to install zsh-doc package for info pages
|
|
|
|
info --vi-keys $(test $search != zsh && echo --index-search=$search) zsh || LESS="$LESS +/^ *${@:$#} *\\[" man zshall;;
|
|
|
|
(vlc) unbuffer vlc --full-help "${@:2}" | $paginate;;
|
|
|
|
(gh|chordpro) $@ --help | $paginate;;
|
2021-09-20 06:57:20 +00:00
|
|
|
(caddy) $1 help ${@:2} | $paginate;;
|
2021-10-31 19:27:18 +00:00
|
|
|
(*) man "$@" || { info "$1" -w | grep -v "manpages" && pinfo "$@"; } || { "$@" --help || "$@" -help; } 2>&1 | ${PAGER:-less} || which "$@";;
|
2021-07-02 16:33:30 +00:00
|
|
|
esac
|
2021-09-29 16:38:57 +00:00
|
|
|
docs="/usr/share/doc/$1"
|
|
|
|
if test -d "$docs"; then
|
|
|
|
if test -z "$browse"
|
|
|
|
then echo "Find more in $docs"
|
|
|
|
else
|
|
|
|
len() { echo $1 | wc -c; }
|
|
|
|
shortest() {
|
|
|
|
read shortest
|
|
|
|
while read in
|
|
|
|
do test $(len $shortest) -gt $(len $in) && shortest=$in
|
|
|
|
done
|
|
|
|
echo $shortest
|
|
|
|
}
|
|
|
|
firefox "file://$(find $docs -name index.html | shortest | grep . || find $docs -name $1*.html | shortest)"
|
|
|
|
fi
|
|
|
|
fi
|