Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7907063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:15:09+00:00 2026-06-03T11:15:09+00:00

How do you change the default Virtualenvwrapper prompt? By default, working on a particular

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T11:15:11+00:00Added an answer on June 3, 2026 at 11:15 am

    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:

    PROMPT_COLOR1='0;36m'
    PROMPT_COLOR2='1;34m'
    PS1='\n\[\033[$PROMPT_COLOR1\](\t)\[\033[$PROMPT_COLOR2\] \u @ \w \n\[\033[$PROMPT_COLOR1\]$ \[\033[0;39m\]'
    

    Which yields a command prompt along the lines of:

    < old_line >
    
    (19:11:05) kevin @ ~/research 
    $ 
    

    Switching into a new virtual environment with “workon < name_of_env >” turned the command prompt to something like:

    < old_line >
    (< name_of_env >)
    (19:11:05) kevin @ ~/research 
    $ 
    

    Which was more cluttered than I wanted and the wrong color to boot. I was hoping for something like:

    < old_line >
    
    (< name_of_env >) (19:11:05) kevin @ ~/research 
    $ 
    

    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:

    # color virtualenv name properly and put it after the \n if there is one at the start of the prompt
    if [ ${_OLD_VIRTUAL_PS1:0:2} == '\n' ]; then
        PS1="\n\[\033[$PROMPT_COLOR1\](`basename \"$VIRTUAL_ENV\"`) ${_OLD_VIRTUAL_PS1:2:${#_OLD_VIRTUAL_PS1}}"
    else
        PS1="\[\033[$PROMPT_COLOR1\](`basename \"$VIRTUAL_ENV\"`) $_OLD_VIRTUAL_PS1 "
    fi
    

    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).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know how to change default Azure SDK local deploy directory?
Is it possible to change default EventKitUI style? I'd like to have different background
I need to change default machine name on TFS adminitration Console. i find some
I am writing a small editor. I would like to change default behaviour of
I am currently working on an iphone app where I want to change default
Working with asp.net, and I am trying to find a way to change default
How to change default emacs mark-paragraph function behaviour to not select first empty line?
Is there any way to change default font of controls in winforms. I must
I want to change the default arguments passed to a Ruby function. For example,
How do I change the default refactoring keyboard mappings in Delphi 2006?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.