mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-12-22 15:21:56 +00:00
Merge pull request #143 from dritter/segment_deprecation_helpers
Added segment deprecation helper
This commit is contained in:
commit
b83cfd7515
2 changed files with 24 additions and 0 deletions
|
@ -118,3 +118,19 @@ if [[ "$OS" == 'OSX' ]]; then
|
||||||
SED_EXTENDED_REGEX_PARAMETER="-E"
|
SED_EXTENDED_REGEX_PARAMETER="-E"
|
||||||
fi
|
fi
|
||||||
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() {
|
||||||
|
typeset -AH raw_deprecated_segments
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -754,6 +754,14 @@ powerlevel9k_init() {
|
||||||
print -P "You should put: %F{blue}export TERM=\"xterm-256color\"%f in your \~\/.zshrc"
|
print -P "You should put: %F{blue}export TERM=\"xterm-256color\"%f in your \~\/.zshrc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Display a warning if deprecated segments are in use.
|
||||||
|
typeset -AH deprecated_segments
|
||||||
|
# old => new
|
||||||
|
deprecated_segments=(
|
||||||
|
'longstatus' 'status'
|
||||||
|
)
|
||||||
|
print_deprecation_warning deprecated_segments
|
||||||
|
|
||||||
setopt prompt_subst
|
setopt prompt_subst
|
||||||
|
|
||||||
setopt LOCAL_OPTIONS
|
setopt LOCAL_OPTIONS
|
||||||
|
|
Loading…
Reference in a new issue