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
|
2022-01-05 16:53:06 +00:00
|
|
|
# depends: unbuffer
|
|
|
|
# optdepends: highlight(dotfiles)
|
2021-09-16 12:18:26 +00:00
|
|
|
paginate="${PAGER:-less} +Gg"
|
2021-09-29 16:38:57 +00:00
|
|
|
test "$1" = "-d" && browse=1 && shift
|
2022-02-10 14:59:41 +00:00
|
|
|
# TODO resolve aliases in 'h' alias
|
|
|
|
# TODO call 'wh' on scripts instead
|
2021-07-02 16:33:30 +00:00
|
|
|
case $1 in
|
2021-12-08 10:37:18 +00:00
|
|
|
(zsh|zmv) # https://unix.stackexchange.com/questions/19290/zmv-for-zsh-dry-runs-and-man-pages
|
|
|
|
for last; do true; done
|
|
|
|
# need to install zsh-doc package for info pages
|
|
|
|
info --vi-keys "$(test "$last" != zsh && echo "--index-search=$last")" zsh ||
|
|
|
|
LESS="$LESS +/^ *$last *\\[" man zshall;;
|
2022-01-09 21:17:06 +00:00
|
|
|
(gh|chordpro|bat|pdfjam|reflector|topgrade|r128gain) unbuffer "$@" --help | $paginate;;
|
2021-12-08 10:37:18 +00:00
|
|
|
(caddy|stretchly|go) "$1" help "${@:2}" | $paginate;;
|
2022-01-05 16:53:06 +00:00
|
|
|
(plantuml) unbuffer "$@" -help | $paginate;;
|
|
|
|
(vlc) unbuffer vlc --full-help "${@:2}" | $paginate;;
|
2022-01-09 21:17:06 +00:00
|
|
|
(kdeconnect*) kdeconnect-cli --help-all "${@:2}" | $paginate;;
|
2022-02-10 14:59:41 +00:00
|
|
|
(pandoc) man pandoc; highlight "Extensions" && pandoc --list-extensions | paste -s -d' ';;
|
2022-01-07 18:15:25 +00:00
|
|
|
(swaymsg) test $# -gt 1 && man sway "${@:2}" || man swaymsg;;
|
|
|
|
(swaymsg-*) man sway "${1#swaymsg-}";;
|
2021-12-08 10:37:18 +00:00
|
|
|
(*) man "$@" ||
|
|
|
|
{ info "$1" -w | grep -v "manpages" && pinfo "$@"; } ||
|
2022-02-10 14:59:41 +00:00
|
|
|
if which "$1" >/dev/null
|
|
|
|
then "$@" --help || echo $? == 1 && "$@" -help || echo $? == 1 && "$@" -h 2>&1 | $paginate
|
|
|
|
fi;;
|
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
|
2021-12-08 10:37:18 +00:00
|
|
|
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
|
2021-09-29 16:38:57 +00:00
|
|
|
fi
|