diff --git a/.local/bin/scripts/addgroup b/.local/bin/scripts/addgroup new file mode 100755 index 0000000..c2c3532 --- /dev/null +++ b/.local/bin/scripts/addgroup @@ -0,0 +1,3 @@ +#!/bin/sh -e +sudo usermod -aG "$@" "$USER" +sudo su "$USER" diff --git a/.local/bin/scripts/compress b/.local/bin/scripts/compress index 3e13290..3abc7e6 100755 --- a/.local/bin/scripts/compress +++ b/.local/bin/scripts/compress @@ -1,3 +1,3 @@ #!/bin/sh # Just compress the given directory! -7z a "$1" "$@" +7z a "$1.zip" "$@" diff --git a/.local/bin/scripts/ex b/.local/bin/scripts/ex index 956f3ce..6aefd61 100755 --- a/.local/bin/scripts/ex +++ b/.local/bin/scripts/ex @@ -4,6 +4,7 @@ # detects whether unpacking into a subfolder is sensible # and shows progress indications for some operations # 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 case $arg in (-d) del=$(expr ${del:-0} + 1);; diff --git a/.local/bin/scripts/help b/.local/bin/scripts/help index 6184cba..d341939 100755 --- a/.local/bin/scripts/help +++ b/.local/bin/scripts/help @@ -7,12 +7,11 @@ paginate="${PAGER:-less} +Gg" case "$1" in (-d) browse=1; shift;; (-v) set -o xtrace; shift;; - ("") echo "Try: + ("") echo "Provide an object to get help on or check out the following options: tldr info man - test-colors - arg-test / arg-notify" + quickref; test-colors; arg-test / arg-notify" esac showinfo() { diff --git a/.local/bin/scripts/own b/.local/bin/scripts/own index 25753d1..1ade337 100755 --- a/.local/bin/scripts/own +++ b/.local/bin/scripts/own @@ -1,3 +1,8 @@ -#!/bin/sh +#!/bin/sh -e # 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" "${@:-.}" diff --git a/.local/bin/scripts/rd b/.local/bin/scripts/rd index 6d28ecf..ca32ae7 100755 --- a/.local/bin/scripts/rd +++ b/.local/bin/scripts/rd @@ -15,7 +15,7 @@ do 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 \| 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 $? if test -e "$f"; then echo -n "$f ($(ls -A "$f" | head -3 | paste -s -d' ')) " >&2 && diff --git a/.local/bin/scripts/sign b/.local/bin/scripts/sign index ba0086b..620e827 100755 --- a/.local/bin/scripts/sign +++ b/.local/bin/scripts/sign @@ -1,8 +1,8 @@ -#!/bin/sh -e +#!/bin/sh -ex test "$1" = "-q" && quiet=$1 && shift test ! -r "$1" && echo "Usage: sign [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 tmp_base=/tmp/sign @@ -10,7 +10,7 @@ mkdir -p $tmp_base tmp_signed=$tmp_base/$1_last-signature.pdf tmp_reversed=$tmp_base/$1_reverse.pdf sig=$tmp_base/signature_offset.pdf -result="${1%.pdf}_${5:-signed}.pdf" +result="${1%.pdf}_$(basename "${5:-signed}").pdf" h=${2:--160} v=${3:--310}