unbtun python tab补全
2015-11-30 14:11
591 查看
在使用python的时候有时候总是忘记很多代码,这个是作为程序袁最头疼的事情,本人也是刚刚接触python,这几天也是用到这块,所以记录下来,已被需要时能够找到。
我的系统是:
我的系统是:
w@w:~$ uname -a Linux w 4.2.0-16-generic #19-Ubuntu SMP Thu Oct 8 15:35:06 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux先看看自己的python安装路径,如果不知道的话可以根据下面的方法查看以下:
w@w:~$ python Python 2.7.10 (default, Oct 14 2015, 16:09:02) [GCC 5.2.1 20151010] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/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/PILcompat', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client']既然找到了python的安装路径,把下面的代码传进去
#!/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所传路径以及文件名称可以随意,但是在调用的时候要一致。但是文件必须传到python路径下:
w@w:/usr/lib/python2.7/dist-packages$ vi tab.py我把文件传到/usr/lib/python2.7/dist-packages目录下,并且用tab.py命名。
#!/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
w@w:~$ vi .bashrc #for python export PYTHONSTARTUP=/usr/lib/python2.7/dist-packages/tab.py #上面的路径和文件名必须和上面的保持一致。 w@w:~$ source .bashrc #启用上面的环境
相关文章推荐
- Linux socket 初步
- Python动态类型的学习---引用的理解
- Python3写爬虫(四)多线程实现数据爬取
- 垃圾邮件过滤器 python简单实现
- linux lsof详解
- linux 文件权限
- Linux 执行数学运算
- 下载并遍历 names.txt 文件,输出长度最长的回文人名。
- 10 篇对初学者和专家都有用的 Linux 命令教程
- Linux 与 Windows 对UNICODE 的处理方式
- Ubuntu12.04下QQ完美走起啊!走起啊!有木有啊!
- 解決Linux下Android开发真机调试设备不被识别问题
- 运维入门
- 运维提升
- Linux 自检和 SystemTap
- install and upgrade scrapy
- Scrapy的架构介绍