1.新建如下脚本:
# cat ~/.pythonstartup
#!/usr/bin/env python
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'], '.pythonstartup')
try:
readline.read_history_file(histfile)
except IOError:
pass
atexit.register(readline.write_history_file, histfile)
del os, histfile, readline, rlcompleter
2.配置环境变量
echo 'export PYTHONSTARTUP=/root/.pythonstartup'>> /etc/profile
3.重新登陆shell,输入python命令进入交互模式,就可以用Tab键进行补全。
本文由 Mr Gu 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: Mar 2, 2018 at 03:21 pm