Skip to content

Instantly share code, notes, and snippets.

@styk-tv
Forked from jmvrbanac/install_pyenv.sh
Last active May 12, 2023 14:47
Show Gist options
  • Save styk-tv/b160cd2e4a54472ba04a17f11b7faca5 to your computer and use it in GitHub Desktop.
Save styk-tv/b160cd2e4a54472ba04a17f11b7faca5 to your computer and use it in GitHub Desktop.
ubu22 pyenv
#!/bin/bash
sudo apt-get install git python3-pip make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl liblzma-dev
sudo pip install virtualenvwrapper
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
git clone https://github.com/yyuu/pyenv-virtualenvwrapper.git ~/.pyenv/plugins/pyenv-virtualenvwrapper
git clone https://github.com/pyenv/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
echo 'pyenv virtualenvwrapper' >> ~/.bashrc
exec $SHELL
### VENV ON PROMPT ADD TO .BASHRC
export PYENV_VIRTUALENV_DISABLE_PROMPT=1
pyenvVirtualenvUpdatePrompt() {
RED='\[\e[0;31m\]'
GREEN='\[\e[0;32m\]'
BLUE='\[\e[0;34m\]'
RESET='\[\e[0m\]'
[ -z "$PYENV_VIRTUALENV_ORIGINAL_PS1" ] && export PYENV_VIRTUALENV_ORIGINAL_PS1="$PS1"
[ -z "$PYENV_VIRTUALENV_GLOBAL_NAME" ] && export PYENV_VIRTUALENV_GLOBAL_NAME="$(pyenv global)"
VENV_NAME="$(pyenv version-name)"
VENV_NAME="${VENV_NAME##*/}"
GLOBAL_NAME="$PYENV_VIRTUALENV_GLOBAL_NAME"
# non-global versions:
COLOR="$BLUE"
# global version:
[ "$VENV_NAME" == "$GLOBAL_NAME" ] && COLOR="$RED"
# virtual envs:
[ "${VIRTUAL_ENV##*/}" == "$VENV_NAME" ] && COLOR="$GREEN"
if [ -z "$COLOR" ]; then
PS1="$PYENV_VIRTUALENV_ORIGINAL_PS1"
else
PS1="($COLOR${VENV_NAME}$RESET)$PYENV_VIRTUALENV_ORIGINAL_PS1"
fi
export PS1
}
export PROMPT_COMMAND="$PROMPT_COMMAND pyenvVirtualenvUpdatePrompt;"
@styk-tv
Copy link
Author

styk-tv commented Jan 27, 2023

for ubuntu 22 its python3-pip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment