Last active
January 22, 2021 12:42
-
-
Save jaredyam/601f3ae66d9994766c8f2ba4741e4769 to your computer and use it in GitHub Desktop.
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
# Rename conda env and redirect bash shebang to new env. | |
# | |
# Reference | |
# --------- | |
# https://stackoverflow.com/a/62853056/11533669 | |
# rename | |
# The two variables below should be something like path str or filename if the file presents in current directory | |
mv $OLD_ENV_NAME $NEW_ENV_NAME | |
# modify bash shebang | |
## GNU/Linux | |
sed -i "s:$(head -1 $NEW_ENV_NAME/bin/pip):#\!$PWD/$NEW_ENV_NAME/bin/python:" $NEW_ENV_NAME/bin/* | |
## FreeBSD/MacOS | |
gsed -i "s:$(head -1 $NEW_ENV_NAME/bin/pip):#\!$PWD/$NEW_ENV_NAME/bin/python:" $NEW_ENV_NAME/bin/* | |
# or wrap up to a function (MacOS case) | |
# $1: old env name; $2: new env name | |
function rename-env() { | |
mv $1 $2 | |
gsed -i "s:$(head -1 $2/bin/pip):#\!$PWD/$2/bin/python:" $2/bin/* | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment