From 3a75ed8590bfd379b9e06500a318cd02eb0030ae Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Wed, 6 Apr 2022 16:54:41 +0200 Subject: [PATCH] bin: some script tweaks --- .local/bin/scripts/ex | 6 ++++-- .local/bin/scripts/sign | 11 ++++++----- .local/bin/scripts/tl | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.local/bin/scripts/ex b/.local/bin/scripts/ex index 2c17d6e..9b1d32c 100755 --- a/.local/bin/scripts/ex +++ b/.local/bin/scripts/ex @@ -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" diff --git a/.local/bin/scripts/sign b/.local/bin/scripts/sign index c869a9a..9bc3309 100755 --- a/.local/bin/scripts/sign +++ b/.local/bin/scripts/sign @@ -1,5 +1,6 @@ #!/bin/sh -e -test ! -r "$1" && echo "Usage: sign [hoffset [voffset [scale [alt-signature]]]]" && exit 1 +test "$1" = "-q" && quiet=$1 && shift +test ! -r "$1" && echo "Usage: sign [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 diff --git a/.local/bin/scripts/tl b/.local/bin/scripts/tl index 5159dc8..14a3939 100755 --- a/.local/bin/scripts/tl +++ b/.local/bin/scripts/tl @@ -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}