Hey everyone! I'm using a bash terminal and I've figured out how to change the terminal color when I open an SSH session by checking if the variable "$SSH_CONNECTION" is set. However, I want to achieve a similar effect when I activate a virtual environment. Unfortunately, when I check "$VIRTUAL_ENV", it comes out as null. Does anyone know how to change the terminal color based on virtual environment activation?
1 Answer
It looks like you're using "$VIRTUAL_ENV" in your .bashrc, which only runs when the shell starts, so it doesn't trigger on virtual environment activation. Instead, you might want to add your color change logic directly in the activation script of your virtual environment. You can modify the "activate" script located in "venvname/bin/" to change your prompt color whenever you source it. Just a thought!
That makes sense! I should have checked there. I'll try editing the "activate" script to see if that works. Thanks!