r"""
    Replaces home directory with '~'

def unexpanduser(path):
    r"""
    Replaces home directory with '~'
    """
    homedir = expanduser('~')
    if path.startswith(homedir):
        path = '~' + path[len(homedir):]
    return path