在用户目录下创建.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
输入
export PYTHONSTARTUP=~/.pythonstartup
编辑用户目录下的
.bash_profile,最后加入下列命令
export PYTHONSTARTUP=~/.pythonstartup
时间: 2024-12-24 13:56:27