Virtualenvwrapper makes working with Virtualenv a real pleasure. But for me it wasn’t enough, just because I’m that lazy.
My idea was to type one command and get right into the repository directory. I’d like it to happen within a subshell so I would not need to deactivate the virtual environment. All I would need to do is press CTRL+D to exit the subshell and close my sandbox.
To accomplish it, I managed to write this scratch shell script function:
function work () {
typeset env_name="$1"
if [ "$env_name" = "" ]
then
virtualenvwrapper_show_workon_options
return 1
fi
virtualenvwrapper_verify_workon_environment $env_name || return 1
echo "source ~/.profile
workon $env_name
cdvirtualenv
cd src" > ~/.virtualenvrc
bash --rcfile ~/.virtualenvrc
}
Having virtualenv and virtualenvwrapper installed on your system, just append this function to the end of your .profile or .bash. And type: work envname.
[]‘s!







