(a) System environment:
Os:centos 6.5final
python:2.6.6
(ii) Steps:
1, write a Python auto-complete script first readline and Rlcompleter modules specifically as follows:,
[Email protected] python2.6]# vim tab.py
#!/usr/bin/python # python tab file import sys import readline import rlcompleter import atexit import OS # TAB completion Readline.parse_and_bind (' Tab:complete ') # history file Histfile = Os.path.join (os.environ[' HOME '), '. Pythonhistory ') Try:readline.read_history_file (histfile) except Ioerror:pass atexit.register (Readline.write_history_file, Histfi Le) del os, Histfile, ReadLine, Rlcompleter
2, see the default path of the Python module,/usr/lib/python2.6/
[Email protected] ~]# Pythonpython 2.6.6 (r266:84292, Jul, 15:22:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on L Inux2type "Help", "copyright", "credits" or "license" for more information.>>> import sys>>> sys.path[' ', '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg ', '/usr/lib/python2.6/site-packages/ Pip-1.5.4-py2.6.egg ', '/usr/lib64/python26.zip ', '/usr/lib64/python2.6 ', '/usr/lib64/python2.6/plat-linux2 ', '/usr ' /lib64/python2.6/lib-tk ', '/usr/lib64/python2.6/lib-old ', '/usr/lib64/python2.6/lib-dynload ', '/usr/lib64/ Python2.6/site-packages ', '/usr/lib64/python2.6/site-packages/gtk-2.0 ', '/usr/lib/python2.6/site-packages ']> >>
The default path/usr/lib/python2.6/
3, copy the top script to this path
[email protected] site-packages]# CP tab.py/usr/lib/python2.6/
4, import the module is ready to use.
>>> import tab>>> sys.sys.__class__ ( sys.api_version       SYS.HEXVERSIONSYS.__DELATTR__ ( sys.argv sys.maxintsys.__dict__ sys.builtin_module_names sys.maxsizesys.__displayhook__ ( sys.byteorder sys.maxunicodesys.__doc__ sys.call_tracing ( sys.meta_pathsys.__egginsert sys.callstats ( sys.modulessys.__excepthook__ ( sys.copyright Sys.pathsys.__format__ ( Sys.displayhook ( sys.path_hookssys.__ GETATTRIBUTE__ ( sys.dont_write_bytecode Sys.path_importer_cachesys.__hash__ ( sys.exc_clear ( sys.platformsys.__init__ ( &Nbsp; sys.exc_info ( sys.prefixsys.__name__ sys.exc_type                SYS.PS1SYS.__NEW__ ( sys.excepthook ( sys.ps2sys.__package__ sys.exec_prefix sys.py3kwarning
This article is from the "Breght Moon" blog, make sure to keep this source http://liqingbiao.blog.51cto.com/3044896/1766606
Python command line Add tab auto-complete function