python环境下使用tab自动补全命令
# vim /usr/lib/python2.7/dist-packages/tab.py
加入如下内容:
#!/usr/bin/env python # python startup 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, histfile) del os, histfile, readline, rlcompleter
测试:
# python Python 2.7.3 (default, Aug 1 2012, 05:16:07) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> import tab >>> sys. sys.__class__( sys.argv sys.hexversion sys.__delattr__( sys.builtin_module_names sys.long_info sys.__dict__ sys.byteorder sys.maxint sys.__displayhook__( sys.call_tracing( sys.maxsize sys.__doc__ sys.callstats( sys.maxunicode sys.__excepthook__( sys.copyright sys.meta_path sys.__format__( sys.displayhook( sys.modules sys.__getattribute__( sys.dont_write_bytecode sys.path sys.__hash__( sys.exc_clear( sys.path_hooks sys.__init__( sys.exc_info( sys.path_importer_cache sys.__name__ sys.exc_type sys.platform sys.__new__( sys.excepthook( sys.prefix sys.__package__ sys.exec_prefix sys.ps1 sys.__reduce__( sys.executable sys.ps2 sys.__reduce_ex__( sys.exit( sys.py3kwarning sys.__repr__( sys.exitfunc( sys.pydebug sys.__setattr__( sys.flags sys.setcheckinterval( sys.__sizeof__( sys.float_info sys.setdlopenflags( sys.__stderr__ sys.float_repr_style sys.setprofile( sys.__stdin__ sys.getcheckinterval( sys.setrecursionlimit( sys.__stdout__ sys.getdefaultencoding( sys.settrace( sys.__str__( sys.getdlopenflags( sys.stderr sys.__subclasshook__( sys.getfilesystemencoding( sys.stdin sys._clear_type_cache( sys.getprofile( sys.stdout sys._current_frames( sys.getrecursionlimit( sys.subversion sys._getframe( sys.getrefcount( sys.version sys._mercurial sys.getsizeof( sys.version_info sys.api_version sys.gettrace( sys.warnoptions