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


posted @   reblue520  阅读(291)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示