Skip to content

Instantly share code, notes, and snippets.

@az7arul
Last active December 14, 2015 21:09
Show Gist options
  • Save az7arul/5149300 to your computer and use it in GitHub Desktop.
Save az7arul/5149300 to your computer and use it in GitHub Desktop.
Creating alias for activating python virtual environments. Add this line to your ~/.bash_profile file.
for i in `ls ~/python-env`;do alias act_${i}="source ~/python-env/${i}/bin/activate";done
@az7arul
Copy link
Author

az7arul commented Mar 13, 2013

All your virtual environment should be in ~/python-env directory. This script will create alias for activating each of the virtual environments so that you do not have to type . ~/python-env/[environmentName]/bin/activate or source ~/pyhon-env/[envName]/bin/activate

Each time your shell starts it will create aliases for all the venv's in the ~/python-env directory.

Usage: act_[environmentName] #=> act_cms

P.S. You will need to run ". ~/bash_profile" to get the aliases ready without restarting the shell for the first time

Limitation: virtual env's cant have spaces in their name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment