1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-11 00:00:06 +00:00

support POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=if-different; see #730

This commit is contained in:
Roman Perepelitsa 2020-09-09 12:10:26 +02:00
parent 12cef82077
commit 54d40b924c
5 changed files with 25 additions and 12 deletions

View file

@ -859,7 +859,8 @@
typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=37
# Don't show Python version next to the virtual environment name.
typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false
# Don't show virtualenv if pyenv is already shown.
# If set to "false", won't show virtualenv if pyenv is already shown.
# If set to "if-different", won't show virtualenv if it's the same as pyenv.
typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false
# Separate environment name from Python version only with a space.
typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER=

View file

@ -836,7 +836,8 @@
typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=6
# Don't show Python version next to the virtual environment name.
typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false
# Don't show virtualenv if pyenv is already shown.
# If set to "false", won't show virtualenv if pyenv is already shown.
# If set to "if-different", won't show virtualenv if it's the same as pyenv.
typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false
# Separate environment name from Python version only with a space.
typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER=

View file

@ -836,7 +836,8 @@
typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=37
# Don't show Python version next to the virtual environment name.
typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false
# Don't show virtualenv if pyenv is already shown.
# If set to "false", won't show virtualenv if pyenv is already shown.
# If set to "if-different", won't show virtualenv if it's the same as pyenv.
typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false
# Separate environment name from Python version only with a space.
typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER=

View file

@ -896,7 +896,8 @@
# typeset -g POWERLEVEL9K_VIRTUALENV_BACKGROUND=4
# Don't show Python version next to the virtual environment name.
typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false
# Don't show virtualenv if pyenv is already shown.
# If set to "false", won't show virtualenv if pyenv is already shown.
# If set to "if-different", won't show virtualenv if it's the same as pyenv.
typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false
# Separate environment name from Python version only with a space.
typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER=

View file

@ -4083,11 +4083,18 @@ prompt_virtualenv() {
local v=${VIRTUAL_ENV:t}
[[ $v == $~_POWERLEVEL9K_VIRTUALENV_GENERIC_NAMES ]] && v=${VIRTUAL_ENV:h:t}
msg+="$_POWERLEVEL9K_VIRTUALENV_LEFT_DELIMITER${v//\%/%%}$_POWERLEVEL9K_VIRTUALENV_RIGHT_DELIMITER"
if (( _POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV )); then
_p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '' "$msg"
else
_p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '${(M)${#P9K_PYENV_PYTHON_VERSION}:#0}' "$msg"
fi
case $_POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV in
false)
_p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '${(M)${#P9K_PYENV_PYTHON_VERSION}:#0}' "$msg"
;;
if-different)
_p9k_escape $v
_p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '${${:-'$_p9k__ret'}:#$_p9k__pyenv_version}' "$msg"
;;
*)
_p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '' "$msg"
;;
esac
}
_p9k_prompt_virtualenv_init() {
@ -4124,7 +4131,7 @@ 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
unset P9K_PYENV_PYTHON_VERSION _p9k__pyenv_version
local v=${(j.:.)${(@)${(s.:.)PYENV_VERSION}#python-}}
if [[ -n $v ]]; then
@ -4180,6 +4187,8 @@ prompt_pyenv() {
typeset -g P9K_PYENV_PYTHON_VERSION=$match[1]
fi
typeset -g _p9k__pyenv_version=$v
_p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '' "${v//\%/%%}"
}
@ -7201,7 +7210,7 @@ _p9k_init_params() {
_p9k_declare -e POWERLEVEL9K_VI_VISUAL_MODE_STRING
# OVERWRITE mode is shown as INSERT unless POWERLEVEL9K_VI_OVERWRITE_MODE_STRING is explicitly set.
_p9k_declare -e POWERLEVEL9K_VI_OVERWRITE_MODE_STRING
_p9k_declare -b POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV 1
_p9k_declare -s POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV true
_p9k_declare -b POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION 1
_p9k_declare -e POWERLEVEL9K_VIRTUALENV_LEFT_DELIMITER "("
_p9k_declare -e POWERLEVEL9K_VIRTUALENV_RIGHT_DELIMITER ")"
@ -7869,7 +7878,7 @@ _p9k_must_init() {
[[ $sig == $_p9k__param_sig ]] && return 1
_p9k_deinit
fi
_p9k__param_pat=$'v106\1'${(q)ZSH_VERSION}$'\1'${(q)ZSH_PATCHLEVEL}$'\1'
_p9k__param_pat=$'v107\1'${(q)ZSH_VERSION}$'\1'${(q)ZSH_PATCHLEVEL}$'\1'
_p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1'
_p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1'
_p9k__param_pat+=$'$GITSTATUS_CACHE_DIR\1$GITSTATUS_AUTO_INSTALL\1${ZLE_RPROMPT_INDENT:-1}\1'