def compress_user(path: str, tilde_expand: bool, tilde_val: str) ->str:
    """Does the opposite of expand_user, with its outputs.
    """
    if tilde_expand:
        return path.replace(tilde_val, '~')
    else:
        return path
