增加IPython历史长度

增加IPython历史长度,python,ipython,input-history,Python,Ipython,Input History,我曾尝试在以下帖子中增加IPython的历史长度: 通过在~/.ipython/profile\u default/ipython\u config.py中更改c.TerminalInteractiveShell.history\u length 配置文件似乎在启动时执行(如果我在文件中放入print('test-startup'),则在启动IPython时打印) 但它似乎没有任何影响,是否可以从ipython内部检查历史记录大小(有点像如何在bash中执行echo$HISTSIZE;echo$

我曾尝试在以下帖子中增加IPython的历史长度: 通过在
~/.ipython/profile\u default/ipython\u config.py
中更改
c.TerminalInteractiveShell.history\u length

配置文件似乎在启动时执行(如果我在文件中放入
print('test-startup')
,则在启动IPython时打印)

但它似乎没有任何影响,是否可以从ipython内部检查历史记录大小(有点像如何在bash中执行
echo$HISTSIZE;echo$HISTFILESIZE

In[3]: %config TerminalInteractiveShell.history_length
Out[3]: 10000

在试图自己回答这个问题时,我偶然发现了这个问题,并发现一些片段并没有为OP提供完整的TL;博士信息

因此,为了我自己的记录,并使这里的答案更加完整,我提供了一个快速实现和检查,以“增加iPython历史长度”

生成
iPython
config文件 修改
ipython_config.py
文件 运行上述命令将创建一个
ipython\u config.py
文件,该文件(on
*.nix
存储在
~/.ipython/profile\u default/ipython\u config.py

以下是我取消注释并更改其值的两行:

检查以确保实施有效 启动iPython并运行上面已接受答案中的命令,以确保新的
历史记录长度=100000

benjamingross (develop*)$ ipython
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:14:23)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.3.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: %config TerminalInteractiveShell.history_length
Out[1]: 100000

谢谢你非常详细的回答!:)
$ ipython profile create
benjamingross (develop*)$ ipython
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:14:23)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.3.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: %config TerminalInteractiveShell.history_length
Out[1]: 100000