I wonder how conda puts the env name in front of the username in the command prompt when I activate the env. In the image below, I activated an env named tf, and the command prompt changed. Can I achieve this by setting some environment variables?

I wonder how conda puts the env name in front of the username in the command prompt when I activate the env. In the image below, I activated an env named tf, and the command prompt changed. Can I achieve this by setting some environment variables?

You can achieve this by setting the PS1 environment variable:
export PS1="(tf) $PS1"
Here you can find some more information about the customization of the prompt in general.