Show More
@@ -28,7 +28,7 b' from IPython.core import oinspect' | |||
|
28 | 28 | from IPython.core import page |
|
29 | 29 | from IPython.core.error import UsageError, StdinNotImplementedError |
|
30 | 30 | from IPython.core.magic import ( |
|
31 | Magics, compress_dhist, magics_class, line_magic, cell_magic | |
|
31 | Magics, compress_dhist, magics_class, line_magic, cell_magic, line_cell_magic | |
|
32 | 32 | ) |
|
33 | 33 | from IPython.testing.skipdoctest import skip_doctest |
|
34 | 34 | from IPython.utils.io import file_read, nlprint |
@@ -548,8 +548,8 b' class OSMagics(Magics):' | |||
|
548 | 548 | else: |
|
549 | 549 | return out |
|
550 | 550 | |
|
551 | @line_magic | |
|
552 |
def sx(self, |
|
|
551 | @line_cell_magic | |
|
552 | def sx(self, line='', cell=None): | |
|
553 | 553 | """Shell execute - run shell command and capture output (!! is short-hand). |
|
554 | 554 | |
|
555 | 555 | %sx command |
@@ -590,9 +590,20 b' class OSMagics(Magics):' | |||
|
590 | 590 | This is very useful when trying to use such lists as arguments to |
|
591 | 591 | system commands.""" |
|
592 | 592 | |
|
593 | if parameter_s: | |
|
594 | return self.shell.getoutput(parameter_s) | |
|
593 | if cell is None: | |
|
594 | # line magic | |
|
595 | return self.shell.getoutput(line) | |
|
596 | else: | |
|
597 | opts,args = self.parse_options(line, '', 'out=') | |
|
598 | output = self.shell.getoutput(cell) | |
|
599 | out_name = opts.get('out', opts.get('o')) | |
|
600 | if out_name: | |
|
601 | self.shell.user_ns[out_name] = output | |
|
602 | else: | |
|
603 | return output | |
|
595 | 604 | |
|
605 | system = line_cell_magic('system')(sx) | |
|
606 | bang = cell_magic('!')(sx) | |
|
596 | 607 | |
|
597 | 608 | @line_magic |
|
598 | 609 | def bookmark(self, parameter_s=''): |
General Comments 0
You need to be logged in to leave comments.
Login now