I assume you want to do this from an already running IPython session. There is probably something a lot , but all that I could think of now:
get_ipython().shell.run_cell(open('path/to/commands').read())
Another crazy idea is to run IPython as EDITOR=cat ipython . Now you can load commands from a file with:
%edit -r path/to/commands
Probably for your use case, there probably should be real magic.
Or you can do the same non-interactively (add -i to interactive mode):
ipython -c 'get_ipython().shell.run_cell(open("path/to/commands").read())'
source share