diff --git a/tools/erase-toolkit-traces.sh b/tools/erase-toolkit-traces.sh index a885f2e..685c5f0 100755 --- a/tools/erase-toolkit-traces.sh +++ b/tools/erase-toolkit-traces.sh @@ -115,32 +115,9 @@ rm -f "$SCRIPT_DIR/.sysref" 2>/dev/null rm -f "$SCRIPT_DIR/.sysref.timestamp" 2>/dev/null echo " ✓ Reference database removed" -# Offer to remove the entire toolkit -echo "" -echo -e "${YELLOW}Final step: Remove toolkit directory?${NC}" -echo "This will delete: $SCRIPT_DIR" -echo "" -read -p "Remove entire toolkit directory? (yes/no): " remove_dir - -if [ "$remove_dir" = "yes" ]; then - echo "" - echo "Removing toolkit directory..." - cd /root - rm -rf "$SCRIPT_DIR" - echo "" - echo -e "${GREEN}✓ Toolkit completely removed${NC}" - echo "" - echo "All traces have been erased." - exit 0 -else - echo "" - echo -e "${GREEN}✓ History and logs cleaned${NC}" - echo "" - echo "Toolkit directory remains at: $SCRIPT_DIR" - echo "You can manually remove it later with: rm -rf $SCRIPT_DIR" -fi - -# Final step: Clean bash history (done last to capture all script commands) +# Clean bash history BEFORE asking about directory removal +# (This ensures history is cleaned even if user removes toolkit directory) +CLEAN_HISTORY=true if [ "$CLEAN_HISTORY" = true ] && [ -f ~/.bash_history ]; then echo "" echo "→ Final cleanup: Removing bash history..." @@ -197,6 +174,30 @@ if [ "$CLEAN_HISTORY" = true ] && [ -f ~/.bash_history ]; then echo " or simply logout/login to start completely fresh." fi +# Offer to remove the entire toolkit (AFTER history cleaning) +echo "" +echo -e "${YELLOW}Final step: Remove toolkit directory?${NC}" +echo "This will delete: $SCRIPT_DIR" +echo "" +read -p "Remove entire toolkit directory? (yes/no): " remove_dir + +if [ "$remove_dir" = "yes" ]; then + echo "" + echo "Removing toolkit directory..." + cd /root + rm -rf "$SCRIPT_DIR" + echo "" + echo -e "${GREEN}✓ Toolkit completely removed${NC}" + echo "" + echo "All traces have been erased." +else + echo "" + echo -e "${GREEN}✓ History and logs cleaned${NC}" + echo "" + echo "Toolkit directory remains at: $SCRIPT_DIR" + echo "You can manually remove it later with: rm -rf $SCRIPT_DIR" +fi + echo "" echo "All traces removed. The trace eraser commands will also be" echo "removed when you log out or start a new shell session."