Use the .history directory for readline history

This commit is contained in:
Andrew R. M 2016-10-03 02:26:44 -04:00
parent 0d9a54719a
commit 6d4ee75eb1

View File

@ -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)