bin: some script fixes

This commit is contained in:
xeruf 2023-04-06 16:21:36 +02:00
parent e0a5a0a837
commit 40dc402902
7 changed files with 18 additions and 10 deletions

3
.local/bin/scripts/addgroup Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh -e
sudo usermod -aG "$@" "$USER"
sudo su "$USER"

View File

@ -1,3 +1,3 @@
#!/bin/sh #!/bin/sh
# Just compress the given directory! # Just compress the given directory!
7z a "$1" "$@" 7z a "$1.zip" "$@"

View File

@ -4,6 +4,7 @@
# detects whether unpacking into a subfolder is sensible # detects whether unpacking into a subfolder is sensible
# and shows progress indications for some operations # and shows progress indications for some operations
# optdepends: rewrite(part of my dotfiles, for unzip line rewriting) 7z p7zip unzip # optdepends: rewrite(part of my dotfiles, for unzip line rewriting) 7z p7zip unzip
# TODO auto-delete archive, auto-extract in current dir, trim .tar.gz fully
for arg do for arg do
case $arg in case $arg in
(-d) del=$(expr ${del:-0} + 1);; (-d) del=$(expr ${del:-0} + 1);;

View File

@ -7,12 +7,11 @@ paginate="${PAGER:-less} +Gg"
case "$1" in case "$1" in
(-d) browse=1; shift;; (-d) browse=1; shift;;
(-v) set -o xtrace; shift;; (-v) set -o xtrace; shift;;
("") echo "Try: ("") echo "Provide an object to get help on or check out the following options:
tldr tldr
info info
man man
test-colors quickref; test-colors; arg-test / arg-notify"
arg-test / arg-notify"
esac esac
showinfo() { showinfo() {

View File

@ -1,3 +1,8 @@
#!/bin/sh #!/bin/sh -e
# Recursively take ownership of the given files or the current directory # Recursively take ownership of the given files or the current directory
sudo chown -R --preserve-root $USER:$USER "${@:-.}" u=$USER
case "$1" in
(+*) sudo chmod -R "$1" "${@:-.}"; shift; break;;
(-*) u="${1#-}"; shift; break;;
esac
sudo chown -R --preserve-root "$u:$u" "${@:-.}"

View File

@ -15,7 +15,7 @@ do
fi fi
# $elevate find -H "$f" -maxdepth $(expr 1 \& "$f" = "/" \| 5 \& $# \> 0 \| 4) -type d -empty -name .stfolder -exec rm -div {} \; # $elevate find -H "$f" -maxdepth $(expr 1 \& "$f" = "/" \| 5 \& $# \> 0 \| 4) -type d -empty -name .stfolder -exec rm -div {} \;
$elevate find -H "$f" -maxdepth $(expr 1 \& "$f" = "/" \| 5 \& $# \> 0 \| 3) -not \( -name '.stfolder' -o -name '.*keep' -o -name "*.py" \) \( -type d -o -type f \) -a -empty -printf 'Removing empty %p\n' -delete $elevate find -H "$f" -maxdepth $(expr 1 \& "$f" = "/" \| 5 \& $# \> 0 \| 3) -not \( -name '.stfolder' -o -name '.*keep' -o -name "*.py" -o -name "nodelay.txt" \) \( -type d -o -type f \) -a -empty -printf 'Removing empty %p\n' -delete
test $# -eq 0 && exit $? test $# -eq 0 && exit $?
if test -e "$f"; then if test -e "$f"; then
echo -n "$f ($(ls -A "$f" | head -3 | paste -s -d' ')) " >&2 && echo -n "$f ($(ls -A "$f" | head -3 | paste -s -d' ')) " >&2 &&

View File

@ -1,8 +1,8 @@
#!/bin/sh -e #!/bin/sh -ex
test "$1" = "-q" && quiet=$1 && shift test "$1" = "-q" && quiet=$1 && shift
test ! -r "$1" && echo "Usage: sign <document.pdf> [hoffset (-160) [voffset (-310) [scale [signature-image]]]]" && exit 1 test ! -r "$1" && echo "Usage: sign <document.pdf> [hoffset (-160) [voffset (-310) [scale [signature-image]]]]" && exit 1
signature=$(pass info/signature$(test -n "$5" && echo "-$5")) signature=$(pass info/signature$(test -n "$5" && echo "-$5") || echo "$5")
# TODO make filenames unique and don't rerun unneccessarily # TODO make filenames unique and don't rerun unneccessarily
tmp_base=/tmp/sign tmp_base=/tmp/sign
@ -10,7 +10,7 @@ mkdir -p $tmp_base
tmp_signed=$tmp_base/$1_last-signature.pdf tmp_signed=$tmp_base/$1_last-signature.pdf
tmp_reversed=$tmp_base/$1_reverse.pdf 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}_$(basename "${5:-signed}").pdf"
h=${2:--160} h=${2:--160}
v=${3:--310} v=${3:--310}