Last active
August 29, 2015 14:10
-
-
Save phpdude/b2ea553c356097988e55 to your computer and use it in GitHub Desktop.
Auto activate virtualenv & activate_env alias
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias activate_env='ENVDIR=""; for d in *; do if [ -f $d/bin/activate ]; then ENVDIR="$d/bin/activate"; fi; done; if [ "$ENVDIR" ]; then source $ENVDIR; else echo Virtualenv dir not found; fi' | |
ENVDIR=""; for d in *; do if [ -f $d/bin/activate ]; then ENVDIR="$d/bin/activate"; fi; done; if [ "$ENVDIR" ]; then source $ENVDIR; fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@dude /# activate_env | |
Virtualenv dir not found | |
@dude /# cd /WWW/Python/My/AskGuru | |
@dude /WWW/Python/My/AskGuru# activate_env | |
(env)@dude /WWW/Python/My/AskGuru# | |
(env)@dude /Users/WWW/Python/My/AskGuru# echo $ENVDIR | |
env/bin/activate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple drop this code to your ~/.profile file and on console tab initialization virtualenv will be activated automatically. Or you can use shell alias
activate_env
manually.On bash intialization helper doesn't show anything if virtualenv not found, but alias will show error message if virtualenv not found.
Also you have $ENVDIR env variable as bonus :)