aboutsummaryrefslogtreecommitdiff
path: root/internal/p10k.zsh
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-12-06 16:46:45 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-12-06 16:46:45 +0300
commitd5cff592c6573b5274c13c40770497786edea5c9 (patch)
tree4291a2c860993caee67e6c2f0221c6ab7da8088d /internal/p10k.zsh
parent339703e2b1b4c84d201ff50523e8ccf93811e932 (diff)
display the new rustc version when rustc is upgraded; fixes #365
Diffstat (limited to 'internal/p10k.zsh')
-rw-r--r--internal/p10k.zsh25
1 files changed, 21 insertions, 4 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index f0f0707e..5bf89edb 100644
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -2179,9 +2179,7 @@ instant_prompt_root_indicator() { prompt_root_indicator; }
################################################################
# Segment to display Rust version number
prompt_rust_version() {
- _p9k_cached_cmd_stdout rustc --version || return
- local v=${${_p9k_ret#rustc }%% *}
- [[ -n $v ]] || return
+ (( $+commands[rustc] )) || return
if (( _POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY )); then
local dir=$_p9k_pwd_a
while true; do
@@ -2190,6 +2188,25 @@ prompt_rust_version() {
dir=${dir:h}
done
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//\%/%%}"
}
@@ -5413,7 +5430,7 @@ _p9k_must_init() {
[[ $sig == $_p9k__param_sig ]] && return 1
_p9k_deinit
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+=$'$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'