In IPython console you can use %logstart logfile to save all history commands
and the future commands into
Add -o option (%logstart -o logfile)
if you want to save the output along with the inputs.
However, note that the output of print() will NOT be saved to logfile.
When logfile parameter omitted, a file ipython_log.py is created.
See details with ?%logstart.
Stop saving with %logstop.