aboutsummaryrefslogtreecommitdiff
path: root/internal/p10k.zsh
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-09-07 11:05:56 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-09-07 11:05:56 +0300
commit9a8a6ca836fa5cca5cd1f8d181a0281edc2712a5 (patch)
tree1cd66a7295d6b35239a84d49127fd8c7cad10042 /internal/p10k.zsh
parent91b715f18f7f9e9b9bcd921a3387f04e5a3dc7d3 (diff)
allow prompt segments to be disabled through configuration options
Prompt segment `foo` doesn't get evaluated or shown on the left if `${POWERLEVEL9K_FOO_LEFT_DISABLED-$POWERLEVEL9K_FOO_DISABLED}` is equal to `true`. Example: POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(dir) - By default `dir` is shown on the left and on the right. - `POWERLEVEL9K_DIR_LEFT_DISABLED=true` disables `dir` on the left. - `POWERLEVEL9K_DIR_RIGHT_DISABLED=true` disables `dir` on the right. - `POWERLEVEL9K_DIR_DISABLED=true` disables `dir` everywhere. Note that it's possible to hide segments without disabling their evaluation through expansions. For example: POWERLEVEL9K_DIR_CONTENT_EXPANSION='${HIDE_DIR-$P9K_CONTENT}' POWERLEVEL9K_DIR_VISUAL_IDENTIFIER_EXPANSION='${HIDE_DIR-$P9K_VISUAL_IDENTIFIER}' With these settings, `HIDE_DIR=''` hides `dir` while `unset HIDE_DIR` restores it. fixes #205
Diffstat (limited to 'internal/p10k.zsh')
-rwxr-xr-xinternal/p10k.zsh24
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index e28bf616..e409c36c 100755
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -3785,6 +3785,30 @@ _p9k_init_params() {
#
# These correspond to `java -fullversion` and `java -version` respectively.
_p9k_declare -b POWERLEVEL9K_JAVA_VERSION_FULL 1
+
+ local -i i=1
+ while (( i <= $#_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS )); do
+ local segment=${(U)_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[i]}
+ local var=POWERLEVEL9K_${segment}_LEFT_DISABLED
+ (( $+parameters[$var] )) || var=POWERLEVEL9K_${segment}_DISABLED
+ if [[ ${(P)var} == true ]]; then
+ _POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[i,i]=()
+ else
+ (( ++i ))
+ fi
+ done
+
+ local -i i=1
+ while (( i <= $#_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS )); do
+ local segment=${(U)_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[i]}
+ local var=POWERLEVEL9K_${segment}_RIGHT_DISABLED
+ (( $+parameters[$var] )) || var=POWERLEVEL9K_${segment}_DISABLED
+ if [[ ${(P)var} == true ]]; then
+ _POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[i,i]=()
+ else
+ (( ++i ))
+ fi
+ done
}
typeset -ga __p9k_wrapped_zle_widgets