'Save history and add a %plot magic.'

def _handle_input_request(self, msg):

    if self._hidden:
        raise RuntimeError('Request    for    raw    input    during    hidden    execution.')
    self.kernel_client.iopub_channel.flush()
    def callback(line):
        self._control.history.append(line)
        if line.startswith('%plot    '):
            line = line.split()[(-1)]
            code = ("__spy_code__    =    get_ipython().run_cell('%s')" % line)
            self.kernel_client.input(code)
        else:
            self.kernel_client.input(line)
    if self._reading:
        self._reading = False
    self._readline(msg['content']['prompt'], callback=callback, password=msg['content']['password'])
