#需求
为了方便工作,我们需要在Python终端下添加Tab健补全功能
#存放脚本路径
Pyhton2.6
/usr/lib/python2.6/site-packages/
Python2.7
/usr/lib/python2.7/dist-packages/
#脚本代码
[root@localhost ~]# cat /usr/lib/python2.6/site-packages/tab.py try: import readline except ImportError: print("Module readline not available.") else: import rlcompleter readline.parse_and_bind("tab: complete")
#bashrc文件配置
[root@localhost ~]# tail -1 /etc/bashrc export PYTHONSTARTUP="/usr/lib/python2.6/site-packages/tab.py"
#注销重新登陆
[root@localhost ~]# login
#测试
[root@localhost ~]# python Python 2.6.6 (r266:84292, Jul 23 2015, 15:22:56) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys. sys.__class__( sys.argv sys.maxint sys.__delattr__( sys.builtin_module_names sys.maxsize sys.__dict__ sys.byteorder sys.maxunicode sys.__displayhook__( sys.call_tracing( sys.meta_path sys.__doc__ sys.callstats( sys.modules sys.__excepthook__( sys.copyright sys.path sys.__format__( sys.displayhook( sys.path_hooks sys.__getattribute__( sys.dont_write_bytecode sys.path_importer_cache sys.__hash__( sys.exc_clear( sys.platform sys.__init__( sys.exc_info( sys.prefix sys.__name__ sys.exc_type sys.ps1 sys.__new__( sys.excepthook( sys.ps2 sys.__package__ sys.exec_prefix sys.py3kwarning sys.__reduce__( sys.executable sys.setcheckinterval( sys.__reduce_ex__( sys.exit( sys.setdlopenflags( sys.__repr__( sys.flags sys.setprofile( sys.__setattr__( sys.float_info sys.setrecursionlimit( sys.__sizeof__( sys.getcheckinterval( sys.settrace( sys.__stderr__ sys.getdefaultencoding( sys.stderr sys.__stdin__ sys.getdlopenflags( sys.stdin sys.__stdout__ sys.getfilesystemencoding( sys.stdout sys.__str__( sys.getprofile( sys.subversion sys.__subclasshook__( sys.getrecursionlimit( sys.version sys._clear_type_cache( sys.getrefcount( sys.version_info sys._current_frames( sys.getsizeof( sys.warnoptions sys._getframe( sys.gettrace( sys.api_version sys.hexversion >>> sys.