From 4ed8aae3246da5c8f16978266ba6af139a1d06ca Mon Sep 17 00:00:00 2001 From: Zaidhaan Hussain Date: Sun, 7 May 2023 17:10:08 +0800 Subject: [PATCH] nvm: implement POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW and default to false --- config/p10k-classic.zsh | 3 +++ config/p10k-lean-8colors.zsh | 3 +++ config/p10k-lean.zsh | 3 +++ config/p10k-rainbow.zsh | 3 +++ internal/p10k.zsh | 6 +++++- 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 231c8009..d29aa2f8 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -1007,6 +1007,9 @@ ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### # Nvm color. typeset -g POWERLEVEL9K_NVM_FOREGROUND=70 + # If set to false, hide node version if it's the same as default: + # $(nvm version current) == $(nvm version default). + typeset -g POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW=false # If set to false, hide node version if it's equal to "system". typeset -g POWERLEVEL9K_NVM_SHOW_SYSTEM=true # Custom icon. diff --git a/config/p10k-lean-8colors.zsh b/config/p10k-lean-8colors.zsh index 36dc7287..9fbd5fa2 100644 --- a/config/p10k-lean-8colors.zsh +++ b/config/p10k-lean-8colors.zsh @@ -988,6 +988,9 @@ ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### # Nvm color. typeset -g POWERLEVEL9K_NVM_FOREGROUND=2 + # If set to false, hide node version if it's the same as default: + # $(nvm version current) == $(nvm version default). + typeset -g POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW=false # If set to false, hide node version if it's equal to "system". typeset -g POWERLEVEL9K_NVM_SHOW_SYSTEM=true # Custom icon. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 09403985..844c1bfe 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -984,6 +984,9 @@ ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### # Nvm color. typeset -g POWERLEVEL9K_NVM_FOREGROUND=70 + # If set to false, hide node version if it's the same as default: + # $(nvm version current) == $(nvm version default). + typeset -g POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW=false # If set to false, hide node version if it's equal to "system". typeset -g POWERLEVEL9K_NVM_SHOW_SYSTEM=true # Custom icon. diff --git a/config/p10k-rainbow.zsh b/config/p10k-rainbow.zsh index c6fd0553..c21d879a 100644 --- a/config/p10k-rainbow.zsh +++ b/config/p10k-rainbow.zsh @@ -1053,6 +1053,9 @@ # Nvm color. typeset -g POWERLEVEL9K_NVM_FOREGROUND=0 typeset -g POWERLEVEL9K_NVM_BACKGROUND=5 + # If set to false, hide node version if it's the same as default: + # $(nvm version current) == $(nvm version default). + typeset -g POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW=false # If set to false, hide node version if it's equal to "system". typeset -g POWERLEVEL9K_NVM_SHOW_SYSTEM=true # Custom icon. diff --git a/internal/p10k.zsh b/internal/p10k.zsh index cf32f9ba..87af17e8 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -2567,7 +2567,10 @@ _p9k_nvm_ls_current() { prompt_nvm() { [[ -n $NVM_DIR ]] && _p9k_nvm_ls_current || return local current=$_p9k__ret - ! _p9k_nvm_ls_default || [[ $_p9k__ret != $current ]] || return + _p9k_nvm_ls_default + if (( !_POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW )); then + [[ $current == $_p9k__ret ]] && return + fi if (( !_POWERLEVEL9K_NVM_SHOW_SYSTEM )); then [[ $current == system ]] && return fi @@ -7533,6 +7536,7 @@ _p9k_init_params() { _p9k_declare -b POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -a POWERLEVEL9K_NODENV_SOURCES -- shell local global _p9k_declare -b POWERLEVEL9K_NODENV_SHOW_SYSTEM 1 + _p9k_declare -b POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW 0 _p9k_declare -b POWERLEVEL9K_NVM_SHOW_SYSTEM 1 _p9k_declare -b POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -a POWERLEVEL9K_RBENV_SOURCES -- shell local global