summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Perepelitsa <roman.perepelitsa@gmail.com>2020-09-09 13:10:26 +0300
committerRoman Perepelitsa <roman.perepelitsa@gmail.com>2020-09-09 13:10:26 +0300
commit54d40b924c491a6510c44391dccac05fe78a7310 (patch)
treefd1c24801d63997ddf4a30e48122a2e34431bc6a
parent12cef820770a5067b16bb31dfe2f5078e1f88266 (diff)
support POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=if-different; see #730
-rw-r--r--config/p10k-classic.zsh3
-rw-r--r--config/p10k-lean-8colors.zsh3
-rw-r--r--config/p10k-lean.zsh3
-rw-r--r--config/p10k-rainbow.zsh3
-rw-r--r--internal/p10k.zsh25
5 files changed, 25 insertions, 12 deletions
diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh
index e34f172a..b7abae53 100644
--- a/config/p10k-classic.zsh
+++ b/config/p10k-classic.zsh
@@ -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=
diff --git a/config/p10k-lean-8colors.zsh b/config/p10k-lean-8colors.zsh
index 79056ebd..8a4df8d1 100644
--- a/config/p10k-lean-8colors.zsh
+++ b/config/p10k-lean-8colors.zsh
@@ -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=
diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh
index e82f1a81..ed6ce824 100644
--- a/config/p10k-lean.zsh
+++ b/config/p10k-lean.zsh
@@ -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=
diff --git a/config/p10k-rainbow.zsh b/config/p10k-rainbow.zsh
index 9e1dedd0..39e1261e 100644
--- a/config/p10k-rainbow.zsh
+++ b/config/p10k-rainbow.zsh
@@ -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=
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index fc8f3f8b..cf4d471e 100644
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -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'