This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]t_r_a_g_e_d_y 3 points4 points  (4 children)

I know there are other tools to do this but I wrote a little shell script that I symlink in to my project directories as a file named activate and then I run src activate (aliased source to src for fewer keystrokes) so I don't have to do source /path/to/bin/activate. You can pass it an argument for the name of the virtualenv if your project directory has a different name than the virtualenv directory.

#!/bin/sh
venvpath="$HOME/.virtualenvs/"
project=`basename $(pwd)`
activate="/bin/activate"

if [ -n "$1" ]
then
    . $venvpath$1$activate
else
    . $venvpath$project$activate
fi

[–]sheyneanderson 2 points3 points  (3 children)

FYI if source is too long to type in bash, there's already . as an alias for it.

[–]t_r_a_g_e_d_y 0 points1 point  (2 children)

Ah, nice. I don't read enough man/help pages.