Python Zone is brought to you in partnership with:

I work at Tangent Labs, a digital agency, writing applications in python and django. I spend most of my free time hacking. I run commandlinefu.com and am the author of the e-commerce framework django-oscar amongst other things. I used to be a mathematician; I have a PhD in Mathematics from the University of Nottingham and an associated interest in cryptic crosswords, chess and playing devil's advocate. David is a DZone MVB and is not an employee of DZone and has posted 27 posts at DZone. You can read more from them at their website. View Full User Profile

Auto-Setting Terminal Titles for Python Virtual Environments

02.19.2012
| 3404 views |
  • submit to reddit

Problem

You're a Python hacker using virtualenv and virtualenvwrapper on a range of projects. After a few hours in the office and much context switching, your terminal emulator is bursting with open tabs with the unhelpful title 'bash' and it's difficult to remember which tab is for which project. This is making you unhappy.

Solution

Use your postactivate script (which will be somewhere like ~/.virtualenvs/yourproject/bin/postactivate) to set the terminal title when you activate a virtual environment. Add something similar to the following to your postactivate script:

TITLE="codeinthehole.com"
echo -ne "\033]0;$TITLE\007"

Then whenever you start working on a project (using workon), your tab title will be labelled correctly.



Source: http://codeinthehole.com/writing/auto-setting-terminal-titles-for-python-virtual-environments/

 

Published at DZone with permission of David Winterbottom, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)