initial dotfiles

This commit is contained in:
srtk 2026-04-25 16:39:11 +05:30
commit 45e5fe53d2
370 changed files with 25449 additions and 0 deletions

View file

@ -0,0 +1,30 @@
#!/usr/bin/env bash
BACKUP_DIR="/drives/rei/backup"
# Hard-delete whitelist (exact real paths)
ALLOW_DELETE=(
"$HOME/.cache"
"/drives/rei/backup"
)
mkdir -p "$BACKUP_DIR"
for item in "$@"; do
real_item="$(realpath "$item" 2>/dev/null)"
# Check if the item is in the hard-delete whitelist
for allowed in "${ALLOW_DELETE[@]}"; do
real_allowed="$(realpath "$allowed" 2>/dev/null)"
if [[ "$real_item" == "$real_allowed"* ]]; then
rm -rf -- "$item"
continue 2
fi
done
# Otherwise move to backup with timestamp
base="$(basename "$item")"
ts="$(date +%Y%m%d_%H%M%S)"
mv -- "$item" "$BACKUP_DIR/$base-$ts"
done