'Set shell current working directory.'

def set_cwd(self, dirname):

    if (os.name == 'nt'):
        dirname = dirname.replace(u'\\', u'\\\\')
    code = u"get_ipython().kernel.set_cwd(u'{}')".format(dirname)
    if self._reading:
        self.kernel_client.input((u'!' + code))
    else:
        self.silent_execute(code)
    self._cwd = dirname
