bin: improve terminal output of b and help

This commit is contained in:
xeruf 2022-09-19 23:46:05 +02:00
parent 5d7f2b33a5
commit d3fad6a181
2 changed files with 8 additions and 7 deletions

View File

@ -70,8 +70,10 @@ for arg; do
case "$mime" in case "$mime" in
(*\ application/pdf\;*) (*\ application/pdf\;*)
echo Converting "$arg" echo Converting "$arg"
test -f "$tmpfile-1.ppm" || pdftoppm -forcenum -r 70 "$arg" "$tmpfile" -l $(expr $grid \& \( $grid \> 4 \| $# \> 1 \) \| $grid '*' 2) grid=$(expr $(tput cols) / 20 \* $#)
timg -W --grid=$grid "$tmpfile"*.ppm limit=$(expr $grid \& \( $grid \> 3 \| $# \> 1 \) \| $grid '*' 2)
test -f "$tmpfile-1.ppm" || pdftoppm -forcenum -r 70 "$arg" "$tmpfile" -l $limit
find "$prefix" -path "$tmpfile*.ppm" | head -$limit | xargs timg -W --grid=$grid
;; ;;
(*\ application/*document*) (*\ application/*document*)
# https://ask.libreoffice.org/t/convert-to-command-line-parameter/840/4 # https://ask.libreoffice.org/t/convert-to-command-line-parameter/840/4

View File

@ -18,7 +18,7 @@ showinfo() {
cmd="$1" cmd="$1"
case "$cmd" in case "$cmd" in
# TODO extract help in standard format from scripts # TODO extract help in standard format from scripts
(rdoc|gh|chordpro|bat|pdfjam|reflector|topgrade|r128gain|7z|kubectl|diffr|docker|jrnl|difft|wiked-diff) unbuffer "$@" --help | $paginate;; (hunt|rdoc|gh|chordpro|bat|pdfjam|reflector|topgrade|r128gain|7z|kubectl|diffr|docker|jrnl|difft|wiked-diff) unbuffer "$@" --help | $paginate;;
(caddy|stretchly|go|fossil) test "$cmd" = "fossil" -a $# -eq 1 && repo="$(locate -b -l 1 "fossil*.fossil")" && fossil ui "$repo" && exit (caddy|stretchly|go|fossil) test "$cmd" = "fossil" -a $# -eq 1 && repo="$(locate -b -l 1 "fossil*.fossil")" && fossil ui "$repo" && exit
# TODO view fossil ui in terminal # TODO view fossil ui in terminal
shift shift
@ -39,10 +39,9 @@ case "$cmd" in
# need to install zsh-doc package for info pages # need to install zsh-doc package for info pages
showinfo zsh $(test "$last" != zsh && echo "$last") || showinfo zsh $(test "$last" != zsh && echo "$last") ||
LESS="$LESS +/^ *$last *\\[" man zshall;; LESS="$LESS +/^ *$last *\\[" man zshall;;
(*) showinfo "$@" || man "$@" (*) showinfo "$@" || man "$@" || return=$?
return=$? if test "$return" -gt 0 && which "$cmd" >/dev/null
if test $return -gt 0 && which "$cmd" >/dev/null then { unbuffer "$@" --help || { test $? == 1 && "$@" -help; } || { test $? == 1 && "$@" -h; }; } 2>&1 | $paginate
then { "$@" --help || { test $? == 1 && "$@" -help; } || { test $? == 1 && "$@" -h; }; } 2>&1 | $paginate
return=$? return=$?
fi;; fi;;
esac esac