#!/usr/bin/python
# -*- coding: UTF-8 -*-
import readline
import rlcompleter
import atexit
import os
# tab autocomplete
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
完成之后,我们把它保存为.pythonstartup.py,存放在自己的目录下(譬如/home/dir),再将PYTHONSTARTUP变量指向刚才放的地址,就可以了。最省事的办法是在bashrc中添加这样一行
export PYTHONSTARTUP=/home/dir/.pythonstartup.py
lyjfriends 于 2016-04-09 23:49:02发表:
非常好,学习了!