How do I rename a magic function in IPython?

I would like to rename %paste

to something like %pp

so that it takes up fewer keys. I've worked out a way to do this, but it seems complicated. Is there a better way?

def foo(self, bar):
    get_ipython().magic("paste")

get_ipython().define_magic('pp', foo)

      

+3


source to share


2 answers


From IPython 0.13 there is a new magic function %alias_magic

that you would use like:



%alias_magic pp paste

      

+3


source


use %alias

magic for this (if you want it to be permanent use %store

):



In [8]: %alias??

"""Define an alias for a system command.

   '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
   ... 

      

+3


source







All Articles