diff options
author | Roman Perepelitsa <roman.perepelitsa@gmail.com> | 2022-10-09 12:54:02 +0300 |
---|---|---|
committer | Roman Perepelitsa <roman.perepelitsa@gmail.com> | 2022-10-09 12:54:02 +0300 |
commit | bd0c9f4ec7511f51851f9bde0e2e24b05fd1c10e (patch) | |
tree | 0fa52ad0592a1962273b4c0852be41e7192d007f /internal/p10k.zsh | |
parent | f89b54faf23731255b3814f45f2c989c2c61fc91 (diff) |
rename arch to cpu_arch and rewrite it (#1752)
Diffstat (limited to 'internal/p10k.zsh')
-rw-r--r-- | internal/p10k.zsh | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/internal/p10k.zsh b/internal/p10k.zsh index f9e38f84..b21b57bf 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -5646,18 +5646,26 @@ _p9k_prompt_haskell_stack_init() { ################################################################ # CPU Architecture -prompt_arch() { - if ! _p9k_cache_ephemeral_get $0 ; then - _p9k_cache_ephemeral_set $(arch) +prompt_cpu_arch() { + local -i len=$#_p9k__prompt _p9k__has_upglob + + local state text + if _p9k_cache_ephemeral_get $0; then + state=$_p9k__cache_val[1] + text=$_p9k__cache_val[2] + else + text=$(command arch) 2>/dev/null && [[ $text == [a-zA-Z][a-zA-Z0-9_]# ]] || text= + state=_${(U)text} + _p9k_cache_ephemeral_set "$state" "$text" + fi + if [[ -n $text ]]; then + _p9k_prompt_segment "$0$state" "yellow" "$_p9k_color1" 'ARCH_ICON' 0 '' "$text" fi - [[ $_p9k__cache_val[1] == $POWERLEVEL9K_ARCH_DEFAULT ]] && return - _p9k_prompt_segment "$0" "$_p9k_color1" "orange1" 'ARCH_ICON' 0 '' "$_p9k__cache_val[1]" -} -instant_prompt_arch() { prompt_arch; } + (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] +} _p9k_prompt_arch_init() { - echo 'arch init' >> ~/p9k_debug.txt typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[arch]' } |