1. Create a new Python environment variable configuration file:
Vim ~/.pystartup
# ADD Auto-completion and a stored history file of commands to your python# interactive interpreter. Requires Python 2.0+, ReadLine. Autocomplete is# bound to the ESC key by default (you can change It-see readline docs). # # Store the file in ~/.pystartup , and set an environment variable to point# to it: ' export Pythonstartup=~/.pystartup ' in Bash.import atexitimport OSI Mport readlineimport rlcompleterreadline.parse_and_bind (' tab:complete ') 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) atexit.register (save_ History) del OS, atexit, ReadLine, Rlcompleter, Save_history, Historypath
2. Set the python environment variable:
Immediate effect, restart failure: Export Pythonstartup=~/.pystartup
Permanently valid for the current User: echo "Export Pythonstartup=~/.pystartup" >> ~/.bash_profile
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Set python command-line interactivity to auto-complement