Ipython: print the full story (not just the current session)

in ipython , I can use %hist or %history to print recent history, but this only prints the history from the current session.

I would like to print the whole story, as the bash history command does.

What I'm trying to do is get the full story so that I can then search with a regular expression, see which commands are executed after the specified commands, etc.

Speaking of history, is it also possible to print time codes?

BIG NOTE : In bash, I wrote a simple script that prints a story, and I can grep it for keywords. I see the times when certain commands were executed. I can specify -A n or -B n , where n is the number of AFTER or BEFORE lines of this command. This is very convenient, because I can easily find what I did, when and what happened ...

I am looking for something similar for ipython

+103
ipython
Aug 04 '14 at 17:12
source share
3 answers

In ipython type:

 %history -g 

It does not print time codes, but it prints a session / line number.

+124
Aug 14 '15 at 21:55
source share

First use %hist -o -g -f ipython_history.md to output the history (input and output) to a text file. ( http://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-history )

Then you can use the get_session_info function to get the date and time of the session you are interested in. ( Http://ipython.readthedocs.io/en/stable/api/generated/IPython.core.history.html?highlight = hist # IPython.core.history.HistoryAccessor.get_session_info )

 profile_hist=IPython.core.history.HistoryAccessor(profile='default') profile_hist.get_session_info(100) 

It will print something like

 (100, datetime.datetime(2018, 2, 13, 19, 8, 30, 40691), None, None, '') 

This means that session 100 began on February 13, 2018 at 19:08:30.

+16
May 05 '18 at
source share

Here is the Firefox extension found by @kait : SQLite Manager

It has a graphical interface for opening a database file and issuing various sqlite commands from the menu. You get the added bonus of looking at the SQL commands that generate the output. Here is my example for %history ipython %history in ~/.ipython/profile_default/history.sqlite :

enter image description here

And even there is a menu for creating graphs (spread, line, strip, etc.) from your data!

0
Apr 19 '19 at 18:44
source share



All Articles