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. SQL Server MYSQL 对外键建立索引的必要性

    背景: 大家知道在定义外键时,都会给出on delete .....   on update .....: 这里指定的就是当主表的列发生变化时,从表的列要用怎么样的变化去迎合.对从表中的外键,建立索引 ...

  2. 可以使用QT给龙芯开发软件

    直接apt-get install libqt5core5a就有了,也许是一个很好的小众市场机会呢 至于系统,可以使用debian mips https://www.debian.org/devel/ ...

  3. IOS研究院之打开照相机与本地相册选择图片

    如下图所示 在本地相册中选择一张图片后,我们将他拷贝至沙盒当中,在客户端中将它的缩略图放在按钮旁边,这个结构其实和新浪微薄中选择图片后的效果一样.最终点击发送将按钮将图片2进制图片上传服务器. 下面我 ...

  4. Linux进程间通信——使用信号量

    这篇文章将讲述别一种进程间通信的机制——信号量.注意请不要把它与之前所说的信号混淆起来,信号与信号量是不同的两种事物.有关信号的更多内容,可以阅读我的另一篇文章:Linux进程间通信——使用信号.下面 ...

  5. [Leetcode][Python]39: Combination Sum

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 39: Combination Sumhttps://oj.leetcode. ...

  6. 抽象工厂模式firstones

    与工厂方法模式的区别是工厂子类中会创建出同一类型的不同产品对象.工厂方法模式则工厂子类中只是创建一种具体的产品对象 结构: 产品基类:子类继承的虚函数方法 具体产品子类:实现该产品功能 工厂基类:工厂 ...

  7. 在mangento后台调用wysiwyg编辑器

    在mangento后台调用操蛋的wysiwyg编辑器: 1.在头部加载TincyMCE protected function _prepareLayout() {     parent::_prepa ...

  8. C#编程规范

    C#编程规范 Version 1.0   目录 第一章 概述.... 4 规范制定原则.... 4 术语定义.... 4 Pascal 大小写.... 4 Camel 大小写.... 4 文件命名组织 ...

  9. cocos2d-x3.0 SpriteFrameCache

    bool HelloWorld::init() { ////////////////////////////// // 1. super init first if ( !Layer::init() ...

  10. 赵雅智_BroadcastReceiver电话监听

    AndroidManifest.xml 注冊广播接收者 加入权限 <?xml version="1.0" encoding="utf-8"?> &l ...