in your IPython
session, get_ipython
is a function you can call to customize and configure your shell experience.
IPython
input transformation docs have some examples for customization. in retrospect, this approach might have drawbacks if the magic calls IPython
run cell machinery.