I often work on multiple Python projects at a time, each with its own virtual environment and terminal tab. I use virtualenvwrapper to manage my virtualenvs.
I like to have each terminal tab named after the project loaded in it, so I changed my preactivate script to look like this:
# This hook is run after every virtualenv is activated.
# The environment name is passed as argument
# renames the current os x terminal tab title
Now, whenever I switch to a virtualenv with the
workon command, my tab is automatically updated.
I added a similar command to the predeactivate command to remove the terminal tab name:
# This hook is run before every virtualenv is deactivated.
# remove virtualenv name from terminal tab name
This works with iTerm2 as well.