Auto-rename OS X terminal tab with virtualenv name
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:
#!/bin/bash
# This hook is run after every virtualenv is activated.
# The environment name is passed as argument
# renames the current os x terminal tab title
printf "\e]1;$1\a"
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:
#!/bin/bash
# This hook is run before every virtualenv is deactivated.
# remove virtualenv name from terminal tab name
printf "\e]1;\a"
This works with iTerm2 as well.
Written by Greg Nofi
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#