From 0cfe7f081f3df46eac956d5af48bf6372fa6e6a6 Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Thu, 10 Oct 2024 12:05:42 +1100 Subject: [PATCH] feat(pyenv): add prefix and suffix for pyenv_prompt_info Added two new environment variables `ZSH_THEME_PYENV_PREFIX` and `ZSH_THEME_PYENV_SUFFIX` to allow customisation of the prefix and suffix displayed around the Python version in the prompt. --- plugins/pyenv/README.md | 6 ++++++ plugins/pyenv/pyenv.plugin.zsh | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/pyenv/README.md b/plugins/pyenv/README.md index 95d79cb52..86953895a 100644 --- a/plugins/pyenv/README.md +++ b/plugins/pyenv/README.md @@ -26,6 +26,12 @@ eval "$(pyenv init --path)" - `ZSH_PYENV_VIRTUALENV`: if set to `false`, the plugin will not load pyenv-virtualenv when it finds it. +- `ZSH_THEME_PYENV_PREFIX`: the prefix to display before the Python version in + the prompt. + +- `ZSH_THEME_PYENV_SUFFIX`: the prefix to display after the Python version in + the prompt. + ## Functions - `pyenv_prompt_info`: displays the Python version in use by pyenv; or the global Python diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh index b5c9a7bd3..8d66e62e0 100644 --- a/plugins/pyenv/pyenv.plugin.zsh +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -88,13 +88,13 @@ if [[ $FOUND_PYENV -eq 1 ]]; then function pyenv_prompt_info() { local version="$(pyenv version-name)" - echo "${version:gs/%/%%}" + echo "${ZSH_THEME_PYENV_PREFIX=}${version:gs/%/%%}${ZSH_THEME_PYENV_SUFFIX=}" } else # Fall back to system python function pyenv_prompt_info() { local version="$(python3 -V 2>&1 | cut -d' ' -f2)" - echo "system: ${version:gs/%/%%}" + echo "${ZSH_THEME_PYENV_PREFIX=}system: ${version:gs/%/%%}${ZSH_THEME_PYENV_SUFFIX=}" } fi