Skip to content

Instantly share code, notes, and snippets.

@zachaysan
Created June 2, 2020 12:38
Show Gist options
  • Save zachaysan/25712f3e9aa02a234437f89c60cad8d0 to your computer and use it in GitHub Desktop.
Save zachaysan/25712f3e9aa02a234437f89c60cad8d0 to your computer and use it in GitHub Desktop.
import pdb
import atexit
import os
import readline
from pathlib import Path
class Config(pdb.DefaultConfig):
sticky_by_default = True
history_path = os.path.expanduser("~/.pdb_history")
Path(history_path).touch()
if os.path.getsize(history_path) > 100 * 1024:
os.remove(history_path)
Path(history_path).touch()
def save_history(history_path=history_path):
readline.write_history_file(history_path)
if os.path.exists(history_path):
readline.read_history_file(history_path)
atexit.register(save_history, history_path=history_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment