python <tab>自动补全
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>自动补全的更多相关文章
- Linux python <tab>自动补全
为Python添加交互模式下TAB自动补全以及命令历史功能. 1.获取python目录 [root@localhost ~]# python Python 2.6.6 (r266:84292, Jul ...
- python tab 自动补全
学习python,经常要使用python命令行查找一些不熟悉的使用方法等等,但是python命令行下没有自带tab补全的功能,看见别人写了tab,可以解决特此记下,以备后用 1.创建tab.py文件, ...
- python Tab自动补全命令设置
Mac/Windows下需要安装模块儿 pip install pyreadline pip install rlcompleter pip install readline 注意,需要先安装pyre ...
- Python建立Tab自动补全的脚本
Python建立Tab自动补全的脚本 #!/usr/bin/python #python steup file import sys import readline import rlcomplete ...
- Python-2.7 配置tab自动补全功能
作者博文地址:http://www.cnblogs.com/spiritman/ 之前一直使用shell编程,习惯了shell的 tab 自动补全功能,而Python的命令行却不支持 tab 自动补全 ...
- Python-2.7 配置 tab 自动补全功能
作者博文地址:http://www.cnblogs.com/liu-shuai/ 之前一直使用shell编程,习惯了shell的 tab 自动补全功能,而Python的命令行却不支持 tab 自动补全 ...
- 如何为 .NET Core CLI 启用 TAB 自动补全功能
如何为 .NET Core CLI 启用 TAB 自动补全功能 Intro 在 Linux 下经常可以发现有些目录/文件名,以及有些工具可以命令输入几个字母之后按 TAB 自动补全,最近发现其实 do ...
- Mysql命令行tab自动补全方法
在mysql命令行有时为了方便想要按tbl键自动补全命令,以便节约时间. 具体方法如下: 第一步:修改my.cnf vi mysql/etc/my.cnf 将下图红框的代码注释,修改成如下代码: #d ...
- sudo和man的tab自动补全
要加入sudo和man的tab自动补全功能,只需在~/.bashrc中加入: #Enabling tab-completioncomplete -cf sudocomplete -cf man
随机推荐
- cocos2d-x中常见的场景切换
本文转载自:http://www.cnblogs.com/linux-ios/archive/2013/04/09/3010779.html bool HelloWorld::init() { /// ...
- 点击后改变css属性
在html中: <div class="formbuilder"> <div class="active">Heading< ...
- Mining 影响数据挖掘结果的 5 方面
第一个: 数据类型. 对象的不同属性会用不同的数据类型来描述,如 年龄-->int; 生日 -->date;数据挖掘时也要对不同的类型有不同的对待. 第二个: 数据质量. 数据质量直接影 ...
- 论山寨手机与Android 【15】结束语
去年11月,与人讨论山寨版Android智能手机的前景,最初觉得这个问题很容易回答.但是三言两语之后,不仅听者茫然,而且言者自己也意识到条理紊乱,说服力不强.于是决定写几篇文章,把这个问题展开说说.所 ...
- 迁移 Qt4 至 Qt5 的几个主要环节(数据库插件别拷错了地方)
Qt5推出一段时间了,经过了试用,虽然还存在一些问题,比如Designer 缺少 WebView 和 ActiveQt 的UI工具,此外 WebKit 的 Release 版本似乎和Visual-St ...
- CC++初学者编程教程(10) 搭建Android java C/C++ NDK QTforAndroid 开发环境
1 安装JDK 2 点下一步 3 点下一步 4 开始安装 5 定制路径,点下一步 6 开始安装 7 安装完成, 8 解压缩 9 启动eclipse 10 看到启动画面 11 设置工作文件夹 12 单击 ...
- hive中partition如何使用
1.背景 1.在Hive Select查询中一般会扫描整个表内容,会消耗很多时间做没必要的工作.有时候只需要扫描表中关心的一部分数据,因此建表时引入了partition概念. 2.分区表指的是在创建表 ...
- 略谈cpu架构种类
一直对x86/i386/i686/x86_64这些东西感觉很不清楚,查些资料,解决部分问题,小记一番. Question1:什么是x86? x86或80x86是英特尔Intel首先开发制造的一种微处理 ...
- 自学XSL的几个例子
XSL 指扩展样式表语言(EXtensible Stylesheet Language).XSL用来描述XML文件的格式,类似于我们可以用CSS描述HTML的格式.具体用法请转:http://www. ...
- Linux 常用命令学习
sed 大法: cat file | sed 's/string/replace_str/' file 按大小分割文件 split -b 100m filename 设置vi不自动转换tab: set ...