Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Auto-Setting Terminal Titles for Python Virtual Environments

DZone's Guide to

Auto-Setting Terminal Titles for Python Virtual Environments

· Cloud Zone
Free Resource

Are you joining the containers revolution? Start leveraging container management using Platform9's ultimate guide to Kubernetes deployment.

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/

 

Using Containers? Read our Kubernetes Comparison eBook to learn the positives and negatives of Kubernetes, Mesos, Docker Swarm and EC2 Container Services.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}