From fdb0bb6af70c0ee70454fe456b4b40a9bba15118 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 2 May 2020 14:32:17 +0200 Subject: [PATCH] set P9K_PYENV_PYTHON_VERSION in prompt_pyenv; see #679 --- internal/p10k.zsh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 6dc2e8a4..8ba844f3 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -4038,6 +4038,8 @@ function _p9k_pyenv_global_version() { # Segment to display pyenv information # https://github.com/pyenv/pyenv#choosing-the-python-version prompt_pyenv() { + unset P9K_PYENV_PYTHON_VERSION + local v=${(j.:.)${(@)${(s.:.)PYENV_VERSION}#python-}} if [[ -n $v ]]; then (( ${_POWERLEVEL9K_PYENV_SOURCES[(I)shell]} )) || return @@ -4084,6 +4086,14 @@ prompt_pyenv() { [[ $v == system ]] && return fi + local versions=${PYENV_ROOT:-$HOME/.pyenv}/versions + versions=${versions:A} + local version=$versions/$v + version=${version:A} + if [[ $version == (#b)$versions/([^/]##)* ]]; then + typeset -g P9K_PYENV_PYTHON_VERSION=$match[1] + fi + _p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '' "${v//\%/%%}" }