##// END OF EJS Templates
Add %alias_magic examples (t -> timeit, whereami -> pwd).
Bradley M. Froehle -
Show More
@@ -59,7 +59,28 b' class BasicMagics(Magics):'
59 )
59 )
60 @line_magic
60 @line_magic
61 def alias_magic(self, line=''):
61 def alias_magic(self, line=''):
62 """Create an alias for an existing line or cell magic."""
62 """Create an alias for an existing line or cell magic.
63
64 Examples
65 --------
66 ::
67 In [1]: %alias_magic t timeit
68
69 In [2]: %t -n1 pass
70 1 loops, best of 3: 954 ns per loop
71
72 In [3]: %%t -n1
73 ...: pass
74 ...:
75 1 loops, best of 3: 954 ns per loop
76
77 In [4]: %alias_magic --cell whereami pwd
78 UsageError: Cell magic function `%%pwd` not found.
79 In [5]: %alias_magic --line whereami pwd
80
81 In [6]: %whereami
82 Out[6]: u'/home/testuser'
83 """
63 args = magic_arguments.parse_argstring(self.alias_magic, line)
84 args = magic_arguments.parse_argstring(self.alias_magic, line)
64 shell = self.shell
85 shell = self.shell
65 escs = ''.join(magic_escapes.values())
86 escs = ''.join(magic_escapes.values())
General Comments 0
You need to be logged in to leave comments. Login now