'Manage IPython\'s bookmark system.
%bookmark <name>       - set bookmark to current dir
%bookmark <name> <dir> - set bookmark to <dir>
%bookmark -l           - list all bookmarks
%bookmark -d <name>    - remove bookmark
%bookmark -r           - remove all bookmarks
You can later on access a bookmarked folder with::
%cd -b <name>
or simply \'%cd <name>\' if there is no directory called <name> AND
there is such a bookmark defined.
Your bookmarks persist through IPython sessions, but they are
associated with each profile.'

@line_magic
def bookmark(self, parameter_s=''):

    (opts, args) = self.parse_options(parameter_s, 'drl', mode='list')
    if (len(args) > 2):
        raise UsageError('%bookmark:    too    many    arguments')
    bkms = self.shell.db.get('bookmarks', {})
    if ('d' in opts):
        try:
            todel = args[0]
        except IndexError:
            raise UsageError('%bookmark    -d:    must    provide    a    bookmark    to    delete')
        else:
            try:
                del bkms[todel]
            except KeyError:
                raise UsageError(("%%bookmark    -d:    Can't    delete    bookmark    '%s'" % todel))
    elif ('r' in opts):
        bkms = {}
    elif ('l' in opts):
        bks = sorted(bkms)
        if bks:
            size = max(map(len, bks))
        else:
            size = 0
        fmt = (('%-' + str(size)) + 's    ->    %s')
        print 'Current    bookmarks:'
        for bk in bks:
            print (fmt % (bk, bkms[bk]))
    elif (not args):
        raise UsageError('%bookmark:    You    must    specify    the    bookmark    name')
    elif (len(args) == 1):
        bkms[args[0]] = os.getcwd()
    elif (len(args) == 2):
        bkms[args[0]] = args[1]
    self.shell.db['bookmarks'] = bkms
