From c5203a3da2a8814992c91b20f8246b19ea88401c Mon Sep 17 00:00:00 2001 From: brent-moffit <72231013+brent-moffit@users.noreply.github.com> Date: Wed, 2 Feb 2022 17:47:46 -0800 Subject: [PATCH 1/3] Add `arch` prompt for displaying CPU architecture Adds the `arch` prompt to `p10k.zsh`, `ARCH_ICON` to `icons.zsh`, and commented entries in the default configs --- config/p10k-classic.zsh | 5 +++++ config/p10k-lean-8colors.zsh | 5 +++++ config/p10k-lean.zsh | 5 +++++ config/p10k-rainbow.zsh | 5 +++++ internal/icons.zsh | 5 +++++ internal/p10k.zsh | 15 +++++++++++++++ 6 files changed, 40 insertions(+) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 21ca015..010459b 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -94,6 +94,7 @@ todo # todo items (https://github.com/todotxt/todo.txt-cli) timewarrior # timewarrior tracking status (https://timewarrior.net/) taskwarrior # taskwarrior task count (https://taskwarrior.org/) + # arch # current CPU Architecture # time # current time # =========================[ Line #2 ]========================= newline # \n @@ -1549,6 +1550,10 @@ # P9K_WIFI_NOISE | noise in dBm, from -120 to 0 # P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE) + ##############################[ arch: current cup architecture ]############################## + # Default CPU Aricheture (section is hidden when current architecture matches default) + # typeset -g POWERLEVEL9K_ARCH_DEFAULT='i386' + ####################################[ time: current time ]#################################### # Current time color. typeset -g POWERLEVEL9K_TIME_FOREGROUND=66 diff --git a/config/p10k-lean-8colors.zsh b/config/p10k-lean-8colors.zsh index dc96d4d..a0e3e5b 100644 --- a/config/p10k-lean-8colors.zsh +++ b/config/p10k-lean-8colors.zsh @@ -93,6 +93,7 @@ todo # todo items (https://github.com/todotxt/todo.txt-cli) timewarrior # timewarrior tracking status (https://timewarrior.net/) taskwarrior # taskwarrior task count (https://taskwarrior.org/) + # arch # current CPU Architecture # time # current time # =========================[ Line #2 ]========================= newline # \n @@ -1530,6 +1531,10 @@ # P9K_WIFI_NOISE | noise in dBm, from -120 to 0 # P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE) + ##############################[ arch: current cup architecture ]############################## + # Default CPU Aricheture (section is hidden when current architecture matches default) + # typeset -g POWERLEVEL9K_ARCH_DEFAULT='i386' + ####################################[ time: current time ]#################################### # Current time color. typeset -g POWERLEVEL9K_TIME_FOREGROUND=6 diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index fc3f20d..4b6519d 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -93,6 +93,7 @@ todo # todo items (https://github.com/todotxt/todo.txt-cli) timewarrior # timewarrior tracking status (https://timewarrior.net/) taskwarrior # taskwarrior task count (https://taskwarrior.org/) + # arch # current CPU Architecture # time # current time # =========================[ Line #2 ]========================= newline @@ -1526,6 +1527,10 @@ # P9K_WIFI_NOISE | noise in dBm, from -120 to 0 # P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE) + ##############################[ arch: current cup architecture ]############################## + # Default CPU Aricheture (section is hidden when current architecture matches default) + # typeset -g POWERLEVEL9K_ARCH_DEFAULT='i386' + ####################################[ time: current time ]#################################### # Current time color. typeset -g POWERLEVEL9K_TIME_FOREGROUND=66 diff --git a/config/p10k-rainbow.zsh b/config/p10k-rainbow.zsh index ef5b444..ed850ba 100644 --- a/config/p10k-rainbow.zsh +++ b/config/p10k-rainbow.zsh @@ -94,6 +94,7 @@ todo # todo items (https://github.com/todotxt/todo.txt-cli) timewarrior # timewarrior tracking status (https://timewarrior.net/) taskwarrior # taskwarrior task count (https://taskwarrior.org/) + # arch # current CPU Architecture # time # current time # =========================[ Line #2 ]========================= newline @@ -1634,6 +1635,10 @@ # P9K_WIFI_NOISE | noise in dBm, from -120 to 0 # P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE) + ##############################[ arch: current cup architecture ]############################## + # Default CPU Aricheture (section is hidden when current architecture matches default) + # typeset -g POWERLEVEL9K_ARCH_DEFAULT='i386' + ####################################[ time: current time ]#################################### # Current time color. typeset -g POWERLEVEL9K_TIME_FOREGROUND=0 diff --git a/internal/icons.zsh b/internal/icons.zsh index e3d71ff..c67bc45 100644 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -148,6 +148,7 @@ function _p9k_init_icons() { JULIA_ICON 'jl' SCALA_ICON 'scala' TOOLBOX_ICON '\u2B22' # ⬢ + ARCH_ICON '\uE205' #  ) ;; 'awesome-fontconfig') @@ -280,6 +281,7 @@ function _p9k_init_icons() { JULIA_ICON 'jl' SCALA_ICON 'scala' TOOLBOX_ICON '\u2B22' # ⬢ + ARCH_ICON '\uE205' #  ) ;; 'awesome-mapped-fontconfig') @@ -415,6 +417,7 @@ function _p9k_init_icons() { JULIA_ICON 'jl' SCALA_ICON 'scala' TOOLBOX_ICON '\u2B22' # ⬢ + ARCH_ICON '\uE205' #  ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -548,6 +551,7 @@ function _p9k_init_icons() { JULIA_ICON '\uE624' #  SCALA_ICON '\uE737' #  TOOLBOX_ICON '\uE20F'$s #  + ARCH_ICON '\uE266' ) ;; ascii) @@ -810,6 +814,7 @@ function _p9k_init_icons() { JULIA_ICON 'jl' SCALA_ICON 'scala' TOOLBOX_ICON '\u2B22' # ⬢ + ARCH_ICON '\uE205' #  ) ;; esac diff --git a/internal/p10k.zsh b/internal/p10k.zsh index e797a87..26e43ee 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -5625,6 +5625,21 @@ _p9k_prompt_haskell_stack_init() { typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[stack]' } +################################################################ +# CPU Architecture +prompt_arch() { + if ! _p9k_cache_ephemeral_get $0 ; then + _p9k_cache_ephemeral_set $(arch) + fi + [[ $_p9k__cache_val[1] == $POWERLEVEL9K_ARCH_DEFAULT ]] && return + _p9k_prompt_segment "$0" "orange1" "black" 'ARCH_ICON' 0 '' "$_p9k__cache_val[1]" +} + +_p9k_prompt_arch_init() { + echo 'arch init' >> ~/p9k_debug.txt + typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[arch]' +} + # Use two preexec hooks to survive https://github.com/MichaelAquilina/zsh-you-should-use with # YSU_HARDCORE=1. See https://github.com/romkatv/powerlevel10k/issues/427. _p9k_preexec1() { From 01467fae4f72dd1bf4b73708e6e356b5417dfc68 Mon Sep 17 00:00:00 2001 From: brent-moffit <72231013+brent-moffit@users.noreply.github.com> Date: Mon, 14 Feb 2022 12:27:56 -0800 Subject: [PATCH 2/3] Change arch prompt colors to better match default themes --- internal/p10k.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 26e43ee..965fd81 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -5632,7 +5632,7 @@ prompt_arch() { _p9k_cache_ephemeral_set $(arch) fi [[ $_p9k__cache_val[1] == $POWERLEVEL9K_ARCH_DEFAULT ]] && return - _p9k_prompt_segment "$0" "orange1" "black" 'ARCH_ICON' 0 '' "$_p9k__cache_val[1]" + _p9k_prompt_segment "$0" "$_p9k_color1" "orange1" 'ARCH_ICON' 0 '' "$_p9k__cache_val[1]" } _p9k_prompt_arch_init() { From 59e90bd8b0bee6b00bc9153f13336f6cafeae08a Mon Sep 17 00:00:00 2001 From: brent-moffit <72231013+brent-moffit@users.noreply.github.com> Date: Mon, 14 Feb 2022 12:38:13 -0800 Subject: [PATCH 3/3] Add instant prompt for arch --- internal/p10k.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 965fd81..2adbc40 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -5635,6 +5635,8 @@ prompt_arch() { _p9k_prompt_segment "$0" "$_p9k_color1" "orange1" 'ARCH_ICON' 0 '' "$_p9k__cache_val[1]" } +instant_prompt_arch() { prompt_arch; } + _p9k_prompt_arch_init() { echo 'arch init' >> ~/p9k_debug.txt typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[arch]'