To make it easier to use Python in Terminal, add a script in the home directory . Pythonstartup, the content is as follows,
Then add the export Pythonstartup=~/.pythonstartupin. BASHRC,
This enables the automatic completion of Python using Tab in Terminal.
#!/usr/bin/python##-----------------------------------------------------------------------------##Usage:#-Rename this file to ". Pythonstartup"#-Put it under your home directory, e.g. "~"#-Modify BASHRC, add following line,#Export Pythonstartup=~/.pythonstartup##-----------------------------------------------------------------------------ImportReadLineImportRlcompleterImportatexitImportOS#Tab CompletionReadline.parse_and_bind ('Tab:complete')#History FileHistfile = Os.path.join (os.environ['HOME'],'. Pythonhistory')Try: Readline.read_history_file (histfile)exceptIOError:PassAtexit.register (Readline.write_history_file, Histfile)delOS, Histfile, ReadLine, Rlcompleter
Finish.
Python Auto-completion in Terminal