您的位置:首页 > 运维架构 > Linux

Linux设置python自动tab自动补全

2015-04-02 11:41 330 查看
1.安装readline模块。

sudo apt-get install readline*


2.创建文件~/.pythonstartup,内容如下

# 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.在~/.bash_profile中添加环境变量

export PYTHONSTARTUP=~/.pythonstartup
4.刷新配置

source .bash_profile
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: