%history
In an ipython REPL the %history magic function can be used to show command history and save it to a file.
%history - prints the history
%history -f <file> - dumps the history to <file>
%history -f <file>
<file>