操作步骤:
一:安装readline
yum -y install readline
二:vim ~/.pythonstartup.py
# 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
三:写入环境变量里
vim ~/.bash_profile
export PYTHONSTARTUP=~/.pythonstartup.py
四:载入.bash_profile
source ~/.bash_profile
转载于:https://blog.51cto.com/more3/1700230