'Print the history for the last 10 Commands on the session on each log in to the shell

I'm trying to print out the last 10 commands on the last session on each login, in the bash.bashrc. I wrote this:

echo "$(history 10)"

But it didn't print anything.



Solution 1:[1]

Solved the issue. Didn't realise that I could just store this custom info in the token payload (upon creation of the token) and then bring it down from the header. There is a bit of code duplication here, but it's a good enough solution:

def get_retailer_id(request: Request):

    token = request.headers.get('Authorization')
    token = token.replace("Bearer ", "")
    credentials_exception = HTTPException(
        status_code=status.HTTP_401_UNAUTHORIZED,
        detail="Token is invalid or payload is corrupt",
        headers={"WWW-Authenticate": "Bearer"},
    )
    try:
        payload = jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM])
        retailer_id: str = payload.get("retailer_id")
        return str(retailer_id)

    except Exception:
        raise credentials_exception

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1