Last active
November 27, 2016 17:33
-
-
Save nrh/1041ed4ed5ec49bf788029d7b2ce6f48 to your computer and use it in GitHub Desktop.
bash function for python virtualenv thingies.
This file contains 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
function venv-activate { | |
if [ ! -z "$1" ]; then | |
. $PWD/$1/bin/activate | |
else | |
_matches=($(compgen -G "*/bin/activate") $(compgen -G ".??*/bin/activate")) | |
if [ ${#_matches[@]} -eq 0 ]; then | |
echo "Environment not found." | |
elif [ ${#_matches[@]} -eq 1 ]; then | |
_env=${_matches[0]} | |
echo "Found $_env" | |
. $PWD/$_env | |
elif [ ${#_matches[@]} -gt 1 ]; then | |
echo "Multiple matches:" | |
for i in ${_matches[@]}; do | |
echo " $i" | |
done | |
fi | |
fi | |
} | |
alias venv-deactivate=deactivate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment