diff options
Diffstat (limited to 'dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/pyenv.zsh')
| -rw-r--r-- | dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/pyenv.zsh | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/pyenv.zsh b/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/pyenv.zsh new file mode 100644 index 00000000..1ef67ba6 --- /dev/null +++ b/dot-oh-my-zsh/custom/themes/spaceship-prompt/sections/pyenv.zsh @@ -0,0 +1,37 @@ +# +# pyenv +# +# pyenv lets you easily switch between multiple versions of Python. +# Link: https://github.com/pyenv/pyenv + +# ------------------------------------------------------------------------------ +# Configuration +# ------------------------------------------------------------------------------ + +SPACESHIP_PYENV_SHOW="${SPACESHIP_PYENV_SHOW=true}" +SPACESHIP_PYENV_PREFIX="${SPACESHIP_PYENV_PREFIX="$SPACESHIP_PROMPT_DEFAULT_PREFIX"}" +SPACESHIP_PYENV_SUFFIX="${SPACESHIP_PYENV_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}" +SPACESHIP_PYENV_SYMBOL="${SPACESHIP_PYENV_SYMBOL="🐍 "}" +SPACESHIP_PYENV_COLOR="${SPACESHIP_PYENV_COLOR="yellow"}" + +# ------------------------------------------------------------------------------ +# Section +# ------------------------------------------------------------------------------ + +# Show current version of pyenv Python, including system. +spaceship_pyenv() { + [[ $SPACESHIP_PYENV_SHOW == false ]] && return + + # Show pyenv python version only for Python-specific folders + [[ -n "$PYENV_VERSION" || -f .python-version || -f requirements.txt || -f pyproject.toml || -n *.py(#qN^/) ]] || return + + spaceship::exists pyenv || return # Do nothing if pyenv is not installed + + local pyenv_status=${$(pyenv version-name 2>/dev/null)//:/ } + + spaceship::section \ + "$SPACESHIP_PYENV_COLOR" \ + "$SPACESHIP_PYENV_PREFIX" \ + "${SPACESHIP_PYENV_SYMBOL}${pyenv_status}" \ + "$SPACESHIP_PYENV_SUFFIX" +} |
