Created
February 26, 2016 05:27
-
-
Save cdpath/2b088292cf90c88b1d13 to your computer and use it in GitHub Desktop.
mv virtualenv properly
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
#!/usr/bin/env bash | |
# Usage: mvvenv.sh oldpath newpath | |
oldpath=$(realpath $1) | |
newpath=$(realpath $2) | |
# binpath=$(find oldpath -type d -name bin) | |
# tmp=${binpath%/*} | |
# venvname=${tmp##*/} | |
venvname=${VIRTUAL_ENV##*/} | |
oldvenvpath=$oldpath/$venvname | |
newvenvpath=$newpath/$venvname | |
_oldvenvpath=$(echo $oldvenvpath | sed 's/\//\\\//g') | |
_newvenvpath=$(echo $newvenvpath | sed 's/\//\\\//g') | |
deactivate | |
sed -i -e "/VIRTUAL_ENV/s/$_oldvenvpath/$_newvenvpath/" $oldvenvpath/bin/activate | |
sed -i -e "s/$_oldvenvpath\/bin\/python/$_newvenvpath\/bin\/python/" $oldvenvpath/bin/pip | |
# sed -i -e "1c\$_newvenvpath/bin/python" $oldvenvpath/bin/pip | |
mv oldpath newpath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment