python: add history to pdb

This commit is contained in:
J. Fernando Sánchez
2026-06-10 23:06:27 +02:00
parent 89f9e3d9bc
commit 1035c858fc
2 changed files with 59 additions and 34 deletions

18
python/.pdbrc Normal file
View File

@@ -0,0 +1,18 @@
# ~/.pdbrc
import atexit
import os
import readline
# Define where the pdb command history will be saved
historyPath = os.path.expanduser("~/.pdb_history")
# Read existing history if it exists
if os.path.exists(historyPath):
readline.read_history_file(historyPath)
# Register a hook to automatically save history when exiting pdb
def save_history(historyPath=historyPath):
import readline
readline.write_history_file(historyPath)
atexit.register(save_history)