From 6d4ee75eb116a0f1858d36c97f62db4335edce22 Mon Sep 17 00:00:00 2001 From: "Andrew R. M" Date: Mon, 3 Oct 2016 02:26:44 -0400 Subject: [PATCH] Use the .history directory for readline history --- pythonrc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pythonrc b/pythonrc index 7a54a82..2f88b26 100644 --- a/pythonrc +++ b/pythonrc @@ -1,8 +1,17 @@ -#!/usr/bin/env python +#{- ~/.pythonrc -}# +import atexit +import os +import readline import sys # Primary prompt: (>>> ) in magenta sys.ps1 = '\033[1;35m>>>\033[0m ' # Secondary prompt: (... ) in red sys.ps2 = '\033[1;31m...\033[0m ' + +# Use ~/.history/python as a history file instead of ~/.python_history +history_file = os.path.join (os.environ['HOME'], '.history', 'python') +if os.path.exists(history_file): + readline.read_history_file(history_file) +atexit.register(readline.write_history_file, history_file)