In the use of Python sometimes always forget a lot of code, this is the most headache for the program Yuan thing, I was just contact Python, these days is also used this piece, so recorded, has been needed to be able to find.
My system is:
[Email protected]:~$ uname-alinux w 4.2.0-16-generic #19-ubuntu SMP Thu Oct 8 15:35:06 UTC x86_64 x86_64 x86_64 gnu/ Linux
First look at your own Python installation path, if you do not know the following methods can be viewed as follows:
[Email protected]:~$ pythonpython 2.7.10 (default, OCT, 16:09:02) [GCC 5.2.1 20151010] on Linux2type ' help ', ' copy Right "," credits "or" license "for more information.>>> import sys>>> sys.path[', '/usr/lib/python2.7 ', '/usr/lib/python2.7/plat-x86_64-linux-gnu ', '/usr/lib/python2.7/lib-tk ', '/usr/lib/python2.7/lib-old ', '/usr/ Lib/python2.7/lib-dynload ', '/usr/local/lib/python2.7/dist-packages ', '/usr/lib/python2.7/dist-packages ', '/usr/ Lib/python2.7/dist-packages/pilcompat ', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client ']
Now that the Python installation path is found, pass the following code in
#!/usr/bin/python# python startup fileimport sysimport readlineimport rlcompleterimport atexitimport os# tab Completionreadline.parse_and_bind (' Tab:complete ') # History filehistfile = Os.path.join (os.environ[' HOME '), '. Pythonhistory ') try:readline.read_history_file (histfile) except IOError:passatexit.register (Readline.write_ History_file, Histfile) del os, Histfile, ReadLine, Rlcompleter
The path and file name are arbitrary, but should be consistent at the time of invocation. However, the file must be uploaded to the python path:
[Email protected]:/usr/lib/python2.7/dist-packages$ vi tab.py #!/usr/bin/python# python startup FileImport sysimport Readlineimport rlcompleterimport atexitimport os# tab completionreadline.parse_and_bind (' Tab:complete ') # History Filehistfile = Os.path.join (os.environ[' HOME '), '. Pythonhistory ') try:readline.read_history_file (histfile) except IOError:passatexit.register (Readline.write_history_file, histfile) del os, Histfile, ReadLine, Rlcompleter
I uploaded the file to the/usr/lib/python2.7/dist-packages directory and named it with tab.py.
[Email protected]:~$ vi bashrc#for python export pythonstartup=/usr/lib/python2.7/dist-packages/tab.py# The path and file name above must be consistent with the above. [email protected]:~$ source. BASHRC #启用上面的环境
This article is from the "Wu-Dick" blog, please be sure to keep this source http://9827789.blog.51cto.com/9817789/1718144
Unbtun python tab completion