Skip to content

Instantly share code, notes, and snippets.

@askb
Created August 20, 2022 12:23
Show Gist options
  • Save askb/8fe1a7a345096bc1dc58c5d7535b51b1 to your computer and use it in GitHub Desktop.
Save askb/8fe1a7a345096bc1dc58c5d7535b51b1 to your computer and use it in GitHub Desktop.
## pyenv configs
# Set the python version available under pyenv
export PYENV_ROOT="/opt/pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
set_python_version="3.9"
# Takes 3.x and returns 3.x.y from the available py3.x versions on the system
pyver() { grep "^$(echo ${1//[a-zA-Z]/})\(\..*\)\?\.[0-9]\+$" <(pyenv versions | sed 's/[[:alpha:]|(|)|/||*|[:space:]]//g'| tr -d ' ') | sort -V | tail -n 1 ; }
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
eval "$(pyenv global ${set_python_version})"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment