'Get, set, or list environment variables.
Usage:\
%env: lists all environment variables/values
%env var: get value for var
%env var val: set value for var
%env var=val: set value for var
%env var=$val: set value for var, using python expansion if possible'

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

    if parameter_s.strip():
        split = ('=' if ('=' in parameter_s) else '    ')
        bits = parameter_s.split(split)
        if (len(bits) == 1):
            key = parameter_s.strip()
            if (key in os.environ):
                return os.environ[key]
            else:
                err = 'Environment    does    not    have    key:    {0}'.format(key)
                raise UsageError(err)
        if (len(bits) > 1):
            return self.set_env(parameter_s)
    return dict(os.environ)
