ipython:打印完整的历史记录(不仅仅是当前会话) [英] ipython: print complete history (not just current session)
问题描述
在 ipython
中,我可以使用%hist
或%history
打印最近的历史记录,但这仅打印当前会话的历史记录。
in ipython
, I can use %hist
or %history
to print recent history, but this only prints history from current session.
我想打印所有历史记录,类似于bash 历史记录
命令。
I would like to print all history, similar as bash history
command does.
我想要做的是获取完整的历史记录,以便我可以使用正则表达式进行搜索,查看指定命令后遵循的命令,等等
What I am trying to do is to get complete history, so that I can then search with regex, see what commands followed after specified commands, and so on
说到历史,它还可以打印时间码吗?
Speaking of history, can it also print timecodes?
SIDE NOTE :
在bash中,我编写了一个打印历史记录的简单脚本,我可以用它来搜索关键字。我看到执行某些命令的时间。我可以指定 -A n
或 -B n
,其中 n
是一行 AFTER
或 BEFORE
给定的命令。
这非常方便,因为我可以很容易地找到我在做什么,接下来做什么,...
SIDE NOTE:
In bash, I have written a simple script which prints history and I can grep it for keywords. I see times when certain commands were executed. I can specify -A n
or -B n
, where n
is a number of lines AFTER
or BEFORE
a given command.
This is very handy, because I can easily find what I did when, and what followed, ...
我正在为<$寻找类似的东西c $ c> ipython
推荐答案
在 ipython
输入:
%history -g
它不打印时间码,但会打印会话/行号。
It does not print time codes but it does print session/line number.
这篇关于ipython:打印完整的历史记录(不仅仅是当前会话)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!