diff --git a/.config/shell/arch b/.config/shell/arch index 5e7f030..b4a6dc0 100644 --- a/.config/shell/arch +++ b/.config/shell/arch @@ -45,8 +45,8 @@ yas() { ) if test -n "$pkg" then echo "Installing $pkg..." - cmd="yay -Sy --batchinstall --rebuildall $pkg" - print -s "$cmd" + cmd="yay -S --batchinstall --rebuildall $pkg" + print -s $cmd eval "$cmd" rehash fi diff --git a/.config/shell/functions b/.config/shell/functions index 77e5466..1ba22c7 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -272,9 +272,10 @@ curlh() { unalias u 2>/dev/null # for bash u() { - # Line below handy for users of netkeeper + # Line below handy for users of netkeeper internet blocker #sudo nft list ruleset | grep -q outall && echo "Suspending netkeeper" >&2 | echo 'pausing netkeeper for sysupgrade' | netkeeper 30 2>/dev/null if command -v pacman >/dev/null; then + sudo find /var/lib/pacman/db.lck -mmin +600 -delete 2>/dev/null && echo 'Deleted stale pacman db.lock' if test "$(stat /etc/pacman.d/mirrorlist --printf=%y | cut -d'-' -f1-2)" != "$(date +%Y-%m)" then # TODO also run if location changed significantly or mirror is slow diff --git a/.local/bin/scripts/b b/.local/bin/scripts/b index dc60c0d..07f4dc9 100755 --- a/.local/bin/scripts/b +++ b/.local/bin/scripts/b @@ -50,6 +50,7 @@ fileinfo() { # I think this check is here to avoid scrolling text interpreted as video #probe="$($elevate ffprobe "$arg" 2>&1)" #echo $probe | grep -v -e '00:00:00.04' -e 'ansi' && + # Omit short videos: test $(printf "%.0f" $(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$file")) -gt 4 # Print media infos over file infos when <2G if ! { test "$size" -lt 2000000000 && $elevate ffprobe -hide_banner "$arg" 2>&1 | grep -E "bitrate: .{3,5} " | sed 's/, start:[^,]\+,/,/'; } || $inspect then $elevate stat --format "%U:%G %A %s $( diff --git a/.local/bin/scripts/dif b/.local/bin/scripts/dif index 788cf4d..5ed1cf6 100755 --- a/.local/bin/scripts/dif +++ b/.local/bin/scripts/dif @@ -16,10 +16,10 @@ if ! test "$command"; then (*sqlite*) sqldiff --summary "${files[@]}" | grep -v '0 changes, 0 inserts, 0 deletes';; # TODO syntax highlighting for INSERT/UPDATE/DELETE (text/*) # Use wiked-diff only for text <100KB - if test 100000 -gt "$(stat --format=%s "${files[@]}" | paste -s -d'+' | bc)" - then wiked-diff "${files[@]}" - else diff --color=always --unified=1 --report-identical-files "${files[@]}" - fi;; + test 100000 -gt "$(stat --format=%s "${files[@]}" | paste -s -d'+' | bc)" && + wiked-diff "${files[@]}" || + diff --color=always --unified=1 --report-identical-files "${files[@]}" + ;; (*) diff-color --report-identical-files "${files[@]}";; esac fi diff --git a/.local/bin/scripts/disktest b/.local/bin/scripts/disktest index 613893d..3ef7477 100755 --- a/.local/bin/scripts/disktest +++ b/.local/bin/scripts/disktest @@ -11,18 +11,20 @@ highlight() { echo "$1"; } highlight "Checking SMART with hdparm" # Needs sudo for read test -sudo hdparm -MWAgt "$disk" +sudo hdparm -MWAgt "$disk" || true if test $# -eq 0 then highlight "Write Test" sync - count=100$(test $(df --output="avail" . | tail -1) -gt 999999 && echo 0 || true) - # This prevents predictions by using random, but since that is too slow we have to copy a previously created file - highlight "Preparing random bits:" && - sudo dd status=progress if=/dev/random of=/var/tmp/tempfile bs=1M count=$count && + count=3000$(test $(df --output="avail" . | tail -1) -gt 999999 && echo 0 || true) + tempfile=/var/tmp/.$count + # Prevent deduplication/predictions by using random rather than zero, but since that is too slow we have to copy a previously created file + test -s $tempfile || + ( highlight "Preparing random bits:" && + sudo dd status=progress if=/dev/urandom of=$tempfile bs=1M count=$count ) && highlight "Copying random bits:" && - sudo dd status=progress if=/var/tmp/tempfile of=tempfile bs=1M count=$count + sudo dd status=progress if=$tempfile of=.$count bs=1M count=$count highlight "Copying zero bits:" && - sudo dd status=progress if=/dev/zero of=tempfile bs=1M count=$count - sudo rm tempfile + sudo dd status=progress if=/dev/zero of=.$count bs=1M count=$count + sudo rm .$count fi diff --git a/.local/bin/scripts/downloads-hui b/.local/bin/scripts/downloads-hui new file mode 100755 index 0000000..a480f07 --- /dev/null +++ b/.local/bin/scripts/downloads-hui @@ -0,0 +1,8 @@ +#!/bin/sh -e +cd "$DATA/1-projects/software-challenge/capper/gui/src/main/resources/hui/" +rm -- * +mv "$DATA/5-incubator/download"/hui_*.zip . +unzip -- *.zip +mv -- */* . +git add . +exec $SHELL diff --git a/.local/bin/scripts/fix b/.local/bin/scripts/fix new file mode 100755 index 0000000..ed03ef3 --- /dev/null +++ b/.local/bin/scripts/fix @@ -0,0 +1,4 @@ +#!/bin/sh +# Fix odd processes getting stuck +systemctl --user restart espanso & +mpdr diff --git a/.local/bin/scripts/jrnl-tag b/.local/bin/scripts/jrnl-tag index bf8b94d..88e0487 100755 --- a/.local/bin/scripts/jrnl-tag +++ b/.local/bin/scripts/jrnl-tag @@ -2,9 +2,14 @@ # Find terms in jrnl files and turn them into tags # Check with jrnl --tags if test $# -eq 0 -then $0 sleep lens uni nap cry health tech read girl dev phone Zinc bike tour laptop computer PC piano faith CB Claudia Franklin Kerstin Henri Katja Erlangen Bayreuth Berlin ICF Joan +then + set -x + $0 sleep uni nap cry tech read dev phone bike tour laptop computer piano faith health lens Zinc \ + girl CB Claudia Kerstin Turi Taura \ + Erlangen Bayreuth Berlin ICF + true $? else for arg - do rpl "\(^\|[^@/]\)\b$arg\b" "\1@$arg" $JOURNAL/*.txt 2>/dev/null + do rpl "\(^\|[^@/]\)\b$arg\b" "\1@$arg" "$JOURNAL"/*.jrnl 2>/dev/null done fi diff --git a/.local/bin/scripts/kubeclean b/.local/bin/scripts/kubeclean new file mode 100755 index 0000000..d91c752 --- /dev/null +++ b/.local/bin/scripts/kubeclean @@ -0,0 +1,6 @@ +#!/bin/sh -e +# Cleanup Inactive and Broken Pods +kubectl get pods --all-namespaces --no-headers | + egrep -iv 'PodInitializing|Running|ContainerCreating|Terminating' | + awk '{print "--namespace=" $1 " " $2}' | + xargs -L 1 kubectl delete pod diff --git a/.local/bin/scripts/m b/.local/bin/scripts/m index 741a954..96c6e5e 100755 --- a/.local/bin/scripts/m +++ b/.local/bin/scripts/m @@ -10,7 +10,7 @@ dir="$(dirname "$1")" test "$(lsattr -d "$dir" 2>/dev/null | cut -c6)" = a && setappend=true test -z "$setappend" || sudo chattr -V -a "$dir" -$elevate mkdir -p $(case "$last" in (*/) echo "$last";; (*) dirname "$last";; esac) +$elevate mkdir -p "$(case "$last" in (*/) echo "$last";; (*) dirname "$last";; esac)" $elevate mv --verbose --interactive "$@" # TODO Diff when interactive diff --git a/.local/bin/scripts/mailto-handler b/.local/bin/scripts/mailto-handler new file mode 100755 index 0000000..517329f --- /dev/null +++ b/.local/bin/scripts/mailto-handler @@ -0,0 +1,14 @@ +#!/bin/sh -e + +# Extract the email address from the mailto link +mailto_link="$1" +email_address="${mailto_link#mailto:}" + +# Copy the extracted email address to the clipboard +echo -n "$email_address" | xclip -selection clipboard + +# Optional: Notify the user +notify-send "Email address copied to clipboard" "$email_address" + +# Optional: Log the copied email addresses for debugging +echo "Copied email address: $email_address" >> ~/mailto_log.txt diff --git a/.local/bin/scripts/nv b/.local/bin/scripts/nv new file mode 100755 index 0000000..00f5763 --- /dev/null +++ b/.local/bin/scripts/nv @@ -0,0 +1,3 @@ +#!/bin/sh -e +# Toggle NordVPN +nordvpn status | grep --color=never Disconnected && nordvpn connect de || nordvpn disconnect; nordvpn status diff --git a/.local/bin/scripts/save b/.local/bin/scripts/save index 05a1ca5..e15c5e7 100755 --- a/.local/bin/scripts/save +++ b/.local/bin/scripts/save @@ -1,4 +1,5 @@ #!/bin/sh -e # Put system to sleep after specified number of seconds -$(which timer || sleep) "${@:-10}" +mpc pause || mpdr +$(which timer || sleep) "${@:-30}" systemctl suspend diff --git a/.local/bin/scripts/wl-save b/.local/bin/scripts/wl-save new file mode 100755 index 0000000..4ac0ecd --- /dev/null +++ b/.local/bin/scripts/wl-save @@ -0,0 +1,5 @@ +#!/bin/sh -e +# Save wl clipboard image with last copied url +file="$(date +%y%m%d-%H%M%S)_$(cliphist list | grep https:// | head -1 | rev | cut -d/ -f1 | rev).png" +wl-paste >"$file" +b "$file" diff --git a/.zshenv b/.zshenv index 42d2b08..a1f0682 100644 --- a/.zshenv +++ b/.zshenv @@ -154,6 +154,7 @@ export CMAKE_BUILD_PARALLEL_LEVEL=${SPARE_CORES} export CTEST_PARALLEL_LEVEL=${SPARE_CORES} export CTEST_PROGRESS_OUTPUT=1 export CTEST_OUTPUT_ON_FAILURE=1 +export CARGO_BUILD_JOBS=${SPARE_CORES} # TODO move to proper place - is also called when firenvim starts #autolight