Created
June 4, 2018 04:53
-
-
Save aweimeow/866e2298799ac8992c0b965deead4151 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
#!/usr/bin/env bash | |
set -e | |
program="${0##*/}" | |
localbin="$HOME/.local/bin" | |
export PYENV_ROOT="$HOME/.pyenv" | |
if [[ "$1" = "change" ]]; then | |
/usr/local/Cellar/pyenv/1.2.4/libexec/pyenv global $2; | |
if [[ "$?" -ne "0" ]]; then | |
echo "Assigned version not install yet in Pyenv."; | |
exit; | |
fi | |
cwd=$(pwd) | |
directory="$HOME/.pipenv/$2"; | |
if [[ ! -d $directory ]]; then | |
cd $HOME/.pipenv; mkdir $2 && cd $2; | |
pipenv --python $2; | |
fi | |
cd $HOME/.pipenv/$2; | |
for file in "python" "pip"; do | |
rm $localbin/$file; | |
ln -s $(pwd)/.venv/bin/$file $localbin/$file; | |
done | |
echo "Python Environment checkout to $2 ($directory)"; | |
cd $cwd; | |
else | |
# If parameter is not change, execute it | |
exec "/usr/local/Cellar/pyenv/1.2.4/libexec/pyenv" "$@"; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment