Displaying virtualenv Displaying virtualenv shell shell

Displaying virtualenv


So I figured out how to do this. In the activate script the $PS1 is redefined to prepend the name of the env, in this case (foo-env). In order to prepend it with whatever you want you have to go into the activate script that you run to activate the virtualenv ([yourenv]/bin/activate]). There you change the line that that defines the new $PS1 from PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1" to be whatever you want, here PS1="(F)$PS1".


You need to set the $PS1 environmental variable to change your prompt.

Take a look in the virtualenv config files for the setting.

See http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html for how to set it as you'd like. It sounds like you just need to replace the string foo-env with F.


As an alternative, use pew (Python Env Wrapper). Then your PS1 won't get mangled when you use a virtualenv, and you can set your PS1 in your .bashrc (etc.) as usual, displaying the $VIRTUAL_ENV if it's set. The relevant piece of mine looks like this:

# python virtual env, however it comes to beif [ -z ${VIRTUAL_ENV+x} ]thenVENV_NOTICE=""elseVENV_NOTICE=" (py: $(basename "$VIRTUAL_ENV"))"fiPS1='whatever $VENV_NOTICE else'