Activer l’historique dans le shell Python

Créer un fichier ~/.pythonrc.py et écrire dedans:

#!/usr/bin/env python

import os,readline,atexit

hist = os.path.join(os.environ['HOME'], ".python_history")

try:
	readline.read_history_file(hist)
except IOError:
	pass

readline.set_history_length(100)
readline.parse_and_bind("tab: complete")
atexit.register(readline.write_history_file, hist)

del hist, os, readline, atexit