1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-17 10:10:07 +00:00

display the new rustc version when rustc is upgraded; fixes #365

This commit is contained in:
romkatv 2019-12-06 14:46:45 +01:00
parent 339703e2b1
commit d5cff592c6

View file

@ -2179,9 +2179,7 @@ instant_prompt_root_indicator() { prompt_root_indicator; }
################################################################ ################################################################
# Segment to display Rust version number # Segment to display Rust version number
prompt_rust_version() { prompt_rust_version() {
_p9k_cached_cmd_stdout rustc --version || return (( $+commands[rustc] )) || return
local v=${${_p9k_ret#rustc }%% *}
[[ -n $v ]] || return
if (( _POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY )); then if (( _POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY )); then
local dir=$_p9k_pwd_a local dir=$_p9k_pwd_a
while true; do while true; do
@ -2190,6 +2188,25 @@ prompt_rust_version() {
dir=${dir:h} dir=${dir:h}
done done
fi fi
local rustc=$commands[rustc] so
if (( $+commands[ldd] )); then
if _p9k_cache_stat_get $0_so $rustc; then
so=$_p9k_cache_val[1]
else
local line match
for line in "${(@f)$(ldd $rustc 2>/dev/null)}"; do
[[ $line == (#b)[[:space:]]#librustc_driver[^[:space:]]#.so' => '(*)' (0x'[[:xdigit:]]#')' ]] || continue
so=$match[1]
break
done
_p9k_cache_stat_set "$so"
fi
fi
if ! _p9k_cache_stat_get $0_v $rustc $so; then
_p9k_cache_stat_set "$($rustc --version 2>/dev/null)"
fi
local v=${${_p9k_cache_val[1]#rustc }%% *}
[[ -n $v ]] || return
_p9k_prompt_segment "$0" "darkorange" "$_p9k_color1" 'RUST_ICON' 0 '' "${v//\%/%%}" _p9k_prompt_segment "$0" "darkorange" "$_p9k_color1" 'RUST_ICON' 0 '' "${v//\%/%%}"
} }
@ -5413,7 +5430,7 @@ _p9k_must_init() {
[[ $sig == $_p9k__param_sig ]] && return 1 [[ $sig == $_p9k__param_sig ]] && return 1
_p9k_deinit _p9k_deinit
fi fi
_p9k__param_pat=$'v13\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1' _p9k__param_pat=$'v14\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1'
_p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1' _p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1'
_p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1' _p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1'
_p9k__param_pat+=$'$DEFAULT_USER\1${ZLE_RPROMPT_INDENT:-1}\1$P9K_SSH\1$__p9k_ksh_arrays' _p9k__param_pat+=$'$DEFAULT_USER\1${ZLE_RPROMPT_INDENT:-1}\1$P9K_SSH\1$__p9k_ksh_arrays'