From 361eec6f95d31570c77b98f5405efe508592eadd Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 30 Apr 2019 12:51:34 +0200 Subject: [PATCH 1/2] replace all -v checks with equivalents (trying to port to zsh 5.2) --- functions/icons.zsh | 4 ++-- functions/utilities.zsh | 2 +- powerlevel9k.zsh-theme | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/functions/icons.zsh b/functions/icons.zsh index ca7b2b0a..d1cccffd 100755 --- a/functions/icons.zsh +++ b/functions/icons.zsh @@ -550,8 +550,8 @@ function _p9k_init_icons() { function print_icon() { local icon_name=$1 local var_name=POWERLEVEL9K_${icon_name} - if [[ -v "$var_name" ]]; then - echo -n "${(P)ICON_USER_VARIABLE}" + if [[ -n "${(tP)var_name}" ]]; then + echo -n "${(P)var_name}" else echo -n "${icons[$icon_name]}" fi diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 7a322e57..9821b287 100755 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -22,7 +22,7 @@ function set_default() { local varname=$1 shift - if [[ -v $varname ]]; then + if [[ -n ${(tP)varname} ]]; then typeset $flags $varname elif [[ "$flags" == *[aA]* ]]; then eval "typeset ${(@q)flags} ${(q)varname}=(${(qq)@})" diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 040e717f..242c8cc9 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -55,7 +55,7 @@ if ! autoload -U is-at-least || ! is-at-least 5.2; then return 1 fi -if [[ -v _P9K_SOURCED ]]; then +if (( $+_P9K_SOURCED )); then prompt_powerlevel9k_setup "$@" return fi @@ -1608,7 +1608,7 @@ powerlevel9k_vcs_init() { local component state for component in REMOTE_URL COMMIT BRANCH TAG REMOTE_BRANCH STAGED UNSTAGED UNTRACKED \ OUTGOING_CHANGES INCOMING_CHANGES STASH ACTION; do - local color=${(P):-POWERLEVEL9K_VCS_${component}FORMAT_FOREGROUND} + local color=${(P)${:-POWERLEVEL9K_VCS_${component}FORMAT_FOREGROUND}} if [[ -n $color ]]; then for state in "${(@k)vcs_states}"; do local var=POWERLEVEL9K_VCS_${(U)state}_${component}FORMAT_FOREGROUND @@ -1661,7 +1661,7 @@ typeset -gAH _P9K_LAST_GIT_PROMPT typeset -gAH _P9K_GIT_SLOW function _p9k_vcs_style() { - local color=${(P):-POWERLEVEL9K_VCS_${1}_${2}FORMAT_FOREGROUND} + local color=${(P)${:-POWERLEVEL9K_VCS_${1}_${2}FORMAT_FOREGROUND}} if [[ -z $color ]]; then _P9K_RETVAL="" return @@ -1679,7 +1679,7 @@ function _p9k_vcs_style() { } function _p9k_vcs_render() { - if [[ -v _P9K_NEXT_VCS_DIR ]]; then + if (( $+_P9K_NEXT_VCS_DIR )); then local -a msg local dir=${${GIT_DIR:a}:-$PWD} while true; do @@ -1864,7 +1864,7 @@ function _p9k_vcs_resume() { function _p9k_vcs_gitstatus() { [[ $POWERLEVEL9K_DISABLE_GITSTATUS == true ]] && return 1 if [[ $_P9K_REFRESH_REASON == precmd ]]; then - if [[ -v _P9K_NEXT_VCS_DIR ]]; then + if (( $+_P9K_NEXT_VCS_DIR )); then typeset -gH _P9K_NEXT_VCS_DIR=${${GIT_DIR:a}:-$PWD} else local dir=${${GIT_DIR:a}:-$PWD} From 79ea46de97e7e80f56fd725b34be589056922edd Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 30 Apr 2019 13:39:27 +0200 Subject: [PATCH 2/2] lower the minimum required zsh version to 5.1 --- README.md | 5 ++++- powerlevel9k.zsh-theme | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1ea338a6..d529a14a 100644 --- a/README.md +++ b/README.md @@ -314,4 +314,7 @@ This method of installation won't make anything slower or otherwise sub-par. ### What is the minimum supported zsh version? -Anything below 5.2 definitely won't work. 5.4 definitely will. +ZSH 5.1 or newer should work. + +However, there are too many version, OS, platform, terminal and option configurations to test. If +Powerlevel10k doesn't work for you, please open an issue. diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 242c8cc9..ddc411a8 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -26,9 +26,9 @@ if test -z "${ZSH_VERSION}"; then exit 1 fi -if ! autoload -U is-at-least || ! is-at-least 5.2; then +if ! autoload -U is-at-least || ! is-at-least 5.1; then () { - >&2 echo -E "You are using ZSH version $ZSH_VERSION. The minimum required version for Powerlevel10k is 5.2." + >&2 echo -E "You are using ZSH version $ZSH_VERSION. The minimum required version for Powerlevel10k is 5.1." >&2 echo -E "Type 'echo \$ZSH_VERSION' to see your current zsh version." local def=${SHELL:c:A} local cur=${${ZSH_ARGZERO#-}:c:A} @@ -37,7 +37,7 @@ if ! autoload -U is-at-least || ! is-at-least 5.2; then >&2 echo -E "The shell you are currently running is likely $cur." fi local other=${${:-zsh}:c} - if [[ -n $other ]] && $other -c 'autoload -U is-at-least && is-at-least 5.2' &>/dev/null; then + if [[ -n $other ]] && $other -c 'autoload -U is-at-least && is-at-least 5.1' &>/dev/null; then local other_v=$($other -c 'echo -E $ZSH_VERSION' 2>/dev/null) if [[ -n $other_v && $other_v != $ZSH_VERSION ]]; then >&2 echo -E "You have $other with version $other_v but this is not what you are using."