After using virtualenv for months, I finally got around to putting my main virtualenv into my bash profile. It’s really simple. All I had to do was add the following to ~/.bash_profile:

# python virtualenv
source /Users/ben/virtualenv/pearl/bin/activate

This worked, but there was one thing I wanted to turn off. The activate script that virtualenv creates adds the name of the current virtualenv to the front of the prompt. This is useful when switching between virtualenv directories, but it’s not very useful to me when I’m on the default virtualenv. So I moved my prompt definition to the bottom of the file, so it gets executed after the source command above.

# prompt (moved after virtualenv so it isn't shown)
PS1="\[\e[31;40m\]\@ \[\e[32;40m\]\w \[\e[36;40m\]\$\[\e[0m\] "

By the way, to keep the prompt I use the most often short, I set my own colors. It’s easy for me to tell that it’s my main shell, and since it’s my main shell, I know the username and hostname associated with it.

One thought on “setting up a default virtualenv

Comments are closed.