History across different ipdb sessions?
Is it possible to save history across different ipdb sessions? I would like pull up commands from my previous ipdb debug session that was invoked using ipdb.set_trace().
I have never tried myself. Anyone else ?
Why is this issue closed? History across different sessions is still unavailable.
PR welcome :-)
https://github.com/ipython/ipython/issues/682
Maybe the history support should be implemented in IPython or pdb.
However, seems that using ipdb with IPython 5.0.0 doesn't show the history at all, while using it with previous versions will show the IPython history.
The history for the current session is stored in p.shell.debugger_history.strings, where p is the debugger instance (that is created with _init_pdb()).
However... even if the history can be easily loaded inside _init_pdb(), I didn't find a way to store it in a file because it has to be done after ipdb console exit.
Is there a way to execute a function after ipdb console exit, without changing the user experience?
If for example ipdb.set_trace() is used, the executions breaks in the line that calls it, but there's no way to do something after the end of the debugging session because the scope returns on the main program and not on ipdb code.
@gotcha: sorry for all this mess... I added the Fix tag on the commit message while experimenting and it generated an event for every commit amend.
However, I sent you a PR that enables history for IPython 5.0.0.
The history works by creating a file in the IPython profile directory (usually ~/.ipython/profile-default/) or in user home if the profile isn't available.
When a line is entered, it's appended in the history file (if valid and not already present as last entry in the file). Then, on IPython debugger initialization the file is loaded back in the shell history.
This works only in 5.0.0, that use a dedicated history for the debugger. However, ipdb behavior with previous version of IPython is not changed in this patch.
Is this still being worked on..
Something lik this can possibly be incorporated.. https://wiki.python.org/moin/PdbRcIdea
Isn't this a solution? https://github.com/michelesr/ipdb/commit/2c808b5343deb3482f6cd025ab11d4bf355a6929
So far I received no feedback from @gotcha in #104, and that was opened in 2016 so the code must have changed in the meantime.
I'll be happy to resolve the conflicts if I can get that PR merged.
Support for history is provided by recent IPython : see https://github.com/gotcha/ipdb/issues/236