bin: some script tweaks

This commit is contained in:
xeruf 2022-04-06 16:54:41 +02:00
parent 6a7970b0f6
commit 3a75ed8590
3 changed files with 11 additions and 8 deletions

View File

@ -32,12 +32,14 @@ for arg do
(*.Z) uncompress "$fullpath";;
(*) echo "'$arg' cannot be extracted by ex" >&2;;
esac
test "$(basename "$PWD")" = "$namepart" &&
if test $# -lt 2 -a "$(ls -U | wc -l)" -lt 3
# If we created a temporary subfolder, check if it can be eliminated
if test "$(basename "$PWD")" = "$namepart"
then if test $# -lt 2 -a "$(ls -U | wc -l)" -lt 3
then test "$(ls)" && mv * ..
cd .. && rm -d "$namepart"
else cd .. && mv "$namepart" "$name"
fi
fi
)
else
echo "'$1' is not a readable file"

View File

@ -1,5 +1,6 @@
#!/bin/sh -e
test ! -r "$1" && echo "Usage: sign <document.pdf> [hoffset [voffset [scale [alt-signature]]]]" && exit 1
test "$1" = "-q" && quiet=$1 && shift
test ! -r "$1" && echo "Usage: sign <document.pdf> [hoffset [voffset [scale [signature-image]]]]" && exit 1
signature=$(pass info/signature$(test -n "$5" && echo "-$5"))
@ -11,16 +12,16 @@ tmp_reversed=$tmp_base/$1_reverse.pdf
sig=$tmp_base/signature_offset.pdf
result="${1%.pdf}_${5:-signed}.pdf"
pdfjam "$signature" --outfile "$sig" --papersize "{595pt, 842pt}" --noautoscale true \
pdfjam $quiet "$signature" --outfile "$sig" --papersize "{595pt, 842pt}" --noautoscale true \
--offset "${2:-0}pt ${3:-0}pt" --scale "${4:-1}"
pdfjam "$1" last "$sig" --outfile "$tmp_signed" --delta "0 -842pt" --nup "1x2" --fitpaper true
pdfjam $quiet "$1" last "$sig" --outfile "$tmp_signed" --delta "0 -842pt" --nup "1x2" --fitpaper true
timg "$tmp_signed"
# https://apple.stackexchange.com/questions/198854/shell-command-to-count-pages-in-a-pdf-other-than-pdftk
if test "$(pdftk "$1" dump_data | grep Pages | cut -d' ' -f2)" -gt 1
then
pdfjam "$1" last-1 --outfile "$tmp_reversed"
pdfjam "$tmp_reversed" last-2 "$tmp_signed" --outfile "$result"
pdfjam $quiet "$1" last-1 --outfile "$tmp_reversed"
pdfjam $quiet "$tmp_reversed" last-2 "$tmp_signed" --outfile "$result"
else cp "$tmp_signed" "$result"
fi

View File

@ -6,4 +6,4 @@
# If first arg is a digit, it displaces the default depth of 3
# Any other arguments (usually pathnames) are passed on to the tree command
case "$1" in ([0-9]) depth=$1; shift;; esac
tree -a --dirsfirst -L ${depth:-3} --du -h -C "$@" | ${PAGER:-less}
tree -a --dirsfirst --du -h -C -L ${depth:-3} "$@" | ${PAGER:-less}