diff --git a/launcher.sh b/launcher.sh index 19c9ba7..0d0e002 100755 --- a/launcher.sh +++ b/launcher.sh @@ -1507,42 +1507,19 @@ main() { read -p "Clean history and remove traces? (yes/no): " clean_hist if [ "$clean_hist" = "yes" ]; then - # Create a cleanup script for the parent shell to source - cat > /tmp/.cleanup_history_$$.sh << 'CLEANUP_EOF' -# Disable history recording -set +o history -shopt -u histappend 2>/dev/null || true - -# Clean the history file -GREP_PATTERN="git\.mull\.lol|linux-server-management-toolkit|server-toolkit|launcher\.sh|erase-toolkit-traces" -if [ -f ~/.bash_history ]; then - cp ~/.bash_history ~/.bash_history.bak.$$ - grep -Ev "$GREP_PATTERN" ~/.bash_history.bak.$$ > ~/.bash_history 2>/dev/null || true - rm -f ~/.bash_history.bak.$$ -fi - -# Clear and reload history -history -c -history -r ~/.bash_history -unset HISTFILE - -# Clean up this temp script -rm -f /tmp/.cleanup_history_*.sh 2>/dev/null - -echo "" -echo "✓ History cleaned. Exit and start new shell to verify." -echo "" -CLEANUP_EOF - - # Run trace eraser for logs/files/directory cleanup + # Run the trace eraser in auto mode (removes files, logs, directory) TRACE_ERASER_AUTO=yes bash "$BASE_DIR/tools/erase-toolkit-traces.sh" 2>&1 | grep -E "^✓|^$" || true + # Create a simple helper script for parent shell history cleanup + # (Parent shell needs to source this since subprocess can't modify parent's history) + cat > /tmp/.cleanup_hist.sh << 'HIST_EOF' +set +o history; shopt -u histappend 2>/dev/null; GREP_PATTERN="git\.mull\.lol|linux-server-management-toolkit|server-toolkit|launcher\.sh|erase-toolkit-traces"; [ -f ~/.bash_history ] && cp ~/.bash_history ~/.bash_history.bak.$$ && grep -Ev "$GREP_PATTERN" ~/.bash_history.bak.$$ > ~/.bash_history 2>/dev/null && rm -f ~/.bash_history.bak.$$; history -c; history -r ~/.bash_history; unset HISTFILE; rm -f /tmp/.cleanup_hist.sh; echo ""; echo "✓ History cleaned"; echo "" +HIST_EOF + echo "" echo -e "${GREEN}✓ All traces removed${NC}" echo "" - echo -e "${YELLOW}IMPORTANT: Run this command now to clean your shell's history:${NC}" - echo "" - echo "source /tmp/.cleanup_history_$$.sh" + echo -e "${YELLOW}Run this to finish cleanup:${NC} source /tmp/.cleanup_hist.sh" echo "" else echo ""