# venter Virtualenv venter utils # # Written in 2011 by Christopher Allan Webber # # To the extent possible under law, the author(s) have dedicated all # copyright and related and neighboring rights to this software to the # public domain worldwide. This software is distributed without any # warranty. # # You should have received a copy of the CC0 Public Domain Dedication # along with this software. If not, see # . ## Instructions # Put this in your .bashrc # source ~/.bashrc or start a new terminal # make virtualenvs in ~/env/ # # now this should work: # $ venter myvirtualenvname # even has tab completion on all virtualenvs in ~/env/x # To leave the virtualenv, just type "deactivate" function _venter_complete { local cur prev opts COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" opts="`ls ~/env/`" COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) } complete -F _venter_complete venter function venter { if [ "$1" = "" ] ; then ls ~/env/ elif [ ! -e "$HOME/env/$1" ] ; then echo "Environment $1 does not exist" else cd ~/env/$1 source ~/env/$1/bin/activate fi } function nocd_venter { if [ "$1" = "" ] ; then ls ~/env/ elif [ ! -e "$HOME/env/$1" ] ; then echo "Environment $1 does not exist" else source ~/env/$1/bin/activate fi }