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.
This commit is contained in:
+4
-11
@@ -1507,19 +1507,12 @@ main() {
|
|||||||
read -p "Clean history and remove traces? (yes/no): " clean_hist
|
read -p "Clean history and remove traces? (yes/no): " clean_hist
|
||||||
|
|
||||||
if [ "$clean_hist" = "yes" ]; then
|
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 ""
|
||||||
echo -e "${GREEN}✓ All traces removed${NC}"
|
echo -e "${YELLOW}After launcher exits, run:${NC}"
|
||||||
echo ""
|
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 ""
|
echo ""
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user