Add file-based history cleaning to trace eraser
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
This commit is contained in:
@@ -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."
|
||||
|
||||
Reference in New Issue
Block a user