Python startup (command completion & history)

If you want command completion and a history in your python shell, export the PYTHONSTARTUP env var (export PYTHONSTARTUP=$HOME/.pystartup) in your bashrc and create a file ~/.pystartup with the following contents: import atexit import os import readline import rlcompleter historyPath = os.path.expanduser("~/.pyhistory") def save_history(historyPath=historyPath): import readline readline.write_history_file(historyPath) if os.path.exists(historyPath): readline.read_history_file(historyPath) readline.parse_and_bind(’tab: complete’) atexit.register(save_history) del os, … Continue reading Python startup (command completion & history)