1.获取python目录【我使用的是64位ubuntu系统】

[~$]python
Python 2.7.3 (default, Apr 10 2013, 06:20:15)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/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/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client', '/usr/lib/python2.7/dist-packages/ubuntuone-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', '/usr/lib/python2.7/dist-packages/ubuntuone-couch',
'/usr/lib/python2.7/dist-packages/ubuntuone-installer', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']
>>>

从上面看出python在我电脑上的路径是  /usr/lib/python2.7

2.切换至该目录写个startup.py的脚本,脚本目录就是处理python中<tab>事件,脚本内容如下

#!/usr/bin/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

3.切换至自己主目录

[/usr/lib/python2.7$]cd
[~$]vi .bashrc

4. 增加环境变量

#for python
export PYTHONSTARTUP=/usr/lib/python2.7/startup.py

5.配置环境变量生效

[~$]source .bashrc 

PYTHONSTARTUP是什么东西呢?

If this is the name of a readable file, the Python commands in that file are executed before the first prompt
is displayed in interactive mode. The file is executed in the same name space where interactive commands are
executed so that objects defined or imported in it can be used without qualification in the interactive session.
You can also change the prompts sys.ps1 and sys.ps2 in this file.

python <tab>自动补全的更多相关文章

  1. Linux python <tab>自动补全

    为Python添加交互模式下TAB自动补全以及命令历史功能. 1.获取python目录 [root@localhost ~]# python Python 2.6.6 (r266:84292, Jul ...

  2. python tab 自动补全

    学习python,经常要使用python命令行查找一些不熟悉的使用方法等等,但是python命令行下没有自带tab补全的功能,看见别人写了tab,可以解决特此记下,以备后用 1.创建tab.py文件, ...

  3. python Tab自动补全命令设置

    Mac/Windows下需要安装模块儿 pip install pyreadline pip install rlcompleter pip install readline 注意,需要先安装pyre ...

  4. Python建立Tab自动补全的脚本

    Python建立Tab自动补全的脚本 #!/usr/bin/python #python steup file import sys import readline import rlcomplete ...

  5. Python-2.7 配置tab自动补全功能

    作者博文地址:http://www.cnblogs.com/spiritman/ 之前一直使用shell编程,习惯了shell的 tab 自动补全功能,而Python的命令行却不支持 tab 自动补全 ...

  6. Python-2.7 配置 tab 自动补全功能

    作者博文地址:http://www.cnblogs.com/liu-shuai/ 之前一直使用shell编程,习惯了shell的 tab 自动补全功能,而Python的命令行却不支持 tab 自动补全 ...

  7. 如何为 .NET Core CLI 启用 TAB 自动补全功能

    如何为 .NET Core CLI 启用 TAB 自动补全功能 Intro 在 Linux 下经常可以发现有些目录/文件名,以及有些工具可以命令输入几个字母之后按 TAB 自动补全,最近发现其实 do ...

  8. Mysql命令行tab自动补全方法

    在mysql命令行有时为了方便想要按tbl键自动补全命令,以便节约时间. 具体方法如下: 第一步:修改my.cnf vi mysql/etc/my.cnf 将下图红框的代码注释,修改成如下代码: #d ...

  9. sudo和man的tab自动补全

    要加入sudo和man的tab自动补全功能,只需在~/.bashrc中加入: #Enabling tab-completioncomplete -cf sudocomplete -cf man

随机推荐

  1. IO-04. 混合类型数据格式化输入

    /** *A4-IO-04. 混合类型数据格式化输入 *C语言实现 *测试已通过 */ #include "stdio.h" int main() { float m1,m2; i ...

  2. 2014第13周四Webservice概念问题记

    晚上回来看网页学习了这两天一直疑惑的两个问题: 1.REST和SOAP架构下的Webservice的区别? 2.axis2和CXF的区别. 大部分是理论,暂时摘录一下,以后有更多实践后再回顾. 一.R ...

  3. [C#]DataTable常用操作总结

    ].RowState == DataRowState.Unchanged)        {            //Your logic        }        //⑩Convert to ...

  4. .NET,你忘记了么?(八)—— 从dynamic到特性误用 [转]

    1. 摘要 每个程序员都想写出漂亮的代码,但是什么是漂亮,这个我想每个人都有着自己的看法.那么我就说几种典型的想法: A. 写出别人看不懂的代码,让别人觉得很高深. B. 写出简短的代码 C. 用最新 ...

  5. SQLServer与Oracle的对照

        近期去铁科院面试,项目组长问了我这样一下问题:SQLServer与Oracle的差别是什么?从进入软件行业.从開始CS的编码到BS的编码过程中使用的都是SQLServer.在半年前開始敲DRP ...

  6. Oracle Bills of Material and Engineering Application Program Interface (APIs)

    In this Document Goal   Solution   1. Sample Notes for BOM APIs   2. Datatypes used in these APIs   ...

  7. deferred initcalls与模块化

    deferred initcalls与模块化 有两个技术可以加快kernel的启动速度: 1.deferred initcalls 2.模块化 它们的思想类似,都是将非必要的模块初始化推迟到内核启动之 ...

  8. ajax相关

    Javascript·部分: <script language="javascript" type="text/javascript" src=" ...

  9. Entity Framework Batch Update

      NuGet Package PM> Install-Package EntityFramework.Extended NuGet: http://nuget.org/List/Package ...

  10. JavaScript习题

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...