How do you change the default Virtualenvwrapper prompt? By default, working on a particular virtual environment with a command like workon <_name_of_env_> prepends the name of the virtualenv to your prompt. This may work poorly if you’re not using a default command prompt.
How do you change the default Virtualenvwrapper prompt? By default, working on a particular
Share
By default, when you switch into a virtualenv with the command “workon < name_of_env >”, virtualenvwrapper prepends a string along the lines of “(< name_of_env >) ” to your command prompt. The problem is that I set my Bash prompt with the lines:
Which yields a command prompt along the lines of:
Switching into a new virtual environment with “workon < name_of_env >” turned the command prompt to something like:
Which was more cluttered than I wanted and the wrong color to boot. I was hoping for something like:
Ian Bicking has previously pointed out that virtualenvwrapper’s hooks were the solution but I figured I’d post my actual code to maybe save someone else a minute down the line.
I simply edited the file $WORKON_HOME/postactivate to include these lines:
and voila! The color and location are correct and it even works when you switch directly from one virtual environment to another (which I hadn’t expected).