#!/bin/bash # Script Version: 0.1 # Description: Interactive cleanup for stale Python tool CLI files in ~/.local/bin (at2 workstation) # Set variables # ======== TARGET_DIR="$HOME/.local/bin" LOG_FILE="$HOME/.clean_local_bin.log" # Functions # ======== # List suspected legacy tools list_legacy_tools() { find "$TARGET_DIR" -maxdepth 1 -type f \( \ -name 'futurize' -o -name 'pasteurize' -o -name 'pkginfo' -o -name 'pybabel' \ -o -name 'pygmentize' -o -name 'webassets' -o -name 'wheel' \ -o -name 'mutagen-*' -o -name 'mid3*' -o -name 'moggsplit' \ -o -name 'filetype' -o -name 'normalizer' -o -name 'markdown*' \ -o -name 'jsonschema' -o -name 'httpx' -o -name 'openai' \ -o -name 'unidecode' -o -name 'netaddr' -o -name 'flask' \ -o -name 'pyserial-*' -o -name 'psg*' \ \) } # Main Process # ======== echo "[DEBUG] Scanning $TARGET_DIR for workshop leftovers..." list_legacy_tools > /tmp/.local_bin_candidates.txt if [[ ! -s /tmp/.local_bin_candidates.txt ]]; then echo "[DEBUG] Nothing found to delete." exit 0 fi echo "[DEBUG] Found the following candidates:" cat /tmp/.local_bin_candidates.txt echo "[DEBUG] Proceed with deletion? (y/n)" read CONFIRM if [[ "$CONFIRM" != "y" ]]; then echo "[DEBUG] Aborted by user" exit 1 fi echo "[DEBUG] Deleting files and logging to $LOG_FILE" while read -r FILE; do echo "[DEBUG] Removing $FILE" echo "$(date) [DELETED] $FILE" >> "$LOG_FILE" rm -v "$FILE" done < /tmp/.local_bin_candidates.txt echo "[DEBUG] Cleanup done." # EOF