IPython stores the history in a SQLite database located at ~/.ipython/profile_default/history.sqlite . This can be exported into a file by running
%history -g -f filename
When using Windows 10 Enterprise + git bash 2.22.0 + ipython 7.16.1
Examples of valid filenames
Examples of invalid filenames
Ref:-
See https://github.com/ipython/ipython/blob/master/IPython/terminal/prompts.py → Prompts class → in_prompt_tokens(), continuation_prompt_tokens(), rewrite_prompt_tokens(), out_prompt_tokens()