From 2ac0e017661ed7267a85f15cce49eaed6763f80c Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Tue, 12 Jul 2022 17:10:43 +0200 Subject: [PATCH] python: Handle non-existing history file Create a dummy entry in the history file if it does not exist yet or is empty. Otherwise `~/.python_history` would be used by site.py. --- .config/python/pythonrc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.config/python/pythonrc b/.config/python/pythonrc index 6756196..f2353e6 100644 --- a/.config/python/pythonrc +++ b/.config/python/pythonrc @@ -19,6 +19,11 @@ try: except OSError: pass +# Create dummy entry if the file does not yet exist, as otherwise +# ~/.python_history is used by site.py +if not readline.get_current_history_length(): + readline.add_history("# python history file") + def write_history(): try: readline.write_history_file(history)