After some searching and trawling through the IPython documentation and some code, I can't seem to figure out whether it's possible to store the command history (not the output log) to a text file rather than an SQLite database. ipython --help-all
seems to indicate that this option doesn't exist.
This would be very nice for version controlling frequently used commands like in .bash_history.
Edit: Working solution based on @minrk's answer.
In particular, running the command 'history -f FILENAME' from the IPython Notebook interface will replace FILENAME even if it already exists without confirmation. treat the arg as a glob pattern to search for in (full) history. This includes the saved history (almost all commands ever written).
In XWindows, run iPython from the Xfce terminal app. click Terminal in the top menu bar and look for save contents in the dropdown.
History is store on $(ipython locate)/profile_default/history. sqlite by default. You can remove the file, and or do any operation you want on it (secure erase, etc..). It's an sqlite file so you can load it with any sqlite program and do query on it.
If you want some code to be run at the beginning of every IPython session, the easiest way is to add Python (. py) or IPython (. ipy) scripts to your profile_default/startup/ directory. Files here will be executed as soon as the IPython shell is constructed, before any other code or scripts you have specified.
You can export all of your history in IPython to a text file with the %history magic like this:
%history -g -f filename
One way of getting what you want might be to do that export in a git hook. I usually put these "sync an external resource" actions in the post-checkout git hook.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With