bin: some script tweaks
This commit is contained in:
parent
6a7970b0f6
commit
3a75ed8590
|
@ -32,12 +32,14 @@ for arg do
|
||||||
(*.Z) uncompress "$fullpath";;
|
(*.Z) uncompress "$fullpath";;
|
||||||
(*) echo "'$arg' cannot be extracted by ex" >&2;;
|
(*) echo "'$arg' cannot be extracted by ex" >&2;;
|
||||||
esac
|
esac
|
||||||
test "$(basename "$PWD")" = "$namepart" &&
|
# If we created a temporary subfolder, check if it can be eliminated
|
||||||
if test $# -lt 2 -a "$(ls -U | wc -l)" -lt 3
|
if test "$(basename "$PWD")" = "$namepart"
|
||||||
|
then if test $# -lt 2 -a "$(ls -U | wc -l)" -lt 3
|
||||||
then test "$(ls)" && mv * ..
|
then test "$(ls)" && mv * ..
|
||||||
cd .. && rm -d "$namepart"
|
cd .. && rm -d "$namepart"
|
||||||
else cd .. && mv "$namepart" "$name"
|
else cd .. && mv "$namepart" "$name"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
echo "'$1' is not a readable file"
|
echo "'$1' is not a readable file"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/sh -e
|
#!/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"))
|
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
|
sig=$tmp_base/signature_offset.pdf
|
||||||
result="${1%.pdf}_${5:-signed}.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}"
|
--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"
|
timg "$tmp_signed"
|
||||||
|
|
||||||
# https://apple.stackexchange.com/questions/198854/shell-command-to-count-pages-in-a-pdf-other-than-pdftk
|
# 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
|
if test "$(pdftk "$1" dump_data | grep Pages | cut -d' ' -f2)" -gt 1
|
||||||
then
|
then
|
||||||
pdfjam "$1" last-1 --outfile "$tmp_reversed"
|
pdfjam $quiet "$1" last-1 --outfile "$tmp_reversed"
|
||||||
pdfjam "$tmp_reversed" last-2 "$tmp_signed" --outfile "$result"
|
pdfjam $quiet "$tmp_reversed" last-2 "$tmp_signed" --outfile "$result"
|
||||||
else cp "$tmp_signed" "$result"
|
else cp "$tmp_signed" "$result"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -6,4 +6,4 @@
|
||||||
# If first arg is a digit, it displaces the default depth of 3
|
# 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
|
# Any other arguments (usually pathnames) are passed on to the tree command
|
||||||
case "$1" in ([0-9]) depth=$1; shift;; esac
|
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}
|
||||||
|
|
Loading…
Reference in New Issue