简体   繁体   English

增加IPython历史记录长度

[英]Increase IPython history length

I have tried increasing IPython history length following this post : Control ipython history length by changing c.TerminalInteractiveShell.history_length in ~/.ipython/profile_default/ipython_config.py . :我曾尝试下面这个帖子增加IPython的历史长度IPython的历史长度控制 ,通过改变c.TerminalInteractiveShell.history_length~/.ipython/profile_default/ipython_config.py

The config file seems to be executed at startup (if I put print('test-startup') in the file, it's printed when I start IPython) 配置文件似乎是在启动时执行的(如果我在文件中放置print('test-startup') ,它在我启动IPython时打印)

But it does not seems to have any influence, is there anyway to check the history size from inside the ipython (kinda like how you can do echo $HISTSIZE; echo $HISTFILESIZE in bash ?) 但它似乎没有任何影响,无论如何都要检查ipython中的历史大小(有点像你怎么做echo $HISTSIZE; echo $HISTFILESIZE在bash中echo $HISTSIZE; echo $HISTFILESIZE ?)

Using 运用

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

In attempting to answer the question myself, I stumbled upon this question as well this question and found snippets that really didn't provide the OP with the complete, TL;DR information. 在试图回答这个问题我自己,我就这个问题绊倒,以及这个问题 ,发现片段真的没有提供OP与完整,TL; DR信息。

So for my own records and to make the answers on SO here more complete, I provided a quick implementation and check to "Increase iPython History Length." 因此,对于我自己的记录并在SO上做出更完整的答案,我提供了一个快速实现并检查“增加iPython历史记录长度”。

Generate the iPython config file 生成iPython配置文件

$ ipython profile create <profile name>

I just wanted this for my default config, so I ran: 我只想把它作为我的默认配置,所以我跑了:

$ ipython profile create

Modify the ipython_config.py File 修改ipython_config.py文件

Running the above command creates an ipython_config.py file, which (on *.nix is stored at ~/.ipython/profile_default/ipython_config.py 运行上面的命令会创建一个ipython_config.py文件,该文件位于~/.ipython/profile_default/ipython_config.py上。 *.nix ~/.ipython/profile_default/ipython_config.py

These are the two lines that I uncommented and changed the values for: 这些是我取消注释并更改以下值的两行:

在此输入图像描述

Check to Ensure the Implementation Worked 检查以确保实施工作

Fire up iPython and run the commands found in the accepted answer above to ensure our new history_length = 100,000 . 启动iPython并运行上面接受的答案中找到的命令,以确保我们的新history_length = 100,000

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM