bin: diverse additions
This commit is contained in:
parent
c6a74cd2bc
commit
d4f198a8c3
|
@ -4,7 +4,8 @@
|
||||||
|
|
||||||
typeset -A _clean_map
|
typeset -A _clean_map
|
||||||
_clean_map=([h]=$XDG_CACHE_HOME [t]=/var/tmp [l]=/var/log [v]=/var/cache)
|
_clean_map=([h]=$XDG_CACHE_HOME [t]=/var/tmp [l]=/var/log [v]=/var/cache)
|
||||||
_clean_home=(.ant .autopsy .bundle .cache .cargo .cpanm .docker .electron .electron-gyp .gradle .gradle-kotlin-dsl .hex .java .kscript .konan .m2 .mix .nix-defexpr .node-gyp .nv .openjfx .parallel .stack .surf .texlive
|
# TODO .mix - outdated version in socha
|
||||||
|
_clean_home=(.ant .autopsy .bundle .cache .cargo .cpanm .docker .electron .electron-gyp .gradle .gradle-kotlin-dsl .hex .java .kscript .konan .m2 .nix-defexpr .node-gyp .nv .openjfx .parallel .stack .surf .texlive
|
||||||
.yarn .node_modules .npm .pnpm-store
|
.yarn .node_modules .npm .pnpm-store
|
||||||
luametatex-cache luatex-cache
|
luametatex-cache luatex-cache
|
||||||
.lesshst .python_history .rubberband.wisdom.d .yarnrc)
|
.lesshst .python_history .rubberband.wisdom.d .yarnrc)
|
||||||
|
@ -50,16 +51,17 @@ highlight "s :: recursively remove logs"
|
||||||
|
|
||||||
highlight "m :: recursively remove mac-files"
|
highlight "m :: recursively remove mac-files"
|
||||||
if [[ $1 =~ "m" ]]; then
|
if [[ $1 =~ "m" ]]; then
|
||||||
find -name '__MACOSX' -print -exec rm -r {} +
|
find \( -name '__MACOSX' -o -name '._.Trashes' \) -print -exec rm -r {} +
|
||||||
find \( -iname '.spotlight*' -o -name 'System Volume Information' -o -name '.fseventsd' \) -print -exec rm -rI {} +
|
find \( -iname '.spotlight*' -o -name 'System Volume Information' -o -name '.fseventsd' \) -print -exec rm -rI {} +
|
||||||
find -name '*.DS_Store' -delete
|
find -name '*.DS_Store' -delete
|
||||||
|
echo 'Removed DS Stores'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
highlight "d :: recursively remove development caches"
|
highlight "d :: recursively remove development caches"
|
||||||
if [[ $1 =~ "d" ]]; then
|
if [[ $1 =~ "d" ]]; then
|
||||||
# TODO some matches duplicate log clearing
|
# TODO some matches duplicate log clearing
|
||||||
find -maxdepth 1 \( -name "*.aux" -o -name "*.log" -o -name "*.t[uo][ca]" -o -name "*.out" \) -print -delete
|
find -maxdepth 1 \( -name "*.aux" -o -name "*.log" -o -name "*.t[uo][ca]" -o -name "*.out" \) -print -delete
|
||||||
find \( -name 'src' -o -name 'vendor' \) -prune -o \
|
find \( -name 'src' -o -name 'vendor' -o -name 'web' \) -prune -o \
|
||||||
-type d \( -name 'cache' $(echo $DIRS_GENERATED | sed 's|-x \([^ ]\+\)|-o -name \1|g') \) \
|
-type d \( -name 'cache' $(echo $DIRS_GENERATED | sed 's|-x \([^ ]\+\)|-o -name \1|g') \) \
|
||||||
-print -exec rm $i -r {} + -prune
|
-print -exec rm $i -r {} + -prune
|
||||||
echo -n " " && highlight "build directories"
|
echo -n " " && highlight "build directories"
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/sh -e
|
||||||
|
# Clean the download folder of empty files and duplicates
|
||||||
|
IFS='
|
||||||
|
'
|
||||||
|
find -name '*([0-9])*' -exec sh -c 'file="{}";
|
||||||
|
new="$(echo $file | sed "s| \?([0-9])||")";
|
||||||
|
mv -v$(test -s "$new" && ! command diff "$file" "$new" >&2 && echo i) "$file" "$new"' \;
|
||||||
|
find -name "*.part" -exec rm -vi {} +
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/sh -e
|
||||||
|
case "$1" in ([0-9]*) count=$1; shift;; esac
|
||||||
|
for i in {1..${count:-9}}
|
||||||
|
do txt2img --prompt "$*" --output "${1}_$(date +%y%m%d)-${i}.png"
|
||||||
|
done
|
|
@ -17,12 +17,12 @@ if test $# -eq 0
|
||||||
then highlight "[1mWrite Test"
|
then highlight "[1mWrite Test"
|
||||||
sync
|
sync
|
||||||
# This prevents predictions by using random, but since that is too slow we have to copy a previously created file
|
# This prevents predictions by using random, but since that is too slow we have to copy a previously created file
|
||||||
highlight "Preparing:" &&
|
count=100$(test $(df --output="avail" . | tail -1) -gt 999999 && echo 0 || true)
|
||||||
sudo dd status=progress if=/dev/random of=/var/tmp/tempfile bs=1M count=1K &&
|
highlight "Preparing random bits:" &&
|
||||||
|
sudo dd status=progress if=/dev/random of=/var/tmp/tempfile bs=1M count=$count &&
|
||||||
highlight "Copying random bits:" &&
|
highlight "Copying random bits:" &&
|
||||||
sudo dd status=progress if=/var/tmp/tempfile of=tempfile bs=1M count=1K
|
sudo dd status=progress if=/var/tmp/tempfile of=tempfile bs=1M count=$count
|
||||||
# TODO adjust size to disk
|
|
||||||
highlight "Copying zero bits:" &&
|
highlight "Copying zero bits:" &&
|
||||||
sudo dd status=progress if=/dev/zero of=tempfile bs=1M count=1K
|
sudo dd status=progress if=/dev/zero of=tempfile bs=1M count=$count
|
||||||
sudo rm tempfile
|
sudo rm tempfile
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
if test "$1" = "f"
|
if test "$1" = "f"
|
||||||
then df -B1M -x tmpfs -x devtmpfs -x squashfs | awk -v a="\033[31m" -v b="\033[33m" -v c="\033[35m" -v n="\033[0m" 'NR==1 {printf "%-20s %6s %7s %9s %s\n",$1,$5,$3,$4,$6} NR>1 {u=strtonum($5); printf (u > 99) ? a : (u > 97) ? b : (u > 94) ? c : ""; printf "%-20s %6s %6.1fG %8.1fG %s\n",$1,$5,$3/1024,$4/1024,$6; printf n}'
|
then df -B1M -x tmpfs -x devtmpfs -x squashfs | awk -v a="\033[31m" -v b="\033[33m" -v c="\033[35m" -v n="\033[0m" 'NR==1 {printf "%-20s %6s %7s %9s %s\n",$1,$5,$3,$4,$6} NR>1 {u=strtonum($5); printf (u > 99) ? a : (u > 97) ? b : (u > 94) ? c : ""; printf "%-20s %6s %6.1fG %8.1fG %s\n",$1,$5,$3/1024,$4/1024,$6; printf n}'
|
||||||
else
|
else
|
||||||
IFS="\n"
|
|
||||||
test "$(lsblk --version | cut -d. -f2)" -ge 37 && width="--width" && cols=$(tput cols) && outcols="s"
|
test "$(lsblk --version | cut -d. -f2)" -ge 37 && width="--width" && cols=$(tput cols) && outcols="s"
|
||||||
|
IFS="\n"
|
||||||
lsblk --output name,size,fsavail,fsuse%,mountpoint$outcols,label,fstype$(test "${cols:-0}" -gt 120 && echo ',uuid') $width $cols |
|
lsblk --output name,size,fsavail,fsuse%,mountpoint$outcols,label,fstype$(test "${cols:-0}" -gt 120 && echo ',uuid') $width $cols |
|
||||||
while read line
|
while read line
|
||||||
do p=$(echo "$line" | sed 's|.* \([[:digit:]]\+\)%.*|\1|;t;c0')
|
do p=$(echo "$line" | sed 's|.* \([[:digit:]]\+\)%.*|\1|;t;c0')
|
||||||
|
|
|
@ -25,7 +25,7 @@ sel=$(listconf | fzf -1 -0 --tiebreak=end,length --preview '$(test -r {} || echo
|
||||||
case "$sel" in
|
case "$sel" in
|
||||||
("") exit 1;;
|
("") exit 1;;
|
||||||
(/etc/sudoers) sudo visudo;;
|
(/etc/sudoers) sudo visudo;;
|
||||||
(/etc/fstab) sudoedit "$sel" && sudo findmnt --verify;;
|
(/etc/fstab) sudoedit "$sel" && sudo findmnt --verify && sudo systemctl daemon-reload;;
|
||||||
#systemctl daemon-reload && mount -af -o remount;;
|
#systemctl daemon-reload && mount -af -o remount;;
|
||||||
(/etc/default/grub) sudoedit "$sel" && sudo grub-mkconfig -o /boot/grub/grub.cfg;;
|
(/etc/default/grub) sudoedit "$sel" && sudo grub-mkconfig -o /boot/grub/grub.cfg;;
|
||||||
(/etc/locale.gen) sudoedit "$sel" && sudo locale-gen;;
|
(/etc/locale.gen) sudoedit "$sel" && sudo locale-gen;;
|
||||||
|
|
|
@ -7,6 +7,12 @@ 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:
|
||||||
|
tldr
|
||||||
|
info
|
||||||
|
man
|
||||||
|
test-colors
|
||||||
|
arg-test / arg-notify"
|
||||||
esac
|
esac
|
||||||
|
|
||||||
showinfo() {
|
showinfo() {
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
# Keeps the Internet at bay
|
# Keeps the Internet at bay
|
||||||
if test -e "$JOURNAL"; then
|
if test -e "$JOURNAL"; then
|
||||||
|
# TODO ask previous
|
||||||
echo "What do you want to do? Check your journal!" >&2
|
echo "What do you want to do? Check your journal!" >&2
|
||||||
while test $(echo "$intention" | wc -c) -lt 10
|
mins=${1:-10}
|
||||||
|
while test $(echo "$intention" | wc -c) -lt $mins
|
||||||
do read intention
|
do read intention
|
||||||
done
|
done
|
||||||
jrnl intentions "$intention"
|
jrnl intentions "$intention"
|
||||||
sudo nft flush chain inet filter outall
|
sudo nft flush chain inet filter outall
|
||||||
sudo nft add rule inet filter outall meta hour "$(date +%H:%M)"-"$(date +%H:%M --date="${1:-10}min")" accept
|
sudo nft add rule inet filter outall meta hour "$(date +%H:%M)"-"$(date +%H:%M --date="${mins}min")" accept
|
||||||
#expr \( "$1" \> 40 \) \* 10 \| "$1"
|
#expr \( "$1" \> 40 \) \* 10 \| "$1"
|
||||||
apprise $(pass service/apprise/intentions | head -1) -t 'janeks intention' -b "$intention"
|
apprise $(pass service/apprise/intentions | head -1) -t "janeks intention for ${mins} min" -b "$intention"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
opusenc "$@" "${1%.*}.opus"
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
chmod +x *.AppImage *.exe *.sh "$@"
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/sh -e
|
||||||
|
# Make a gzipped image of a disk with dd
|
||||||
|
sudo dd status=progress "if=$1" bs=1M | gzip > "$2.img.gz"
|
||||||
|
# bs=4k | ssh naspi dd bs=4k of=/data/backups/sd/220811_janek.gz
|
Loading…
Reference in New Issue