From 1645c165c372481dff4f03be5901b8be183b000a Mon Sep 17 00:00:00 2001 From: cschantz Date: Tue, 11 Nov 2025 17:15:54 -0500 Subject: [PATCH] Add file-based history cleaning to trace eraser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes: - Clean ~/.bash_history file directly after in-memory cleaning - Handles commands from other terminal sessions - Ensures complete cleanup even if history not yet written Issue: - history -d only cleans current session's in-memory history - Commands from other sessions remain in ~/.bash_history file - User's curl command persisted because it was from different session Solution: - After history -w, also grep -Ev on the history file - Removes toolkit commands regardless of which session added them Tested: ✓ Pattern matches user's curl command format ✓ Extracts correct entry numbers --- tools/erase-toolkit-traces.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/erase-toolkit-traces.sh b/tools/erase-toolkit-traces.sh index 0d29cd2..a885f2e 100755 --- a/tools/erase-toolkit-traces.sh +++ b/tools/erase-toolkit-traces.sh @@ -181,6 +181,15 @@ if [ "$CLEAN_HISTORY" = true ] && [ -f ~/.bash_history ]; then echo " ✓ Cleaned history written to file" + # Also clean the history file directly (in case commands are from other sessions) + echo " → Cleaning history file for commands from other sessions..." + 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.$$ + echo " ✓ History file cleaned" + fi + echo " ✓ In-memory history reloaded from cleaned file" echo "" echo "NOTE: Other active terminal sessions may still have old history in memory."