diff options
author | Dominik Ritter <dritter03@googlemail.com> | 2015-11-17 03:39:49 +0300 |
---|---|---|
committer | Dominik Ritter <dritter03@googlemail.com> | 2015-11-17 03:39:49 +0300 |
commit | ce7b99cdaf4459afb7d7043cae25e4f02489ba87 (patch) | |
tree | 3b0486d9bde3f2410dd262d28317199ce7fc65ac /functions | |
parent | 9b067ea29c1231ee147476a4ebd012b0722a067d (diff) |
Added a mechanism to make deprecated segments visible to the user.
Diffstat (limited to 'functions')
-rw-r--r-- | functions/utilities.zsh | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/functions/utilities.zsh b/functions/utilities.zsh index 80a38977..3c6a4d49 100644 --- a/functions/utilities.zsh +++ b/functions/utilities.zsh @@ -118,3 +118,18 @@ if [[ "$OS" == 'OSX' ]]; then SED_EXTENDED_REGEX_PARAMETER="-E" fi fi + +# Print a deprecation warning if an old segment is in use. +# Takes the name of an associative array that contains the +# deprecated segments as keys, the values contain the new +# segment names. +print_deprecation_warning() { + local -A raw_deprecated_segments=(${(kvP)1}) + + for key in ${(@k)raw_deprecated_segments}; do + if [[ -n "${POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[(r)$key]}" ]] || [[ -n "${POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[(r)$key]}" ]]; then + # segment is deprecated + print -P "%F{yellow}Warning!%f The '$key' segment is deprecated. Use '%F{blue}${raw_deprecated_segments[$key]}%f' instead. For more informations, have a look at the CHANGELOG.md." + fi + done +} |