diff --git a/launcher.sh b/launcher.sh index 1e91471..120537b 100755 --- a/launcher.sh +++ b/launcher.sh @@ -1507,7 +1507,27 @@ main() { read -p "Clean history and remove traces? (yes/no): " clean_hist if [ "$clean_hist" = "yes" ]; then - # Run trace eraser in non-interactive mode (suppress output) + # Clean history in current shell FIRST (before subprocess) + # This ensures the parent shell's history is cleaned + GREP_PATTERN="git\.mull\.lol|linux-server-management-toolkit|server-toolkit|launcher\.sh|erase-toolkit-traces" + + # Clean the history file + 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 current shell's in-memory history + history -c + + # Reload cleaned history + history -r ~/.bash_history + + # Unset HISTFILE to prevent re-writing on exit + unset HISTFILE + + # Now run trace eraser for logs/files/directory cleanup TRACE_ERASER_AUTO=yes bash "$BASE_DIR/tools/erase-toolkit-traces.sh" 2>&1 | grep -E "^✓|^$" || true fi