bin: colorful helpers

This commit is contained in:
xeruf 2023-03-31 19:09:55 +02:00
parent 6f70299efc
commit 81410fe313
5 changed files with 30 additions and 4 deletions

View File

@ -34,10 +34,12 @@ checkperm() {
mime="$(test -n "$shifted" || $elevate file --dereference --mime "$@")"
}
fileinfo() {
tput setaf 6
tput setaf 4
for arg
do case "$arg" in (-*) continue;; esac
tput smso
$elevate file --exclude elf -E "$arg"
tput rmso
$elevate ssh-keygen -l -f "$arg" 2>/dev/null || true
# TODO do not grep bitrate but extract properly
#probe="$($elevate ffprobe "$arg" 2>&1)"
@ -138,6 +140,7 @@ for arg; do
;;
(*:\ SQLite\ *\ database*) highlight "Tables" && sqlite3 "$arg" ".tables";;
(*:\ data) ;;
(*\ key) bat+=("$arg");;
(*) bat+=("$arg")
timga+=("$arg")
continue

2
.local/bin/scripts/privatize Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh -e
chmod -vR go-rwx "$@"

13
.local/bin/scripts/qobuz Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh -ex
target="${1:-$PWD}"
cd $DATA/5*
tar xf Qobuz-commandes.tar
mv -v *.jpg Qobuz-commandes/
mv -v Qobuz-commandes $target/qobuz #$d4/music/Worship/
rm -i Qobuz-commandes.tar
cd $target/qobuz
find -type d -exec sh -c 'test $(ls "{}" | wc -l) -eq 1 && find "{}" -maxdepth 1 -type f | xargs -i% mv -v % .' \;
find -type d -empty -delete
formatsongs
find -maxdepth 1 -name "*.jpg" -exec sh -c 'mv -v "{}" "$(echo {} | rev | cut -d"/" -f1 | rev | cut -d"-" -f1-2 | tr -s "-" " " | xargs -i% find -type d -iname "%*")/"' \;
exec zsh

View File

@ -5,5 +5,5 @@ export chars=$(expr $(tput cols) - 60)
case "$1" in (+*) size=${1#+}; depth=2; shift;; esac
case "$1" in ([0-9]) depth=$1; shift;; esac
(du --max-depth "${depth:-1}" -xhat ${size:-50}M "$@" | sort -h | grep -v "^0") |
while read line; do echo "$line $(pacman -Qqo $(echo $line | awk '{print $2}') 2>/dev/null | paste -s -d',' | sed "s/\(.\{${chars}\}\).*/\1.../")"; done || #| column -t ||
while read line; do echo "$(tput smso)$line$(tput rmso) $(pacman -Qqo $(echo $line | awk '{print $2}') 2>/dev/null | paste -s -d',' | sed "s/\(.\{${chars}\}\).*/\1.../")"; done || #| column -t ||
(du --max-depth "${depth:-1}" -xha "$@" | sort -h | tail)

View File

@ -1,6 +1,6 @@
#!/bin/sh -e
test "$1" = "-q" && quiet=$1 && shift
test ! -r "$1" && echo "Usage: sign <document.pdf> [hoffset [voffset [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"))
@ -12,8 +12,16 @@ tmp_reversed=$tmp_base/$1_reverse.pdf
sig=$tmp_base/signature_offset.pdf
result="${1%.pdf}_${5:-signed}.pdf"
h=${2:--160}
v=${3:--310}
if test $# -lt 2; then
case "$1" in
(*\ TU.pdf) v=-260;;
esac
fi
export TEXMF=""
pdfjam $quiet "$signature" --outfile "$sig" --papersize "{595pt, 842pt}" --noautoscale true \
--offset "${2:--160}pt ${3:--310}pt" --scale "${4:-1}"
--offset "${h}pt ${v}pt" --scale "${4:-1}"
pdfjam $quiet "$1" last "$sig" --outfile "$tmp_signed" --delta "0 -842pt" --nup "1x2" --fitpaper true
timg "$tmp_signed"