mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-19 21:41:07 +01:00
feat(pyenv): add prompt customization (#12738)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
This commit is contained in:
parent
b5d52682ca
commit
081d704f32
2 changed files with 16 additions and 2 deletions
|
@ -26,6 +26,14 @@ eval "$(pyenv init --path)"
|
||||||
- `ZSH_PYENV_VIRTUALENV`: if set to `false`, the plugin will not load pyenv-virtualenv
|
- `ZSH_PYENV_VIRTUALENV`: if set to `false`, the plugin will not load pyenv-virtualenv
|
||||||
when it finds it.
|
when it finds it.
|
||||||
|
|
||||||
|
- `ZSH_THEME_PYENV_NO_SYSTEM`: if set to `true`, the plugin will not show the system or
|
||||||
|
default Python version 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
|
## Functions
|
||||||
|
|
||||||
- `pyenv_prompt_info`: displays the Python version in use by pyenv; or the global Python
|
- `pyenv_prompt_info`: displays the Python version in use by pyenv; or the global Python
|
||||||
|
|
|
@ -88,13 +88,19 @@ if [[ $FOUND_PYENV -eq 1 ]]; then
|
||||||
|
|
||||||
function pyenv_prompt_info() {
|
function pyenv_prompt_info() {
|
||||||
local version="$(pyenv version-name)"
|
local version="$(pyenv version-name)"
|
||||||
echo "${version:gs/%/%%}"
|
if [[ "$ZSH_THEME_PYENV_NO_SYSTEM" == "true" ]] && [[ "${version}" == "system" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
echo "${ZSH_THEME_PYENV_PREFIX=}${version:gs/%/%%}${ZSH_THEME_PYENV_SUFFIX=}"
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
# Fall back to system python
|
# Fall back to system python
|
||||||
function pyenv_prompt_info() {
|
function pyenv_prompt_info() {
|
||||||
|
if [[ "$ZSH_THEME_PYENV_NO_SYSTEM" == "true" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
local version="$(python3 -V 2>&1 | cut -d' ' -f2)"
|
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
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue