From 73513ec2828fca612df9de95c722b4380996ada0 Mon Sep 17 00:00:00 2001 From: cschantz Date: Tue, 11 Nov 2025 18:14:01 -0500 Subject: [PATCH] Simplify exit cleanup to source single trace eraser script Exit menu now tells user to SOURCE the trace eraser instead of running it as subprocess: - Single command: TRACE_ERASER_AUTO=yes source tools/erase-toolkit-traces.sh - Sourcing runs it in current shell, allowing it to modify that shell's history - No more separate helper scripts or multiple steps - Single source of truth for all cleanup logic This fixes the parent shell history issue - by sourcing instead of running as subprocess, the trace eraser can actually modify the shell's history where the curl command was executed. --- launcher.sh | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/launcher.sh b/launcher.sh index 0d0e002..fb79b1e 100755 --- a/launcher.sh +++ b/launcher.sh @@ -1507,19 +1507,12 @@ main() { read -p "Clean history and remove traces? (yes/no): " clean_hist if [ "$clean_hist" = "yes" ]; then - # 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 -e "${YELLOW}After launcher exits, run:${NC}" echo "" - echo -e "${YELLOW}Run this to finish cleanup:${NC} source /tmp/.cleanup_hist.sh" + echo "TRACE_ERASER_AUTO=yes source $BASE_DIR/tools/erase-toolkit-traces.sh" + echo "" + echo -e "${YELLOW}This will clean history in your current shell and remove all traces.${NC}" echo "" else echo ""