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