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.
This commit is contained in:
Olivier Mehani 2024-10-10 12:05:42 +11:00
commit 0cfe7f081f
No known key found for this signature in database
GPG key ID: 432AAE851836562A
2 changed files with 8 additions and 2 deletions

View file

@ -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

View file

@ -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