diff --git a/.local/bin/scripts/b b/.local/bin/scripts/b index 54985f6..63f71ec 100755 --- a/.local/bin/scripts/b +++ b/.local/bin/scripts/b @@ -70,8 +70,10 @@ for arg; do case "$mime" in (*\ application/pdf\;*) echo Converting "$arg" - test -f "$tmpfile-1.ppm" || pdftoppm -forcenum -r 70 "$arg" "$tmpfile" -l $(expr $grid \& \( $grid \> 4 \| $# \> 1 \) \| $grid '*' 2) - timg -W --grid=$grid "$tmpfile"*.ppm + grid=$(expr $(tput cols) / 20 \* $#) + 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*) # https://ask.libreoffice.org/t/convert-to-command-line-parameter/840/4 diff --git a/.local/bin/scripts/help b/.local/bin/scripts/help index c888245..1722e7d 100755 --- a/.local/bin/scripts/help +++ b/.local/bin/scripts/help @@ -18,7 +18,7 @@ showinfo() { cmd="$1" case "$cmd" in # 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 # TODO view fossil ui in terminal shift @@ -39,10 +39,9 @@ case "$cmd" in # need to install zsh-doc package for info pages showinfo zsh $(test "$last" != zsh && echo "$last") || LESS="$LESS +/^ *$last *\\[" man zshall;; - (*) showinfo "$@" || man "$@" - return=$? - if test $return -gt 0 && which "$cmd" >/dev/null - then { "$@" --help || { test $? == 1 && "$@" -help; } || { test $? == 1 && "$@" -h; }; } 2>&1 | $paginate + (*) showinfo "$@" || man "$@" || return=$? + if test "$return" -gt 0 && which "$cmd" >/dev/null + then { unbuffer "$@" --help || { test $? == 1 && "$@" -help; } || { test $? == 1 && "$@" -h; }; } 2>&1 | $paginate return=$? fi;; esac