Virtualenv: Option to disable prompt update in activate script

Created on 14 Mar 2011  ·  4Comments  ·  Source: pypa/virtualenv

I like the idea of updating the bash prompt to include the name of the current environment when you run an activate script. But I've got my own nice, colorized prompt, so I'd like to customize how the virtualenv environment name gets added to the prompt.

It seems like the easiest solution would be to add a new environment variable — such as VIRTUAL_ENV_DISABLE_PROMPT — and not do the PS2 magic when this variable is set. That way, my existing prompt definition can check for the existence of VIRTUAL_ENV, and include that as necessary.


enhancement

Most helpful comment

Joseph: Looks like it. I spent the time to grok the source and it's in there:

if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then

So, it will only muck around with your $PS1 if $VIRTUAL_ENV_DISABLE_PROMPT is
not set (or if it is set to an empty string). Thusly, export
VIRTUAL_ENV_DISABLE_PROMPT=1 should do the trick.


Original Comment By: Anonymous

All 4 comments

I created a patch that implements this:

https://bitbucket.org/dcreager/virtualenv/changeset/bcc84d4f18f9/


Original Comment By: Douglas Creager
  • Changed status from new to resolved.

Original Comment By: Jannis Leidel

If this issue was resolved, how does one get this functionality in virtualenv?
Using VIRTUAL_ENV_DISABLE_PROMPT ?


Original Comment By: Joseph Turian

Joseph: Looks like it. I spent the time to grok the source and it's in there:

if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then

So, it will only muck around with your $PS1 if $VIRTUAL_ENV_DISABLE_PROMPT is
not set (or if it is set to an empty string). Thusly, export
VIRTUAL_ENV_DISABLE_PROMPT=1 should do the trick.


Original Comment By: Anonymous
Was this page helpful?
0 / 5 - 0 ratings