ipython 的历史文件在哪里

Where is the history file for ipython

我无法确定 ipython 存储其历史记录的位置。

一个。没有~/.python历史:

12:49:00/dashboards $ll ~/.py*
ls: /Users/steve/.py*: No such file or directory

b。 python 启动文件没有什么特别之处:

12:49:07/dashboards $echo $PYTHONSTARTUP
/shared/.pythonstartup
12:49:43/dashboards $cat /shared/.pythonstartup
import rlcompleter
import readline

readline.parse_and_bind("tab: complete")

c。但是:当我启动它时,ipython 中确实有大量可用的历史记录。

那么历史存储在哪里?

UPDATE @Stefano 的回答引导了正确的方式:这是实际路径

13:30:05/shared $ll ~/.ipython/profile_default/history.sqlite
-rw-r--r--  1 steve  staff  372736 Jun  3 12:48 /Users/steve/.ipython/profile_default/history.sqlite

IPython 历史记录存储在配置文件目录中的 SQLite 数据库中。默认:

~/.ipython/profile_default/history.sqlite

旧版本 (1.x) 将配置文件数据存储在 ~/.config/ipython 中,至少在符合 XDG basedir specs 的平台上(即大多数 Linux 发行版)。

无论如何,您可以通过以下方式找到配置文件目录:

$ ipython locate profile default

请注意,历史数据库在 IPython 和 IPython3 之间共享,如果两者都安装的话。

如果您希望您的 IPython 历史记录为纯文本文件,您可以自行导出。

%history -g -f filename