Created
December 6, 2018 17:04
-
-
Save mrmechko/6c39277ff033e9f88f31ce075fcfd5b7 to your computer and use it in GitHub Desktop.
How to wrap a python executable tied to a specific python version when using `pyenv`
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
wrap_pyenv() { | |
if [ "$#" -eq 2 ]; then | |
if [[ -a "~/bin/$1" ]]; then | |
echo "Command $1 exists. remove it first" | |
exit | |
fi | |
echo $'export PYENV_VIRTUALENV_DISABLE_PROMPT=1' > ~/bin/$1 | |
echo $'eval "$(pyenv init -)"' >> ~/bin/$1 | |
echo $'eval "$(pyenv virtualenv-init -)"' >> ~/bin/$1 | |
echo $'pyenv activate '$2 >> ~/bin/$1 | |
echo $1 $'"$@"' >> ~/bin/$1 | |
chmod +x ~/bin/$1 | |
else | |
echo "Usage: wrap_pyenv [command_name] [pyenv version]" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment