与Python 2.7的工作这是.pythonrc.py
文件,我建立了我的笔记本电脑运行Debian测试的内容:.pythonrc.py不是在MacOS
import os, readline, rlcompleter, atexit
history_file= os.path.join(os.environ['HOME'], '.python_history')
try:
readline.read_history_file(history_file)
except IOError:
pass
readline.parse_and_bind("tab: complete")
readline.parse_and_bind('"\e[A": history-search-backward')
readline.parse_and_bind('"\e[B": history-search-forward')
readline.parse_and_bind('"C-\e[A": reverse-search-history')
readline.parse_and_bind('"C-\e[B": forward-search-history')
readline.set_history_length(8000)
atexit.register(readline.write_history_file, history_file)
del os, readline, rlcompleter, atexit, history_file, __file__
我有相同的文件的副本到我MacBook上运行MacOS的塞拉利昂,与.profile
文件相结合,在这里附:
HISTCONTROL=ignoreboth
HISTSIZE=2000
HISTFILESIZE=4000
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
bind '"C-\e[A": reverse-search-history'
bind '"C-\e[B": forward-search-history'
alias pythonic='python -i -c "from user import *"'
PYTHONSTARTUP=$HOME/.pythonrc.py
上猛砸自动完成和历史搜索能正常工作,但同样的功能似乎通过pythonic
别名运行的Python当预期到不行。如果可能的话,有人可以向我解释这种行为的原因以及如何解决它?
感谢您的建议,但也出口'PYTHONSTARTUP'环境变量,'pythonic'一直不工作。 – rudicangiotti
尝试'env | grep'PYTHONSTARTUP'检查var是否存在,如果不存在,请检查'.profile'是否被执行。 – georgexsh
'grep'返回变量,所以它被定义。 – rudicangiotti