From 231a7b5f063d1992b103d1bf8c270bbadef05e30 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 31 Jul 2019 12:45:33 +0200 Subject: doc cleanup --- README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 551a0ee7..f6b71b8c 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ features Powerlevel10k has to offer. ## Fonts -Powerlevel10k doesn't require custom fonts but it can take advantage of them if they are available. +Powerlevel10k doesn't require custom fonts but can take advantage of them if they are available. It works well with [Nerd Fonts](https://github.com/ryanoasis/nerd-fonts), [Source Code Pro](https://github.com/adobe-fonts/source-code-pro), [Font Awesome](https://fontawesome.com/), [Powerline](https://github.com/powerline/fonts), and even @@ -212,17 +212,18 @@ This is the goal. You should be able to switch from Powerlevel9k to Powerlevel10 visible changes except for performance. There are, however, several differences. - By default only `git` vcs backend is enabled in Powerlevel10k. If you need `svn` and `hg`, you'll - need to set `POWERLEVEL9K_VCS_BACKENDS`. -- Powerlevel10k is bug-compatible with Powerlevel9k except for egregious bugs. If you accidentally - rely on these bugs, your prompt will differ between Powerlevel9k and Powerlevel10k. Some examples: + need to add them to `POWERLEVEL9K_VCS_BACKENDS`. +- Powerlevel10k strives to be bug-compatible with Powerlevel9k but not when it comes to egregious + bugs. If you accidentally rely on these bugs, your prompt will differ between Powerlevel9k and + Powerlevel10k. Some examples: - Powerlevel9k doesn't respect `ZLE_RPROMPT_INDENT`. As a result, right prompt in Powerlevel10k - can have an extra space compared to Powerlevel9k. Set `ZLE_RPROMPT_INDENT=0` if you don't want - that space. - - Powerlevel9k ignores some options that are set after the theme is sources while Powerlevel10k + can have an extra space at the end compared to Powerlevel9k. Set `ZLE_RPROMPT_INDENT=0` if you + don't want that space. + - Powerlevel9k ignores some options that are set after the theme is sourced while Powerlevel10k respects all options. If you see different icons in Powerlevel9k and Powerlevel10k, you've probably defined `POWERLEVEL9K_MODE` before sourcing the theme. This parameter gets ignored - by Powerlevel9k but not Powerlevel10k. If you want your prompt to look in Powerlevel10k the same - as in Powerlevel9k, remove `POWERLEVEL9K_MODE`. + by Powerlevel9k but honored by Powerlevel10k. If you want your prompt to look in Powerlevel10k + the same as in Powerlevel9k, remove `POWERLEVEL9K_MODE`. - There are [dozens more bugs](https://github.com/Powerlevel9k/powerlevel9k/issues/created_by/romkatv) in Powerlevel9k that don't exist in Powerlevel10k. -- cgit v1.2.3 From 98cd3a0b4bd3c7990c6c4075e239ebe890db0c5c Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 31 Jul 2019 12:46:57 +0200 Subject: show new screenshot in the docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f6b71b8c..d17ed4c3 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ configuration options it will generate [the same](#does-powerlevel10k-always-render-exactly-the-same-prompt-as-powerlevel9k-given-the-same-config) prompt. It will be [much faster](#is-it-really-fast) though. -![p10k-lean](https://raw.githubusercontent.com/romkatv/powerlevel10k/master/config/p10k-lean.png) +![Powerlevel10k](https://raw.githubusercontent.com/romkatv/powerlevel10k/master/powerlevel10k.png) ## Table of Contents -- cgit v1.2.3 From 0c0641d5798ab2985f1fc091336779a0c8c80fd1 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 31 Jul 2019 13:03:17 +0200 Subject: add a teardown hook for zplugin --- internal/p10k.zsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index b37fa2d0..4059bd87 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -4329,6 +4329,9 @@ prompt_powerlevel9k_teardown() { fi } +# Hook for zplugin. +powerlevel10k_plugin_unload() { prompt_powerlevel9k_teardown; } + autoload -Uz colors && colors autoload -Uz add-zsh-hook -- cgit v1.2.3 From db961be55813bc12cda53a4a49f528ec305e671f Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 31 Jul 2019 13:17:13 +0200 Subject: update headline --- README.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d17ed4c3..69bc641a 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,12 @@ # Powerlevel10k -Powerlevel10k is a theme for ZSH. It's a backward-compatible modern reimplementation of -[Powerlevel9k](https://github.com/bhilburn/powerlevel9k) with lower latency, better -prompt responsiveness and scores of extra features. +Powerlevel10k is a theme for ZSH. It's fast, flexible and easy to install and configure. -Powerlevel10k can be used as a drop-in replacement for Powerlevel9k. When given the same -configuration options it will generate +Powerlevel10k can be used as a [fast](#is-it-really-fast) drop-in replacement for +[Powerlevel9k](https://github.com/bhilburn/powerlevel9k). When given the same configuration options +it will generate [the same](#does-powerlevel10k-always-render-exactly-the-same-prompt-as-powerlevel9k-given-the-same-config) -prompt. It will be [much faster](#is-it-really-fast) though. +prompt. ![Powerlevel10k](https://raw.githubusercontent.com/romkatv/powerlevel10k/master/powerlevel10k.png) @@ -108,7 +107,7 @@ the default system fonts. The full choice of style options is available only whe Overwhelmed? Try the beautiful and powerful Meslo from Nerd Fonts. Download these [four ttf files](https://github.com/romkatv/dotfiles-public/tree/master/.local/share/fonts/NerdFonts), double-click on each and press "Install". This will make `MesloLGS NF` font available to all -applications on your system. Configure your terminal to use `MesloLGS NF`: +applications on your system. Configure your terminal to use this font: - **iTerm2**: Open *iTerm2 → Preferences → Profiles → Text → Change Font* and set *Family* to `MesloLGS NF`. - **Visual Studio Code**: Open *File → Preferences → Settings*, enter -- cgit v1.2.3 From aabb13e3bb4cffa371bbba923644ed18e4d65850 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 31 Jul 2019 14:10:28 +0200 Subject: add an option for an even lighter background color --- internal/wizard.zsh | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index d8ca2efd..a26de7df 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -33,10 +33,10 @@ source $__p9k_root_dir/internal/configure.zsh || return typeset -ri prompt_indent=2 -typeset -ra bg_color=(238 236 234) -typeset -ra frame_color=(242 240 238) -typeset -ra sep_color=(246 244 242) -typeset -ra prefix_color=(248 246 244) +typeset -ra bg_color=(240 238 236 234) +typeset -ra frame_color=(244 242 240 238) +typeset -ra sep_color=(248 246 244 242) +typeset -ra prefix_color=(250 248 246 244) typeset -r left_triangle='\uE0B2' typeset -r right_triangle='\uE0B0' @@ -312,34 +312,44 @@ function ask_style() { function ask_color() { [[ $style != classic ]] && return + if [[ $LINES -lt 26 ]]; then + local nl='' + else + local nl=$'\n' + fi while true; do clear centered "%BPrompt Color%b" - print -P "" - print -P "%B(1) Light.%b" - print -P "" + print -n $nl + print -P "%B(1) Lightest.%b" + print -n $nl color=1 print_prompt print -P "" - print -P "%B(2) Medium.%b" - print -P "" + print -P "%B(2) Light.%b" + print -n $nl color=2 print_prompt print -P "" print -P "%B(3) Dark.%b" - print -P "" + print -n $nl color=3 print_prompt print -P "" + print -P "%B(4) Darkest.%b" + print -n $nl + color=4 print_prompt + print -P "" print -P "(r) Restart from the beginning." print -P "(q) Quit and do nothing." print -P "" local key= - read -k key${(%):-"?%BChoice [123rq]: %b"} || quit + read -k key${(%):-"?%BChoice [1234rq]: %b"} || quit case $key in q) quit;; r) return 1;; - 1) color=1; options+=light; break;; - 2) color=2; options+=medium; break;; + 1) color=1; options+=lightest; break;; + 2) color=2; options+=light; break;; 3) color=3; options+=dark; break;; + 4) color=4; options+=darkest; break;; esac done } @@ -947,7 +957,7 @@ source $__p9k_root_dir/internal/icons.zsh || return while true; do local POWERLEVEL9K_MODE= style= config_backup= gap_char=' ' local left_subsep= right_subsep= left_tail= right_tail= left_head= right_head= - local -i num_lines=0 write_config=0 empty_line=0 color=1 left_frame=1 right_frame=1 + local -i num_lines=0 write_config=0 empty_line=0 color=2 left_frame=1 right_frame=1 local -i cap_diamond=0 cap_python=0 cap_narrow_icons=0 cap_lock=0 local -a extra_icons=('' '') local -a prefixes=('' '') -- cgit v1.2.3 From 4cdee85abd347f7785567d15df75b07547b34384 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 31 Jul 2019 14:57:19 +0200 Subject: enable nordvpn by default --- config/p10k-classic.zsh | 2 +- config/p10k-lean.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 66416a53..889d6618 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -57,9 +57,9 @@ fi # go_version # golang version kubecontext # current kubernetes context (https://kubernetes.io/) context # user@host + nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) # =========================[ Line #2 ]========================= newline - # nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) # public_ip # public IP address # battery # internal battery # time # current time diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 81a3f40d..6914c474 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -59,9 +59,9 @@ fi # go_version # golang version kubecontext # current kubernetes context (https://kubernetes.io/) context # user@host + nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) # =========================[ Line #2 ]========================= newline - # nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) # public_ip # public IP address # battery # internal battery # time # current time -- cgit v1.2.3 From 75d39fabd834044e6291b4a60787a9eca08859d0 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 31 Jul 2019 15:05:51 +0200 Subject: recommend p9k_configure after changing fonts --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 69bc641a..89b49005 100644 --- a/README.md +++ b/README.md @@ -120,8 +120,10 @@ sudo apt install libglib2.0-bin gsettings set org.gnome.desktop.interface monospace-font-name 'MesloLGS NF 11' ``` -(Using a different terminal and know how to set font for it? Share your knowledge by sending a PR -to expand the list!) +Run `p9k_configure` to pick the best style for your new font. + +_Using a different terminal and know how to set font for it? Share your knowledge by sending a PR +to expand the list!_ ## Try it in Docker -- cgit v1.2.3 From 095dd3236d92f4743913d0f07e55df646f6f42bd Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 31 Jul 2019 15:07:19 +0200 Subject: docs --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 89b49005..bb727497 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ prompt. 1. [Antibody](#antibody) 1. [Configuration](#configuration) 1. [For new users](#for-new-users) - 1. [For existing users](#for-existing-users) + 1. [For Powerlevel9k users](#for-powerlevel9k-users) 1. [Fonts](#fonts) 1. [Try it in Docker](#try-it-in-docker) 1. [Is it really faster?](#is-it-really-fast) @@ -85,7 +85,7 @@ Add `antibody bundle romkatv/powerlevel10k` to your `~/.zshrc`. On the first run Powerlevel10k configuration wizard will ask you a few questions and configure your prompt. If it doesn't trigger automatically, type `p9k_configure`. -### For existing users +### For Powerlevel9k users If you've been using Powerlevel9k before, **do not remove the configuration options**. Powerlevel10k will pick them up and provide you with the same prompt UI you are used to. Powerlevel10k recognized -- cgit v1.2.3 From 070697a91401e1fb06ca7affa306b303b6d7701c Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 31 Jul 2019 15:08:19 +0200 Subject: grammar --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bb727497..5e91f68f 100644 --- a/README.md +++ b/README.md @@ -92,8 +92,8 @@ will pick them up and provide you with the same prompt UI you are used to. Power all configuration options used by Powerlevel9k. See Powerlevel9k [configuration guide](https://github.com/bhilburn/powerlevel9k#prompt-customization). -To go beyond the functionality of Powerlevel9k, type `p9k_configure` and explore unique styles and -features Powerlevel10k has to offer. +To go beyond the functionality of Powerlevel9k, type `p9k_configure` and explore the unique styles +and features Powerlevel10k has to offer. ## Fonts -- cgit v1.2.3 From a6b572da4597626fb55b11abb9d3fb0dc255a5cd Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 31 Jul 2019 18:21:37 +0200 Subject: add p10k configure --- README.md | 6 +++--- config/p10k-pure.zsh | 2 +- internal/configure.zsh | 2 +- internal/p10k.zsh | 10 ++++++++++ internal/wizard.zsh | 6 +++--- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5e91f68f..1ff0bea0 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ Add `antibody bundle romkatv/powerlevel10k` to your `~/.zshrc`. ### For new users On the first run Powerlevel10k configuration wizard will ask you a few questions and configure -your prompt. If it doesn't trigger automatically, type `p9k_configure`. +your prompt. If it doesn't trigger automatically, type `p10k configure`. ### For Powerlevel9k users @@ -92,7 +92,7 @@ will pick them up and provide you with the same prompt UI you are used to. Power all configuration options used by Powerlevel9k. See Powerlevel9k [configuration guide](https://github.com/bhilburn/powerlevel9k#prompt-customization). -To go beyond the functionality of Powerlevel9k, type `p9k_configure` and explore the unique styles +To go beyond the functionality of Powerlevel9k, type `p10k configure` and explore the unique styles and features Powerlevel10k has to offer. ## Fonts @@ -120,7 +120,7 @@ sudo apt install libglib2.0-bin gsettings set org.gnome.desktop.interface monospace-font-name 'MesloLGS NF 11' ``` -Run `p9k_configure` to pick the best style for your new font. +Run `p10k configure` to pick the best style for your new font. _Using a different terminal and know how to set font for it? Share your knowledge by sending a PR to expand the list!_ diff --git a/config/p10k-pure.zsh b/config/p10k-pure.zsh index 271504e2..aa6e5b7f 100644 --- a/config/p10k-pure.zsh +++ b/config/p10k-pure.zsh @@ -11,7 +11,7 @@ # For example, just like in Pure, prompt will provide no indication of Git status being stale. # This is likely to make user experience worse than with any other Powerlevel10k config. If # you like the general style of Pure but not particularly attached to all its quirks, type -# `p9k_configure` while having Powerlevel10k theme active and pick lean style. +# `p10k configure` while having Powerlevel10k theme active and pick lean style. # Temporarily disable aliases. if [[ -o 'aliases' ]]; then diff --git a/internal/configure.zsh b/internal/configure.zsh index 9e676183..4dc8de1c 100644 --- a/internal/configure.zsh +++ b/internal/configure.zsh @@ -14,7 +14,7 @@ function _p9k_can_configure() { setopt err_return extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} [[ $1 == '-q' ]] && local -i q=1 || local -i q=0 function $0_error() { - (( q )) || print -P "%1F[ERROR]%f %Bp9k_configure%b: $1" >&2 + (( q )) || print -P "%1F[ERROR]%f %Bp10k configure%b: $1" >&2 return 1 } { diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 4059bd87..71a47362 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -4329,6 +4329,16 @@ prompt_powerlevel9k_teardown() { fi } +function p10k() { + emulate -L zsh && setopt no_hist_expand extended_glob + if [[ $# == 1 && $1 == configure ]]; then + p9k_configure + else + print -P "Usage: %2Fp10k%f %Bconfigure%b" >&2 + return 1 + fi +} + # Hook for zplugin. powerlevel10k_plugin_unload() { prompt_powerlevel9k_teardown; } diff --git a/internal/wizard.zsh b/internal/wizard.zsh index a26de7df..066be483 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -138,7 +138,7 @@ function quit() { if (( force )); then print -P "Powerlevel10k configuration wizard has been aborted. To run it again, type:" print -P "" - print -P " %2Fp9k_configure%f" + print -P " %2Fp10k%f %Bconfigure%b" print -P "" else print -P "Powerlevel10k configuration wizard has been aborted. It will run again" @@ -150,7 +150,7 @@ function quit() { print -P "" print -P "To run Powerlevel10k configuration wizard right now, type:" print -P "" - print -P " %2Fp9k_configure%f" + print -P " %2Fp10k%f %Bconfigure%b" print -P "" fi exit 1 @@ -936,7 +936,7 @@ function write_zshrc() { fi local comments=( - "# To customize prompt, run \`p9k_configure\` or edit $__p9k_cfg_path_u." + "# To customize prompt, run \`p10k configure\` or edit $__p9k_cfg_path_u." ) print -lr -- "" $comments "source $__p9k_cfg_path_u" >>$__p9k_zshrc -- cgit v1.2.3 From 6d11cb5f5da00ce00291941bcf2706997db2c1fb Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 31 Jul 2019 18:35:37 +0200 Subject: format options better --- internal/wizard.zsh | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 066be483..b528f5f4 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -277,7 +277,7 @@ function ask_narrow_icons() { q) quit;; r) return 1;; y) cap_narrow_icons=1; options+='small icons'; break;; - n) cap_narrow_icons=0; break;; + n) cap_narrow_icons=0; options+='large icons'; break;; esac done } @@ -417,7 +417,7 @@ function ask_prefixes() { case $key in q) quit;; r) return 1;; - 1) prefixes=('' ''); break;; + 1) prefixes=('' ''); options+=concise; break;; 2) prefixes=("$fluent[@]"); options+=fluent; break;; esac done @@ -461,7 +461,7 @@ function ask_separators() { right_sep=$left_triangle left_subsep=$right_angle right_subsep=$left_angle - options+='angled sep' + options+='angled separators' break ;; 2) @@ -469,7 +469,7 @@ function ask_separators() { right_sep='' left_subsep=$vertical_bar right_subsep=$vertical_bar - options+='vertical sep' + options+='vertical separators' break ;; 3) @@ -478,7 +478,7 @@ function ask_separators() { right_sep=$up_triangle left_subsep=$slanted_bar right_subsep=$slanted_bar - options+='slanted sep' + options+='slanted separators' break fi ;; @@ -910,8 +910,19 @@ function generate_config() { fi fi header+=$'.\n' - header+="# Wizard options: ${(j:, :)options}" - header+=$'.\n#' + local line="# Wizard options: $options[1]" + local opt + for opt in $options[2,-1]; do + if (( $#line + $#opt > 85 )); then + header+=$line + header+=$',\n' + line="# $opt" + else + line+=", $opt" + fi + done + header+=$line + header+=$'.\n# Type `p10k configure` to generate another config.\n#' if [[ -e $__p9k_cfg_path ]]; then unlink $__p9k_cfg_path || return 1 -- cgit v1.2.3 From 8d2ffb43db2a80254efb401d2f337f6404db8e03 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 31 Jul 2019 19:41:14 +0200 Subject: add "help" and "segment" commands to p10k --- config/p10k-classic.zsh | 4 +- config/p10k-lean.zsh | 4 +- internal/p10k.zsh | 252 ++++++++++++++++++++++++++++-------------------- 3 files changed, 153 insertions(+), 107 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 889d6618..baa380df 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -610,9 +610,9 @@ fi # prompt if `example` prompt segment is added to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and orange text greeting the user. # - # Type `p9k_prompt_segment -h` for documentation and a more sophisticated example. + # Type `p10k help segment` for documentation and a more sophisticated example. function prompt_example() { - p9k_prompt_segment -f 208 -i '⭐' -t 'hello, %n' + p10k segment -f 208 -i '⭐' -t 'hello, %n' } # User-defined prompt segments can be customized the same way as built-in segments. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 6914c474..e4451fc0 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -595,9 +595,9 @@ fi # prompt if `example` prompt segment is added to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and orange text greeting the user. # - # Type `p9k_prompt_segment -h` for documentation and a more sophisticated example. + # Type `p10k help segment` for documentation and a more sophisticated example. function prompt_example() { - p9k_prompt_segment -f 208 -i '⭐' -t 'hello, %n' + p10k segment -f 208 -i '⭐' -t 'hello, %n' } # User-defined prompt segments can be customized the same way as built-in segments. diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 71a47362..dcf07480 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -847,104 +847,7 @@ _p9k_right_prompt_segment() { } function _p9k_prompt_segment() { "_p9k_${_p9k_prompt_side}_prompt_segment" "$@" } - -typeset -gr __p9k_prompt_segment_usage="Usage: p9k_prompt_segment [{+|-}re] [-s state] [-b bg] [-f fg] [-i icon] [-c cond] [-t text] - -Options: - -t text segment's main content; will undergo prompt expansion: '%F{blue}%T%f' will - show as blue current time; default is empty - -i icon segment's icon; default is empty - -r icon is a symbolic reference that needs to be resolved; for example, 'LOCK_ICON' - +r icon is already resolved and should be printed literally; for example, '⭐'; - this is the default; you can also use $'\u2B50' if you don't want to have - non-ascii characters in source code - -b bg background color; for example, 'blue', '4', or '#0000ff'; empty value means - transparent background, as in '%k'; default is black - -f fg foreground color; for example, 'blue', '4', or '#0000ff'; empty value means - default foreground color, as in '%f'; default is empty - -s state segment's state for the purpose of applying styling options; if you want to - to be able to use POWERLEVEL9K parameters to specify different colors or icons - depending on some property, use different states for different values of that - property - -c condition; if empty after parameter expansion and process substitution, the - segment is hidden; this is an advanced feature, use with caution; default is '1' - -e segment's main content will undergo parameter expansion and process - substitution; the content will be surrounded with double quotes and thus - should quote its own double quotes; this is an advanced feature, use with - caution - +e segment's main content should not undergo parameter expansion and process - substitution; this is the default - -h print this help message and return - -Example: 'core' segment tells you if there is a file name 'core' in the current directory. - -- Segment's icon is '⭐'. -- Segment's text is the file's size in bytes. -- If you have permissions to delete the file, state is DELETABLE. If not, it's PROTECTED. - - zmodload -F zsh/stat b:zstat - - function prompt_core() { - local size=() - if ! zstat -A size +size core 2>/dev/null; then - # No 'core' file in the current directory. - return - fi - if [[ -w . ]]; then - local state=DELETABLE - else - local state=PROTECTED - fi - p9k_prompt_segment -s \$state -i '⭐' -b black -f blue -t \${size[1]}b - } - -To enable this segment, add 'core' to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or -POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. - -Example customizations: - - # Override foreground. - POWERLEVEL9K_CORE_FOREGROUND=red - - # Override background when DELETABLE. - POWERLEVEL9K_CORE_DELETABLE_BACKGROUND=green - - # Override icon when PROTECTED. - POWERLEVEL9K_CORE_PROTECTED_VISUAL_IDENTIFIER_EXPANSION='❎' - - # Don't show file size when PROTECTED. - POWERLEVEL9K_CORE_PROTECTED_CONTENT_EXPANSION=''" - -# Type `p9k_prompt_segment -h` for usage. -function p9k_prompt_segment() { - emulate -L zsh && setopt no_hist_expand extended_glob - local opt state bg=0 fg icon cond text ref=0 expand=0 - while getopts ':s:b:f:i:c:t:re' opt; do - case $opt in - s) state=$OPTARG;; - b) bg=$OPTARG;; - f) fg=$OPTARG;; - i) icon=$OPTARG;; - c) cond=${OPTARG:-'${:-}'};; - t) text=$OPTARG;; - r) ref=1;; - e) expand=1;; - +r) ref=0;; - +e) expand=0;; - ?) echo -E - $__p9k_prompt_segment_usage >&2; return 1;; - esac - done - if (( OPTIND <= ARGC )); then - echo -E - $__p9k_prompt_segment_usage >&2 - return 1 - fi - if [[ -n $_p9k_prompt_side ]]; then - (( ref )) || icon=$'\1'$icon - "_p9k_${_p9k_prompt_side}_prompt_segment" "prompt_${_p9k_segment_name}${state:+_${(U)state}}" \ - "$bg" "${fg:-$_p9k_color1}" "$icon" "$expand" "$cond" "$text" - fi - return 0 -} +function p9k_prompt_segment() { p10k segment "$@" } function _p9k_python_version() { _p9k_cached_cmd_stdout_stderr python --version || return @@ -4329,14 +4232,157 @@ prompt_powerlevel9k_teardown() { fi } + +typeset -gr __p9k_p10k_usage="Usage: %2Fp10k%f %Bcommand%b [options] + +Commands: + + %Bconfigure%b run interactive configuration wizard + %Bsegment%b print a user-defined prompt segment + %Bhelp%b print this help message" + +typeset -gr __p9k_p10k_segment_usage="Usage: %2Fp10k%f %Bsegment%b [{+|-}re] [-s state] [-b bg] [-f fg] [-i icon] [-c cond] [-t text] + +Print a user-defined prompt segment.%1F\$error%f + +Options: + -t text segment's main content; will undergo prompt expansion: '%%F{blue}%%*%%f' will + show as %F{blue}%*%f; default is empty + -i icon segment's icon; default is empty + -r icon is a symbolic reference that needs to be resolved; for example, 'LOCK_ICON' + +r icon is already resolved and should be printed literally; for example, '⭐'; + this is the default; you can also use \$'\u2B50' if you don't want to have + non-ascii characters in source code + -b bg background color; for example, 'blue', '4', or '#0000ff'; empty value means + transparent background, as in '%%k'; default is black + -f fg foreground color; for example, 'blue', '4', or '#0000ff'; empty value means + default foreground color, as in '%%f'; default is empty + -s state segment's state for the purpose of applying styling options; if you want to + to be able to use POWERLEVEL9K parameters to specify different colors or icons + depending on some property, use different states for different values of that + property + -c condition; if empty after parameter expansion and process substitution, the + segment is hidden; this is an advanced feature, use with caution; default is '1' + -e segment's main content will undergo parameter expansion and process + substitution; the content will be surrounded with double quotes and thus + should quote its own double quotes; this is an advanced feature, use with + caution + +e segment's main content should not undergo parameter expansion and process + substitution; this is the default + -h print this help message + +Example: 'core' segment tells you if there is a file name 'core' in the current directory. + +- Segment's icon is '⭐'. +- Segment's text is the file's size in bytes. +- If you have permissions to delete the file, state is DELETABLE. If not, it's PROTECTED. + + zmodload -F zsh/stat b:zstat + + function prompt_core() { + local size=() + if ! zstat -A size +size core 2>/dev/null; then + # No 'core' file in the current directory. + return + fi + if [[ -w . ]]; then + local state=DELETABLE + else + local state=PROTECTED + fi + p10k segment -s \\\\\$state -i '⭐' -b black -f blue -t \\\\\${size[1]}b + } + +To enable this segment, add 'core' to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or +POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. + +Example customizations: + + # Override foreground. + POWERLEVEL9K_CORE_FOREGROUND=red + + # Override background when DELETABLE. + POWERLEVEL9K_CORE_DELETABLE_BACKGROUND=green + + # Override icon when PROTECTED. + POWERLEVEL9K_CORE_PROTECTED_VISUAL_IDENTIFIER_EXPANSION='❎' + + # Don't show file size when PROTECTED. + POWERLEVEL9K_CORE_PROTECTED_CONTENT_EXPANSION=''" + +typeset -gr __p9k_p10k_configure_usage="Usage: %2Fp10k%f %Bconfigure%b + +Run interactive configuration wizard." + function p10k() { - emulate -L zsh && setopt no_hist_expand extended_glob - if [[ $# == 1 && $1 == configure ]]; then - p9k_configure - else - print -P "Usage: %2Fp10k%f %Bconfigure%b" >&2 + emulate -L zsh + setopt no_hist_expand extended_glob prompt_percent prompt_subst + + if (( !ARGC )); then + print -P -- $__p9k_p10k_usage >&2 return 1 fi + + local error + case $1 in + segment) + if [[ -z $_p9k_prompt_side ]]; then + error=' Can be called only when Powerlevel10k is rendering prompt.' + print -P -- $__p9k_p10k_segment_usage >&2 + return 1 + fi + shift + local opt state bg=0 fg icon cond text ref=0 expand=0 + while getopts ':s:b:f:i:c:t:reh' opt; do + case $opt in + s) state=$OPTARG;; + b) bg=$OPTARG;; + f) fg=$OPTARG;; + i) icon=$OPTARG;; + c) cond=${OPTARG:-'${:-}'};; + t) text=$OPTARG;; + r) ref=1;; + e) expand=1;; + +r) ref=0;; + +e) expand=0;; + h) print -P -- $__p9k_p10k_segment_usage; return 0;; + ?) print -P -- $__p9k_p10k_segment_usage >&2; return 1;; + esac + done + if (( OPTIND <= ARGC )); then + echo -E - $__p9k_p10k_segment_usage >&2 + return 1 + fi + (( ref )) || icon=$'\1'$icon + "_p9k_${_p9k_prompt_side}_prompt_segment" "prompt_${_p9k_segment_name}${state:+_${(U)state}}" \ + "$bg" "${fg:-$_p9k_color1}" "$icon" "$expand" "$cond" "$text" + return 0 + ;; + configure) + if (( ARGC > 1 )); then + print -P -- $__p9k_p10k_configure_usage >&2 + return 1 + fi + p9k_configure "$@" + ;; + help) + local var=__p9k_p10k_$2_usage + if (( $+parameters[$var] )); then + print -P -- ${(P)var} + return 0 + elif (( ARGC == 1 )); then + print -P -- $__p9k_p10k_usage + return 0 + else + print -P -- $__p9k_p10k_usage >&2 + return 1 + fi + ;; + *) + print -P -- $__p9k_p10k_usage >&2 + return 1 + ;; + esac } # Hook for zplugin. -- cgit v1.2.3 From 3fe113f91d0f819ad33c90608c3f293a1559324a Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 31 Jul 2019 19:54:49 +0200 Subject: better errors in p10k segment --- internal/p10k.zsh | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index dcf07480..d37dfb2c 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -4241,9 +4241,9 @@ Commands: %Bsegment%b print a user-defined prompt segment %Bhelp%b print this help message" -typeset -gr __p9k_p10k_segment_usage="Usage: %2Fp10k%f %Bsegment%b [{+|-}re] [-s state] [-b bg] [-f fg] [-i icon] [-c cond] [-t text] +typeset -gr __p9k_p10k_segment_usage="Usage: %2Fp10k%f %Bsegment%b [-h] [{+|-}re] [-s state] [-b bg] [-f fg] [-i icon] [-c cond] [-t text] -Print a user-defined prompt segment.%1F\$error%f +Print a user-defined prompt segment. Can be called only during prompt rendering. Options: -t text segment's main content; will undergo prompt expansion: '%%F{blue}%%*%%f' will @@ -4290,7 +4290,7 @@ Example: 'core' segment tells you if there is a file name 'core' in the current else local state=PROTECTED fi - p10k segment -s \\\\\$state -i '⭐' -b black -f blue -t \\\\\${size[1]}b + p10k segment -s \\\\\$state -i '⭐' -f blue -t \\\\\${size[1]}b } To enable this segment, add 'core' to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or @@ -4298,10 +4298,10 @@ POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. Example customizations: - # Override foreground. + # Override default foreground. POWERLEVEL9K_CORE_FOREGROUND=red - # Override background when DELETABLE. + # Override foreground when DELETABLE. POWERLEVEL9K_CORE_DELETABLE_BACKGROUND=green # Override icon when PROTECTED. @@ -4323,15 +4323,10 @@ function p10k() { return 1 fi - local error case $1 in segment) - if [[ -z $_p9k_prompt_side ]]; then - error=' Can be called only when Powerlevel10k is rendering prompt.' - print -P -- $__p9k_p10k_segment_usage >&2 - return 1 - fi shift + local -i num_opts=ARGC local opt state bg=0 fg icon cond text ref=0 expand=0 while getopts ':s:b:f:i:c:t:reh' opt; do case $opt in @@ -4350,7 +4345,17 @@ function p10k() { esac done if (( OPTIND <= ARGC )); then - echo -E - $__p9k_p10k_segment_usage >&2 + print -P -- $__p9k_p10k_segment_usage >&2 + return 1 + fi + if [[ -z $_p9k_prompt_side ]]; then + print -P -- "%1F[ERROR]%f %Bp10k segment%b: can be called only during prompt rendering." >&2 + if (( !ARGC )); then + print -P -- "" + print -P -- "For help, type:" >&2 + print -P -- "" + print -P -- " %2Fp10k%f %Bhelp%b %Bsegment%b" >&2 + fi return 1 fi (( ref )) || icon=$'\1'$icon -- cgit v1.2.3 From 37ab63fe694043fdd339c88c89418ec9174ba8f2 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 1 Aug 2019 15:09:39 +0200 Subject: bug fix: support color names in vcs style; fixes #144 --- internal/p10k.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index d37dfb2c..5fb6f6a4 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -375,16 +375,16 @@ _p9k_vcs_style() { local var=POWERLEVEL9K_VCS_${1}_${2}FORMAT_FOREGROUND if (( $+parameters[$var] )); then - _p9k_ret=${(P)var} + _p9k_translate_color "${(P)var}" else var=POWERLEVEL9K_VCS_${2}FORMAT_FOREGROUND if (( $+parameters[$var] )); then - _p9k_ret=${(P)var} + _p9k_translate_color "${(P)var}" else _p9k_color prompt_vcs_$1 FOREGROUND "$_p9k_color1" fi fi - + _p9k_foreground $_p9k_ret _p9k_ret=$style$_p9k_ret _p9k_cache[$key]=${_p9k_ret}. -- cgit v1.2.3 From 723d48d5c09951e93c5e7fe22228a79c5ece5dad Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 1 Aug 2019 19:23:40 +0200 Subject: font docs --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1ff0bea0..fe7f9b67 100644 --- a/README.md +++ b/README.md @@ -104,12 +104,12 @@ It works well with [Nerd Fonts](https://github.com/ryanoasis/nerd-fonts), the default system fonts. The full choice of style options is available only when using [Nerd Fonts](https://github.com/ryanoasis/nerd-fonts). -Overwhelmed? Try the beautiful and powerful Meslo from Nerd Fonts. Download these +Try the beautiful and powerful Meslo Nerd Font with extra patches for Powerlevel10k. Download these [four ttf files](https://github.com/romkatv/dotfiles-public/tree/master/.local/share/fonts/NerdFonts), double-click on each and press "Install". This will make `MesloLGS NF` font available to all applications on your system. Configure your terminal to use this font: -- **iTerm2**: Open *iTerm2 → Preferences → Profiles → Text → Change Font* and set *Family* to `MesloLGS NF`. +- **iTerm2**: Open *iTerm2 → Preferences → Profiles → Text* and set *Font* to `MesloLGS NF`. - **Visual Studio Code**: Open *File → Preferences → Settings*, enter `terminal.integrated.fontFamily` in the search box and set value to `MesloLGS NF`. - **Windows Command Prompt**: Use -- cgit v1.2.3 From 5a94a0c9ebd69349abfafae8fdab7f2c4e368210 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 1 Aug 2019 19:32:01 +0200 Subject: be less strict when detecting the presence of .p10k.zsh in .zshrc --- internal/wizard.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index b528f5f4..8f34fa1d 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -940,7 +940,7 @@ function write_zshrc() { local f5="'$f1'" local f6="\"$f1\"" local f7="\"$f3\"" - if [[ -n ${(@M)lines:#(#b)source[[:space:]]##($f1|$f2|$f3|$f4|$f5|$f6|$f7)*} ]]; then + if [[ -n ${(@M)lines:#(#b)[^#]#([^[:IDENT:]]|)source[[:space:]]##($f1|$f2|$f3|$f4|$f5|$f6|$f7)*} ]]; then print -P "No changes have been made to %4F$__p9k_zshrc_u%f because it already sources %2F$__p9k_cfg_path_u%f." return fi -- cgit v1.2.3 From a29b8264e51b402135943ab5a9d8790c8f6cd939 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 1 Aug 2019 20:03:34 +0200 Subject: source .p10k.zsh only if it exists --- internal/wizard.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 8f34fa1d..6d18f2ed 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -949,12 +949,12 @@ function write_zshrc() { local comments=( "# To customize prompt, run \`p10k configure\` or edit $__p9k_cfg_path_u." ) - print -lr -- "" $comments "source $__p9k_cfg_path_u" >>$__p9k_zshrc + print -lr -- "" $comments "[[ -f $__p9k_cfg_path_u ]] && source $__p9k_cfg_path_u" >>$__p9k_zshrc print -P "" print -P "The following lines have been appended to %4F$__p9k_zshrc_u%f:" print -P "" - print -lP -- ' '${^comments} " %2Fsource%f %B$__p9k_cfg_path_u%b" + print -lP -- ' '${^comments} " %3F[[%f %B-f $__p9k_cfg_path_u%b %3F]]%f && %2Fsource%f %B$__p9k_cfg_path_u%b" } if (( force )); then -- cgit v1.2.3 From ef7c9e5ccc97e9cd82b999f09e7bd15ff6ab3d10 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 1 Aug 2019 20:30:51 +0200 Subject: font docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fe7f9b67..48257617 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ It works well with [Nerd Fonts](https://github.com/ryanoasis/nerd-fonts), the default system fonts. The full choice of style options is available only when using [Nerd Fonts](https://github.com/ryanoasis/nerd-fonts). -Try the beautiful and powerful Meslo Nerd Font with extra patches for Powerlevel10k. Download these +**Recommended:** Meslo Nerd Font with extra patches for Powerlevel10k. Download these [four ttf files](https://github.com/romkatv/dotfiles-public/tree/master/.local/share/fonts/NerdFonts), double-click on each and press "Install". This will make `MesloLGS NF` font available to all applications on your system. Configure your terminal to use this font: -- cgit v1.2.3 From ebfe37b0b6b02c09f20833c4bc7cd325045099f7 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 1 Aug 2019 20:33:09 +0200 Subject: font docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 48257617..fd4651e9 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ It works well with [Nerd Fonts](https://github.com/ryanoasis/nerd-fonts), the default system fonts. The full choice of style options is available only when using [Nerd Fonts](https://github.com/ryanoasis/nerd-fonts). -**Recommended:** Meslo Nerd Font with extra patches for Powerlevel10k. Download these +**Recommended: Meslo Nerd Font patched for Powerlevel10k**. Download these [four ttf files](https://github.com/romkatv/dotfiles-public/tree/master/.local/share/fonts/NerdFonts), double-click on each and press "Install". This will make `MesloLGS NF` font available to all applications on your system. Configure your terminal to use this font: -- cgit v1.2.3 From 012a67aa38f3d79b4005379bd0063656595d6dc9 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 1 Aug 2019 20:40:31 +0200 Subject: extend faq --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index fd4651e9..013e6021 100644 --- a/README.md +++ b/README.md @@ -174,6 +174,18 @@ covered by the same license. ## FAQ +### Why my icons and/or powerline symbols look bad? + +It's likely your font's fault. [Install the recommended font](#fonts) and run `p10k configure`. + +### Why do I have a question mark symbol in my prompt? Is my font broken? + +If it looks like a regular `?`, that's normal. It means you have untracked files in the current Git +repository. Type `git status` to see these files. + +You can change this symbol by editing `~/.p10k.zsh`. Search for `?` and replace it with something +else. + ### Why does Powerlevel10k spawn extra processes? Powerlevel10k uses [gitstatus](https://github.com/romkatv/gitstatus) as the backend behind `vcs` -- cgit v1.2.3 From c6633f7171a354b5fa4842ea70c3e968404aa72e Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 1 Aug 2019 20:41:49 +0200 Subject: update toc --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 013e6021..aff4fdb1 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,8 @@ prompt. 1. [Is it really faster?](#is-it-really-fast) 1. [License](#license) 1. [FAQ](#faq) + 1. [Why my icons and/or powerline symbols look bad?](#why-my-icons-andor-powerline-symbols-look-bad) + 1. [Why do I have a question mark symbol in my prompt? Is my font broken?](#why-do-i-have-a-question-mark-symbol-in-my-prompt-is-my-font-broken) 1. [Why does Powerlevel10k spawn extra processes?](#why-does-powerlevel10k-spawn-extra-processes) 1. [Are there configuration options that make Powerlevel10k slow?](#are-there-configuration-options-that-make-powerlevel10k-slow) 1. [Is Powerlevel10k fast to load?](#is-powerlevel10k-fast-to-load) -- cgit v1.2.3 From fd64eaa6e5f35294d5feb79ec1c344cfd4c8b9fc Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 1 Aug 2019 20:44:06 +0200 Subject: style --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aff4fdb1..0fce4532 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ prompt. 1. [For new users](#for-new-users) 1. [For Powerlevel9k users](#for-powerlevel9k-users) 1. [Fonts](#fonts) + 1. [Recommended: Meslo Nerd Font patched for Powerlevel10k](#recommended-meslo-nerd-font-patched-for-powerlevel10k) 1. [Try it in Docker](#try-it-in-docker) 1. [Is it really faster?](#is-it-really-fast) 1. [License](#license) @@ -106,7 +107,9 @@ It works well with [Nerd Fonts](https://github.com/ryanoasis/nerd-fonts), the default system fonts. The full choice of style options is available only when using [Nerd Fonts](https://github.com/ryanoasis/nerd-fonts). -**Recommended: Meslo Nerd Font patched for Powerlevel10k**. Download these +### Recommended: Meslo Nerd Font patched for Powerlevel10k + +Install these [four ttf files](https://github.com/romkatv/dotfiles-public/tree/master/.local/share/fonts/NerdFonts), double-click on each and press "Install". This will make `MesloLGS NF` font available to all applications on your system. Configure your terminal to use this font: @@ -178,7 +181,9 @@ covered by the same license. ### Why my icons and/or powerline symbols look bad? -It's likely your font's fault. [Install the recommended font](#fonts) and run `p10k configure`. +It's likely your font's fault. +[Install the recommended font](#recommended-meslo-nerd-font-patched-for-powerlevel10k) and run +`p10k configure`. ### Why do I have a question mark symbol in my prompt? Is my font broken? -- cgit v1.2.3 From efde7bf6f9ad3db3b38d4a7d9ff9556c1c8ff87e Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 1 Aug 2019 20:44:52 +0200 Subject: grammar --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0fce4532..74587c64 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ the default system fonts. The full choice of style options is available only whe ### Recommended: Meslo Nerd Font patched for Powerlevel10k -Install these +Download these [four ttf files](https://github.com/romkatv/dotfiles-public/tree/master/.local/share/fonts/NerdFonts), double-click on each and press "Install". This will make `MesloLGS NF` font available to all applications on your system. Configure your terminal to use this font: -- cgit v1.2.3 From b6a365dd401882f86e50eb4536acfe43c3496bcf Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 1 Aug 2019 23:18:13 +0200 Subject: add P9K_NORDVPN_TECHNOLOGY --- internal/p10k.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 5fb6f6a4..b8e354f3 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -2901,6 +2901,7 @@ prompt_java_version() { typeset -gra __p9k_nordvpn_tag=( P9K_NORDVPN_STATUS + P9K_NORDVPN_TECHNOLOGY P9K_NORDVPN_PROTOCOL P9K_NORDVPN_IP_ADDRESS P9K_NORDVPN_SERVER @@ -2955,6 +2956,7 @@ function _p9k_fetch_nordvpn_status() { # # - P9K_NORDVPN_STATUS # - P9K_NORDVPN_PROTOCOL +# - P9K_NORDVPN_TECHNOLOGY # - P9K_NORDVPN_IP_ADDRESS # - P9K_NORDVPN_SERVER # - P9K_NORDVPN_COUNTRY -- cgit v1.2.3 From 99f631abb8ee5fdeb4a27a3ccfa794922266d409 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 1 Aug 2019 23:19:16 +0200 Subject: add rbenv to lean and classic configs (disabled until #146 is resolved) --- config/p10k-classic.zsh | 9 +++++++++ config/p10k-lean.zsh | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index baa380df..444c967d 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -55,6 +55,7 @@ fi nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) # node_version # node.js version # go_version # golang version + # rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) kubecontext # current kubernetes context (https://kubernetes.io/) context # user@host nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) @@ -497,6 +498,14 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## + # Rbenv color. + typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 + # Don't show ruby version if it's the same as global: $(rbenv version-name) == $(rbenv global). + typeset -g POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW=false + # Custom icon. + # typeset -g POWERLEVEL9K_RBENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# # Kubernetes context classes for the purpose of using different colors, icons and expansions with # different contexts. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index e4451fc0..5a94b43f 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -57,6 +57,7 @@ fi nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) # node_version # node.js version # go_version # golang version + # rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) kubecontext # current kubernetes context (https://kubernetes.io/) context # user@host nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) @@ -482,6 +483,14 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## + # Rbenv color. + typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 + # Don't show ruby version if it's the same as global: $(rbenv version-name) == $(rbenv global). + typeset -g POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW=false + # Custom icon. + # typeset -g POWERLEVEL9K_RBENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# # Kubernetes context classes for the purpose of using different colors, icons and expansions with # different contexts. -- cgit v1.2.3 From 0f00e5e9e26a19b393ba54aa03f6a947fa21bb65 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 2 Aug 2019 07:07:23 +0200 Subject: defend against global IFS leaks from other code; for #146 --- internal/p10k.zsh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index b8e354f3..324ca919 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -928,7 +928,7 @@ prompt_disk_usage() { function _p9k_read_file() { _p9k_ret='' - [[ -n $1 ]] && read -r _p9k_ret <$1 + [[ -n $1 ]] && IFS='' read -r _p9k_ret <$1 [[ -n $_p9k_ret ]] } @@ -1674,9 +1674,11 @@ prompt_node_version() { function _p9k_nvm_ls_default() { local v=default local -a seen=($v) - local target - while [[ -r $NVM_DIR/alias/$v ]] && read target <$NVM_DIR/alias/$v; do - [[ -n $target && ${seen[(I)$target]} == 0 ]] || return + while [[ -r $NVM_DIR/alias/$v ]]; do + local target= + IFS='' read -r target <$NVM_DIR/alias/$v + [[ -z $target ]] && break + (( $seen[(I)$target] )) && return seen+=$target v=$target done @@ -1886,9 +1888,8 @@ prompt_ram() { function _p9k_read_rbenv_version_file() { [[ -r $1 ]] || return - local content - read -r content <$1 2>/dev/null - _p9k_ret="${${(A)=content}[1]}" + local rest + read _p9k_ret rest <$1 2>/dev/null [[ -n $_p9k_ret ]] } @@ -2717,7 +2718,7 @@ prompt_virtualenv() { function _p9k_read_pyenv_version_file() { [[ -r $1 ]] || return local content - read -rd $'\0' content <$1 2>/dev/null + IFS='' read -rd $'\0' content <$1 2>/dev/null _p9k_ret=${${(j.:.)${(@)${=content}#python-}:-system}} } @@ -3025,6 +3026,8 @@ function _p9k_build_segment() { } function _p9k_set_prompt() { + local ifs=$IFS + IFS=$' \t\n\0' PROMPT=$_p9k_prompt_prefix_left RPROMPT= @@ -3103,6 +3106,7 @@ function _p9k_set_prompt() { _p9k_prompt_side= (( $#_p9k_cache < _POWERLEVEL9K_MAX_CACHE_SIZE )) || _p9k_cache=() + IFS=$ifs } function _p9k_update_prompt() { @@ -3352,7 +3356,7 @@ _p9k_init_async_pump() { cmd="$setsid zsh -dfxc ${(q)cmd} &!" zsh -dfmxc $cmd &$_p9k_async_pump_fd 2>/dev/null &! - read -t 5 -r -u $_p9k_async_pump_fd _p9k_async_pump_pid && (( _p9k_async_pump_pid )) + IFS='' read -t 5 -r -u $_p9k_async_pump_fd _p9k_async_pump_pid && (( _p9k_async_pump_pid )) _p9k_async_pump_subshell=$ZSH_SUBSHELL add-zsh-hook zshexit _p9k_kill_async_pump -- cgit v1.2.3 From a491e86d92a2cdd45373d0d16bb52ba6ec34366b Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 2 Aug 2019 07:32:22 +0200 Subject: beautify temp file name when printing it --- internal/wizard.zsh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 6d18f2ed..2d2ef2f6 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -787,8 +787,9 @@ function ask_config_overwrite() { q) quit;; r) return 1;; y) - config_backup="$(mktemp ${TMPDIR:-/tmp}/$__p9k_cfg_basename.XXXXXXXXXX)" || return 1 - cp $__p9k_cfg_path $config_backup + config_backup="$(mktemp ${TMPDIR:-/tmp}/$__p9k_cfg_basename.XXXXXXXXXX)" || exit 1 + cp $__p9k_cfg_path $config_backup || exit 1 + config_backup_u=${${TMPDIR:+\$TMPDIR}:-/tmp}/${(q-)config_backup:t} write_config=1 break ;; @@ -966,7 +967,7 @@ fi source $__p9k_root_dir/internal/icons.zsh || return while true; do - local POWERLEVEL9K_MODE= style= config_backup= gap_char=' ' + local POWERLEVEL9K_MODE= style= config_backup= config_backup_u= gap_char=' ' local left_subsep= right_subsep= left_tail= right_tail= left_head= right_head= local -i num_lines=0 write_config=0 empty_line=0 color=2 left_frame=1 right_frame=1 local -i cap_diamond=0 cap_python=0 cap_narrow_icons=0 cap_lock=0 @@ -1033,7 +1034,7 @@ clear print -P "Powerlevel10k configuration has been written to %2F$__p9k_cfg_path_u%f." if [[ -n $config_backup ]]; then - print -P "The backup of the previuos version is at %3F$config_backup%f." + print -P "The backup of the previuos version is at %3F$config_backup_u%f." fi if (( write_config )); then -- cgit v1.2.3 From caddad8e4fb77bc7438dcfed8f37a660b4516cc5 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 2 Aug 2019 09:02:07 +0200 Subject: update font instructions on windows --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 74587c64..da50ea49 100644 --- a/README.md +++ b/README.md @@ -117,8 +117,10 @@ applications on your system. Configure your terminal to use this font: - **iTerm2**: Open *iTerm2 → Preferences → Profiles → Text* and set *Font* to `MesloLGS NF`. - **Visual Studio Code**: Open *File → Preferences → Settings*, enter `terminal.integrated.fontFamily` in the search box and set value to `MesloLGS NF`. -- **Windows Command Prompt**: Use - [this script](https://gist.github.com/romkatv/aa7a70fe656d8b655e3c324eb10f6a8b). +- **Windows Command Prompt** (the old thing): Click the icon in the top left corner, then + *Properties → Font* and set *Font* to 'MesloLGS NF`. +- **Windows Terminal** (the new thing): Open *Settings* (`Ctrl+,`), search for `fontFace` and set + value to `MesloLGS NF` for every profile. - **Linux/GNOME** (all terminals): Type this command: ```zsh sudo apt install libglib2.0-bin -- cgit v1.2.3 From 9e9a6720e6dee0e6ec800da7408e341826c4e615 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 2 Aug 2019 09:17:30 +0200 Subject: style --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index da50ea49..4b188da6 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ applications on your system. Configure your terminal to use this font: - **Visual Studio Code**: Open *File → Preferences → Settings*, enter `terminal.integrated.fontFamily` in the search box and set value to `MesloLGS NF`. - **Windows Command Prompt** (the old thing): Click the icon in the top left corner, then - *Properties → Font* and set *Font* to 'MesloLGS NF`. + *Properties → Font* and set *Font* to `MesloLGS NF`. - **Windows Terminal** (the new thing): Open *Settings* (`Ctrl+,`), search for `fontFace` and set value to `MesloLGS NF` for every profile. - **Linux/GNOME** (all terminals): Type this command: -- cgit v1.2.3 From 635b0d7c99a22d996b5ca43efb56e9ec6b1ebdb4 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 2 Aug 2019 09:39:40 +0200 Subject: make it easier to change the untracked files icon; fixes #147 --- README.md | 4 ++-- config/p10k-classic.zsh | 28 +++++++++++++++------------- config/p10k-lean.zsh | 28 +++++++++++++++------------- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 4b188da6..09f1618d 100644 --- a/README.md +++ b/README.md @@ -192,8 +192,8 @@ It's likely your font's fault. If it looks like a regular `?`, that's normal. It means you have untracked files in the current Git repository. Type `git status` to see these files. -You can change this symbol by editing `~/.p10k.zsh`. Search for `?` and replace it with something -else. +You can change this symbol or disable the display of untracked files altogether. Search for +`untracked files` in `~/.p10k.zsh`. ### Why does Powerlevel10k spawn extra processes? diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 444c967d..cbb4de47 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -278,7 +278,10 @@ fi #####################################[ vcs: git status ]###################################### # Git status: feature:master#tag ⇣42⇡42 *42 merge ~42 +42 !42 ?42. - # We are using parameters defined by the gitstatus plugin. See reference: + # + # You can edit the lines below to customize how Git status looks. + # + # VCS_STATUS parameters are set by gitstatus plugin. See reference: # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. local vcs='' # 'feature' or '@72f5c8a' if not on a branch. @@ -303,14 +306,20 @@ fi vcs+='${${VCS_STATUS_NUM_STAGED:#0}:+ %227F+${VCS_STATUS_NUM_STAGED}}' # !42 if have unstaged changes. vcs+='${${VCS_STATUS_NUM_UNSTAGED:#0}:+ %227F!${VCS_STATUS_NUM_UNSTAGED}}' - # ?42 if have untracked files. - vcs+='${${VCS_STATUS_NUM_UNTRACKED:#0}:+ %39F?${VCS_STATUS_NUM_UNTRACKED}}' + # ?42 if have untracked files. It's really a question mark, your font isn't broken. + # See POWERLEVEL9K_VCS_UNTRACKED_ICON below if you want to use a different icon. + # Remove the next line if you don't want to see untracked files at all. + vcs+='${${VCS_STATUS_NUM_UNTRACKED:#0}:+ %39F${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}}' # If P9K_CONTENT is not empty, leave it unchanged. It's either "loading" or from vcs_info. vcs="\${P9K_CONTENT:-$vcs}" # Branch icon. Set this parameter to $'\uF126' for the popular Powerline branch icon. typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= + # Untracked files icon. It's really a question mark, your font isn't broken. + # Change the value of this parameter to show a different icon. + typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' + # Disable the default Git status formatting. typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true # Install our own Git status formatter. @@ -333,16 +342,9 @@ fi # These settings are used for respositories other than Git or when gitstatusd fails and # Powerlevel10k has to fall back to using vcs_info. - typeset -g POWERLEVEL9K_VCS_{CLEAN,MODIFIED,UNTRACKED}_FOREGROUND=76 - typeset -g POWERLEVEL9K_VCS_REMOTE_BRANCH_ICON=':' - typeset -g POWERLEVEL9K_VCS_COMMIT_ICON='@' - typeset -g POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON='⇣' - typeset -g POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON='⇡' - typeset -g POWERLEVEL9K_VCS_STASH_ICON='*' - typeset -g POWERLEVEL9K_VCS_TAG_ICON=$'%{\b#%}' - typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON=$'%{\b?%}' - typeset -g POWERLEVEL9K_VCS_UNSTAGED_ICON=$'%{\b!%}' - typeset -g POWERLEVEL9K_VCS_STAGED_ICON=$'%{\b+%}' + typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76 + typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=76 + typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=227 ##########################[ status: exit code of the last command ]########################### # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 5a94b43f..52dcdcf4 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -263,7 +263,10 @@ fi #####################################[ vcs: git status ]###################################### # Git status: feature:master#tag ⇣42⇡42 *42 merge ~42 +42 !42 ?42. - # We are using parameters defined by the gitstatus plugin. See reference: + # + # You can edit the lines below to customize how Git status looks. + # + # VCS_STATUS parameters are set by gitstatus plugin. See reference: # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. local vcs='' # 'feature' or '@72f5c8a' if not on a branch. @@ -288,14 +291,20 @@ fi vcs+='${${VCS_STATUS_NUM_STAGED:#0}:+ %227F+${VCS_STATUS_NUM_STAGED}}' # !42 if have unstaged changes. vcs+='${${VCS_STATUS_NUM_UNSTAGED:#0}:+ %227F!${VCS_STATUS_NUM_UNSTAGED}}' - # ?42 if have untracked files. - vcs+='${${VCS_STATUS_NUM_UNTRACKED:#0}:+ %39F?${VCS_STATUS_NUM_UNTRACKED}}' + # ?42 if have untracked files. It's really a question mark, your font isn't broken. + # See POWERLEVEL9K_VCS_UNTRACKED_ICON below if you want to use a different icon. + # Remove the next line if you don't want to see untracked files at all. + vcs+='${${VCS_STATUS_NUM_UNTRACKED:#0}:+ %39F${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}}' # If P9K_CONTENT is not empty, leave it unchanged. It's either "loading" or from vcs_info. vcs="\${P9K_CONTENT:-$vcs}" # Branch icon. Set this parameter to $'\uF126' for the popular Powerline branch icon. typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= + # Untracked files icon. It's really a question mark, your font isn't broken. + # Change the value of this parameter to show a different icon. + typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' + # Disable the default Git status formatting. typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true # Install our own Git status formatter. @@ -318,16 +327,9 @@ fi # These settings are used for respositories other than Git or when gitstatusd fails and # Powerlevel10k has to fall back to using vcs_info. - typeset -g POWERLEVEL9K_VCS_{CLEAN,MODIFIED,UNTRACKED}_FOREGROUND=76 - typeset -g POWERLEVEL9K_VCS_REMOTE_BRANCH_ICON=':' - typeset -g POWERLEVEL9K_VCS_COMMIT_ICON='@' - typeset -g POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON='⇣' - typeset -g POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON='⇡' - typeset -g POWERLEVEL9K_VCS_STASH_ICON='*' - typeset -g POWERLEVEL9K_VCS_TAG_ICON=$'%{\b#%}' - typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON=$'%{\b?%}' - typeset -g POWERLEVEL9K_VCS_UNSTAGED_ICON=$'%{\b!%}' - typeset -g POWERLEVEL9K_VCS_STAGED_ICON=$'%{\b+%}' + typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76 + typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=76 + typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=227 ##########################[ status: exit code of the last command ]########################### # Status on success. No content, just an icon. -- cgit v1.2.3 From 7565d00218a3897034a1e0078738806a530db30d Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 3 Aug 2019 11:54:19 +0200 Subject: disable nordvpn temporarily until #148 is resolved --- config/p10k-classic.zsh | 2 +- config/p10k-lean.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index cbb4de47..ac4750e8 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -58,7 +58,7 @@ fi # rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) kubecontext # current kubernetes context (https://kubernetes.io/) context # user@host - nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) + # nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) # =========================[ Line #2 ]========================= newline # public_ip # public IP address diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 52dcdcf4..6e998971 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -60,7 +60,7 @@ fi # rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) kubecontext # current kubernetes context (https://kubernetes.io/) context # user@host - nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) + # nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) # =========================[ Line #2 ]========================= newline # public_ip # public IP address -- cgit v1.2.3 From f62d1d5ae3f08c24fb002d25bc3ea1b1d5b782b8 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 5 Aug 2019 10:37:04 +0200 Subject: speciazled diagnostics for i686; more escapes; more opts --- internal/configure.zsh | 10 +-- internal/icons.zsh | 4 +- internal/p10k.zsh | 167 ++++++++++++++++++++++++++----------------------- internal/wizard.zsh | 26 ++++---- powerlevel9k.zsh-theme | 1 + 5 files changed, 109 insertions(+), 99 deletions(-) diff --git a/internal/configure.zsh b/internal/configure.zsh index 4dc8de1c..1c69fa85 100644 --- a/internal/configure.zsh +++ b/internal/configure.zsh @@ -1,26 +1,28 @@ typeset -gr __p9k_wizard_columns=76 typeset -gr __p9k_wizard_lines=21 typeset -gr __p9k_zd=${${ZDOTDIR:-$HOME}:A} -typeset -gr __p9k_zd_u=${${(q-)__p9k_zd}/#(#b)$HOME(|\/*)/'~'$match[1]} +typeset -gr __p9k_zd_u=${${${(q-)__p9k_zd}/#(#b)$HOME(|\/*)/'~'$match[1]}//\%/%%} typeset -gr __p9k_cfg_basename=.p10k.zsh typeset -gr __p9k_cfg_path=$__p9k_zd/$__p9k_cfg_basename typeset -gr __p9k_cfg_path_u=$__p9k_zd_u/$__p9k_cfg_basename typeset -gr __p9k_zshrc=$__p9k_zd/.zshrc typeset -gr __p9k_zshrc_u=$__p9k_zd_u/.zshrc -typeset -gr __p9k_root_dir_u=${${(q-)__p9k_root_dir}/#(#b)$HOME(|\/*)/'~'$match[1]} +typeset -gr __p9k_root_dir_u=${${${(q-)__p9k_root_dir}/#(#b)$HOME(|\/*)/'~'$match[1]}//\%/%%} function _p9k_can_configure() { emulate -L zsh setopt err_return extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} [[ $1 == '-q' ]] && local -i q=1 || local -i q=0 function $0_error() { - (( q )) || print -P "%1F[ERROR]%f %Bp10k configure%b: $1" >&2 + (( q )) || print -rP "%1F[ERROR]%f %Bp10k configure%b: $1" >&2 return 1 } { [[ -t 0 && -t 1 ]] || $0_error "no TTY" [[ -o multibyte ]] || $0_error "multibyte option is not set" - [[ "${#$(print -P '\u276F' 2>/dev/null)}" == 1 ]] || $0_error "shell doesn't support unicode" + [[ "${#$(print '\u276F' 2>/dev/null)}" == 1 ]] || $0_error "shell doesn't support unicode" + [[ -e $__p9k_zd ]] || $0_error "$__p9k_zd_u does not exist" + [[ -d $__p9k_zd ]] || $0_error "$__p9k_zd_u is not a directory" [[ -w $__p9k_zd ]] || $0_error "$__p9k_zd_u is not writable" [[ ! -d $__p9k_cfg_path ]] || $0_error "$__p9k_cfg_path_u is a directory" [[ ! -d $__p9k_zshrc ]] || $0_error "$__p9k_zshrc_u is a directory" diff --git a/internal/icons.zsh b/internal/icons.zsh index 57eb8ad8..af920bcc 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -519,7 +519,7 @@ function _p9k_init_icons() { # Sadly, this is a part of public API. Its use is emphatically discouraged. function print_icon() { - emulate -L zsh + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} _p9k_init_icons local icon_name=$1 local var_name=POWERLEVEL9K_${icon_name} @@ -536,7 +536,7 @@ function print_icon() { # otherwise "print_icon" is used, which takes the users # overrides into account. function get_icon_names() { - emulate -L zsh + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} _p9k_init_icons # Iterate over a ordered list of keys of the icons array for key in ${(@kon)icons}; do diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 324ca919..dcf3ff44 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -89,14 +89,14 @@ typeset -grA __p9k_colors=( # # Type `getColorCode background` or `getColorCode foreground` to see the list of predefined colors. function getColorCode() { - emulate -L zsh && setopt no_hist_expand extended_glob + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} if (( ARGC == 1 )); then case $1 in foreground) local k for k in "${(k@)__p9k_colors}"; do local v=${__p9k_colors[$k]} - print -P "%F{$v}$v - $k%f" + print -rP -- "%F{$v}$v - $k%f" done return ;; @@ -104,7 +104,7 @@ function getColorCode() { local k for k in "${(k@)__p9k_colors}"; do local v=${__p9k_colors[$k]} - print -P "%K{$v}$v - $k%k" + print -rP -- "%K{$v}$v - $k%k" done return ;; @@ -169,7 +169,7 @@ function _p9k_declare() { # _p9k_prompt_length '%F{red}abc' => 3 # _p9k_prompt_length $'%{a\b%Gb%}' => 1 function _p9k_prompt_length() { - emulate -L zsh && setopt no_hist_expand extended_glob + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} local COLUMNS=1024 local -i x y=$#1 m if (( y )); then @@ -2578,7 +2578,7 @@ function _p9k_vcs_render() { } function _p9k_vcs_resume() { - emulate -L zsh && setopt no_hist_expand extended_glob + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} if [[ $VCS_STATUS_RESULT == ok-async ]]; then local latency=$((EPOCHREALTIME - _p9k_gitstatus_start_time)) @@ -2615,7 +2615,6 @@ function _p9k_vcs_resume() { } function _p9k_vcs_gitstatus() { - (( _POWERLEVEL9K_DISABLE_GITSTATUS )) && return 1 if [[ $_p9k_refresh_reason == precmd ]]; then if (( $+_p9k_next_vcs_dir )); then _p9k_next_vcs_dir=${${GIT_DIR:a}:-$PWD} @@ -2658,7 +2657,7 @@ function _p9k_vcs_gitstatus() { prompt_vcs() { local -a backends=($_POWERLEVEL9K_VCS_BACKENDS) - if (( ${backends[(I)git]} )) && _p9k_vcs_gitstatus; then + if (( ${backends[(I)git]} && !_POWERLEVEL9K_DISABLE_GITSTATUS )) && _p9k_vcs_gitstatus; then _p9k_vcs_render && return backends=(${backends:#git}) fi @@ -3117,7 +3116,7 @@ function _p9k_update_prompt() { } powerlevel9k_refresh_prompt_inplace() { - emulate -L zsh && setopt no_hist_expand extended_glob + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} (( __p9k_enabled )) || return _p9k_refresh_reason=precmd _p9k_set_prompt @@ -3130,7 +3129,7 @@ typeset -gi __p9k_new_status typeset -ga __p9k_new_pipestatus _p9k_save_status() { - emulate -L zsh && setopt no_hist_expand extended_glob + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} local -i pipe if (( !$+_p9k_line_finished )); then : # SIGINT @@ -3216,6 +3215,7 @@ _p9k_precmd() { } function _p9k_zle_keymap_select() { + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} zle && zle .reset-prompt && zle -R } @@ -3245,7 +3245,7 @@ _p9k_deinit_async_pump() { } function _p9k_on_async_message() { - emulate -L zsh && setopt no_hist_expand extended_glob + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} (( ARGC == 1 )) || return local msg='' IFS='' while read -r -t -u $1 msg; do @@ -3258,10 +3258,11 @@ function _p9k_on_async_message() { } function _p9k_async_pump() { - emulate -L zsh || return - setopt noaliases no_hist_expand extended_glob || return - zmodload zsh/system zsh/datetime || return - echo $$ || return + emulate -L zsh || return + setopt no_aliases no_hist_expand extended_glob || return + setopt no_prompt_bang prompt_{cr,percent,subst,sp} || return + zmodload zsh/system zsh/datetime || return + echo $$ || return local ip last_ip local -F next_ip_time @@ -3320,7 +3321,7 @@ function _p9k_async_pump() { } function _p9k_kill_async_pump() { - emulate -L zsh && setopt no_hist_expand extended_glob + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} if (( ZSH_SUBSHELL == _p9k_async_pump_subshell )); then _p9k_deinit_async_pump fi @@ -3363,9 +3364,9 @@ _p9k_init_async_pump() { } if ! _p9k_start_async_pump ; then - >&2 print -P "%F{red}[ERROR]%f Powerlevel10k failed to start async worker. The following segments may malfunction: " - (( public_ip )) && >&2 print -P " - %F{green}public_ip%f" - (( time_realtime )) && >&2 print -P " - %F{green}time%f" + >&2 print -rP -- "%F{red}[ERROR]%f Powerlevel10k failed to start async worker. The following segments may malfunction: " + (( public_ip )) && >&2 print -rP -- " - %F{green}public_ip%f" + (( time_realtime )) && >&2 print -rP -- " - %F{green}time%f" _p9k_deinit_async_pump fi } @@ -3711,7 +3712,10 @@ _p9k_wrap_zle_widget() { function _p9k_zle_line_finish() { (( __p9k_enabled )) || return _p9k_line_finished= - (( _p9k_reset_on_line_finish )) && zle && zle .reset-prompt && zle -R + if (( _p9k_reset_on_line_finish )); then + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + zle && zle .reset-prompt && zle -R + fi } function _p9k_zle_line_pre_redraw() { @@ -3719,6 +3723,7 @@ function _p9k_zle_line_pre_redraw() { [[ ${KEYMAP:-} == vicmd ]] || return 0 local region=${${REGION_ACTIVE:-0}/2/1} [[ $region != $_p9k_region_active ]] || return 0 + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} _p9k_region_active=$region zle && zle .reset-prompt && zle -R } @@ -3733,8 +3738,8 @@ _p9k_build_gap_post() { local char=${_p9k_ret:- } _p9k_prompt_length $char if (( _p9k_ret != 1 || $#char != 1 )); then - print -P "%F{red}WARNING!%f %BMULTILINE_${(U)1}_PROMPT_GAP_CHAR%b is not one character long. Will use ' '." - print -P "Either change the value of %BPOWERLEVEL9K_MULTILINE_${(U)1}_PROMPT_GAP_CHAR%b or remove it." + print -rP -- "%F{red}WARNING!%f %BMULTILINE_${(U)1}_PROMPT_GAP_CHAR%b is not one character long. Will use ' '." + print -rP -- "Either change the value of %BPOWERLEVEL9K_MULTILINE_${(U)1}_PROMPT_GAP_CHAR%b or remove it." char=' ' fi local style @@ -3930,9 +3935,9 @@ _p9k_init_prompt() { _p9k_prompt_prefix_left+="\${(pl$sep$ruler_len$sep$sep${(q)ruler_char}$sep)}%k%f" _p9k_prompt_prefix_left+='$_p9k_t[$((1+!_p9k_ind))]' else - print -P "%F{red}WARNING!%f %BPOWERLEVEL9K_RULER_CHAR%b is not one character long. Ruler won't be rendered." - print -P "Either change the value of %BPOWERLEVEL9K_RULER_CHAR%b or set %BPOWERLEVEL9K_SHOW_RULER=false%b to" - print -P "disable ruler." + print -rP -- "%F{red}WARNING!%f %BPOWERLEVEL9K_RULER_CHAR%b is not one character long. Ruler won't be rendered." + print -rP -- "Either change the value of %BPOWERLEVEL9K_RULER_CHAR%b or set %BPOWERLEVEL9K_SHOW_RULER=false%b to" + print -rP -- "disable ruler." fi fi @@ -3977,7 +3982,7 @@ _p9k_init_ssh() { } _p9k_must_init() { - emulate -L zsh && setopt no_hist_expand extended_glob + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} local -a param_keys=( ${(o)parameters[(I)(POWERLEVEL9K_*|GITSTATUS_LOG_LEVEL|GITSTATUS_ENABLE_LOGGING|GITSTATUS_DAEMON|GITSTATUS_NUM_THREADS|DEFAULT_USER|ZLE_RPROMPT_INDENT)]}) local IFS param_sig @@ -3996,7 +4001,7 @@ function _p9k_set_os() { } _p9k_init() { - emulate -L zsh && setopt no_hist_expand extended_glob + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} _p9k_init_icons _p9k_init_vars @@ -4087,43 +4092,46 @@ _p9k_init() { fi done - if [[ -n $POWERLEVEL9K_RIGHT_SEGMENT_END_SEPARATOR ]]; then - print -P "%F{yellow}WARNING!%f %F{red}POWERLEVEL9K_RIGHT_SEGMENT_END_SEPARATOR%f is no longer supported!" - print -P "" - print -P "To fix your prompt, replace %F{red}POWERLEVEL9K_RIGHT_SEGMENT_END_SEPARATOR%f with" - print -P "%F{green}POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL%f." - print -P "" - print -P " %F{red} - POWERLEVEL9K_RIGHT_SEGMENT_END_SEPARATOR=${(qqq)${POWERLEVEL9K_RIGHT_SEGMENT_END_SEPARATOR//\%/%%}}%f" - print -P " %F{green} + POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL=${(qqq)${POWERLEVEL9K_RIGHT_SEGMENT_END_SEPARATOR//\%/%%}}%f" - if [[ -n $POWERLEVEL9K_LEFT_SEGMENT_END_SEPARATOR ]]; then - print -P "" - print -P "While at it, also replace %F{red}POWERLEVEL9K_LEFT_SEGMENT_END_SEPARATOR%f with" - print -P "%F{green}POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL%f. The new option, unlike" - print -P "the old, works correctly in multiline prompts." - print -P "" - print -P " %F{red} - POWERLEVEL9K_LEFT_SEGMENT_END_SEPARATOR=${(qqq)${POWERLEVEL9K_LEFT_SEGMENT_END_SEPARATOR//\%/%%}}%f" - print -P " %F{green} + POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=${(qqq)${POWERLEVEL9K_LEFT_SEGMENT_END_SEPARATOR//\%/%%}}%f" - fi - print -P "" - print -P "To get rid of this warning without changing the appearance of your prompt," - print -P "remove %F{red}POWERLEVEL9K_RIGHT_SEGMENT_END_SEPARATOR%f from your config" - fi - - if _p9k_segment_in_use longstatus; then - print -P '%F{yellow}WARNING!%f The "longstatus" segment is deprecated. Use "%F{blue}status%f" instead.' - print -P 'For more informations, have a look at https://github.com/bhilburn/powerlevel9k/blob/master/CHANGELOG.md.' - fi - if _p9k_segment_in_use vcs; then _p9k_vcs_info_init + local gitstatus_dir=${_POWERLEVEL9K_GITSTATUS_DIR:-${__p9k_root_dir}/gitstatus} if [[ $_POWERLEVEL9K_DISABLE_GITSTATUS == 0 && -n $_POWERLEVEL9K_VCS_BACKENDS[(r)git] ]]; then - source ${_POWERLEVEL9K_GITSTATUS_DIR:-${__p9k_root_dir}/gitstatus}/gitstatus.plugin.zsh - gitstatus_start \ - -s $_POWERLEVEL9K_VCS_STAGED_MAX_NUM \ - -u $_POWERLEVEL9K_VCS_UNSTAGED_MAX_NUM \ - -d $_POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM \ - -m $_POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY \ - POWERLEVEL9K + if [[ -z $GITSTATUS_DAEMON && "$(uname -m)" == i686 && -z $gitstatus_dir/bin/*-i686(-static|)(#qN) ]]; then + _POWERLEVEL9K_DISABLE_GITSTATUS=1 + >&2 echo -E - "${(%):-[%1FERROR%f]: %BPowerlevel10k%b is unable to use %Bgitstatus%b. Git prompt will be slow.}" + >&2 echo -E - "" + >&2 echo -E - "${(%):-Reason: There is no %Bgitstatusd%b binary for i686 (32-bit Intel architecture).}" + >&2 echo -E - "" + >&2 echo -E - "${(%):-You can:}" + >&2 echo -E - "" + >&2 echo -E - "${(%):- - Do nothing.}" + >&2 echo -E - "" + >&2 echo -E - "${(%):- * You %Bwill%b see this error message every time you start zsh.}" + >&2 echo -E - "${(%):- * Git prompt will be %Bslow%b.}" + >&2 echo -E - "" + >&2 echo -E - "${(%):- - Set %BPOWERLEVEL9K_DISABLE_GITSTATUS=true%b at the bottom of %B$__p9k_zshrc_u%b.}" + >&2 echo -E - "${(%):- You can do this by running the following command:}" + >&2 echo -E - "" + >&2 echo -E - "${(%):- %2Fecho%f %3F'POWERLEVEL9K_DISABLE_GITSTATUS=true'%f >>! $__p9k_zshrc_u}" + >&2 echo -E - "" + >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}" + >&2 echo -E - "${(%):- * Git prompt will be %Bslow%b.}" + >&2 echo -E - "" + >&2 echo -E - "${(%):- - Compile %Bgitstatusd%b and set %BGITSTATUS_DAEMON=/path/to/gitstatusd%b at}" + >&2 echo -E - "${(%):- the bottom of %B$__p9k_zshrc_u%b. See instructions at}" + >&2 echo -E - "${(%):- https://github.com/romkatv/gitstatus/blob/master/README.md#compiling.}" + >&2 echo -E - "" + >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}" + >&2 echo -E - "${(%):- * Git prompt will be %Bfast%b.}" + else + source $gitstatus_dir/gitstatus.plugin.zsh + gitstatus_start \ + -s $_POWERLEVEL9K_VCS_STAGED_MAX_NUM \ + -u $_POWERLEVEL9K_VCS_UNSTAGED_MAX_NUM \ + -d $_POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM \ + -m $_POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY \ + POWERLEVEL9K || _POWERLEVEL9K_DISABLE_GITSTATUS=1 + fi fi fi @@ -4179,8 +4187,8 @@ _p9k_init() { if _p9k_segment_in_use dir && [[ $_POWERLEVEL9K_SHORTEN_STRATEGY == truncate_with_package_name && $+commands[jq] == 0 ]]; then - >&2 print -P '%F{yellow}WARNING!%f %BPOWERLEVEL9K_SHORTEN_STRATEGY=truncate_with_package_name%b requires %F{green}jq%f.' - >&2 print -P 'Either install %F{green}jq%f or change the value of %BPOWERLEVEL9K_SHORTEN_STRATEGY%b.' + print -rP -- '%F{yellow}WARNING!%f %BPOWERLEVEL9K_SHORTEN_STRATEGY=truncate_with_package_name%b requires %F{green}jq%f.' + print -rP -- 'Either install %F{green}jq%f or change the value of %BPOWERLEVEL9K_SHORTEN_STRATEGY%b.' fi if (( !$+__p9k_char2byte )) && _p9k_segment_in_use nordvpn; then @@ -4219,7 +4227,7 @@ typeset -gi __p9k_enabled=0 typeset -gi __p9k_configured=0 prompt_powerlevel9k_setup() { - emulate -L zsh && setopt no_hist_expand extended_glob + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} prompt_powerlevel9k_teardown __p9k_enabled=1 add-zsh-hook preexec _p9k_preexec @@ -4227,7 +4235,7 @@ prompt_powerlevel9k_setup() { } prompt_powerlevel9k_teardown() { - emulate -L zsh && setopt no_hist_expand extended_glob + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} add-zsh-hook -D precmd '(_p9k_|powerlevel9k_)*' add-zsh-hook -D preexec '(_p9k_|powerlevel9k_)*' PROMPT='%m%# ' @@ -4238,7 +4246,6 @@ prompt_powerlevel9k_teardown() { fi } - typeset -gr __p9k_p10k_usage="Usage: %2Fp10k%f %Bcommand%b [options] Commands: @@ -4296,7 +4303,7 @@ Example: 'core' segment tells you if there is a file name 'core' in the current else local state=PROTECTED fi - p10k segment -s \\\\\$state -i '⭐' -f blue -t \\\\\${size[1]}b + p10k segment -s \\\$state -i '⭐' -f blue -t \\\${size[1]}b } To enable this segment, add 'core' to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or @@ -4325,7 +4332,7 @@ function p10k() { setopt no_hist_expand extended_glob prompt_percent prompt_subst if (( !ARGC )); then - print -P -- $__p9k_p10k_usage >&2 + print -rP -- $__p9k_p10k_usage >&2 return 1 fi @@ -4346,21 +4353,21 @@ function p10k() { e) expand=1;; +r) ref=0;; +e) expand=0;; - h) print -P -- $__p9k_p10k_segment_usage; return 0;; - ?) print -P -- $__p9k_p10k_segment_usage >&2; return 1;; + h) print -rP -- $__p9k_p10k_segment_usage; return 0;; + ?) print -rP -- $__p9k_p10k_segment_usage >&2; return 1;; esac done if (( OPTIND <= ARGC )); then - print -P -- $__p9k_p10k_segment_usage >&2 + print -rP -- $__p9k_p10k_segment_usage >&2 return 1 fi if [[ -z $_p9k_prompt_side ]]; then - print -P -- "%1F[ERROR]%f %Bp10k segment%b: can be called only during prompt rendering." >&2 + print -rP -- "%1F[ERROR]%f %Bp10k segment%b: can be called only during prompt rendering." >&2 if (( !ARGC )); then - print -P -- "" - print -P -- "For help, type:" >&2 - print -P -- "" - print -P -- " %2Fp10k%f %Bhelp%b %Bsegment%b" >&2 + print -rP -- "" + print -rP -- "For help, type:" >&2 + print -rP -- "" + print -rP -- " %2Fp10k%f %Bhelp%b %Bsegment%b" >&2 fi return 1 fi @@ -4371,7 +4378,7 @@ function p10k() { ;; configure) if (( ARGC > 1 )); then - print -P -- $__p9k_p10k_configure_usage >&2 + print -rP -- $__p9k_p10k_configure_usage >&2 return 1 fi p9k_configure "$@" @@ -4379,18 +4386,18 @@ function p10k() { help) local var=__p9k_p10k_$2_usage if (( $+parameters[$var] )); then - print -P -- ${(P)var} + print -rP -- ${(P)var} return 0 elif (( ARGC == 1 )); then - print -P -- $__p9k_p10k_usage + print -rP -- $__p9k_p10k_usage return 0 else - print -P -- $__p9k_p10k_usage >&2 + print -rP -- $__p9k_p10k_usage >&2 return 1 fi ;; *) - print -P -- $__p9k_p10k_usage >&2 + print -rP -- $__p9k_p10k_usage >&2 return 1 ;; esac diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 2d2ef2f6..ae8322a4 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -773,7 +773,7 @@ function ask_config_overwrite() { while true; do clear centered "Powerlevel10k config file already exists." - centered "%BOverwrite %b%2F$__p9k_cfg_path_u%f%B?%b" + centered "%BOverwrite %b%2F${__p9k_cfg_path_u//\\/\\\\}%f%B?%b" print -P "" print -P "%B(y) Yes.%b" print -P "" @@ -942,7 +942,7 @@ function write_zshrc() { local f6="\"$f1\"" local f7="\"$f3\"" if [[ -n ${(@M)lines:#(#b)[^#]#([^[:IDENT:]]|)source[[:space:]]##($f1|$f2|$f3|$f4|$f5|$f6|$f7)*} ]]; then - print -P "No changes have been made to %4F$__p9k_zshrc_u%f because it already sources %2F$__p9k_cfg_path_u%f." + print -rP "No changes have been made to %4F$__p9k_zshrc_u%f because it already sources %2F$__p9k_cfg_path_u%f." return fi fi @@ -950,12 +950,12 @@ function write_zshrc() { local comments=( "# To customize prompt, run \`p10k configure\` or edit $__p9k_cfg_path_u." ) - print -lr -- "" $comments "[[ -f $__p9k_cfg_path_u ]] && source $__p9k_cfg_path_u" >>$__p9k_zshrc + print -lrP -- "" $comments "[[ -f $__p9k_cfg_path_u ]] && source $__p9k_cfg_path_u" >>$__p9k_zshrc - print -P "" - print -P "The following lines have been appended to %4F$__p9k_zshrc_u%f:" - print -P "" - print -lP -- ' '${^comments} " %3F[[%f %B-f $__p9k_cfg_path_u%b %3F]]%f && %2Fsource%f %B$__p9k_cfg_path_u%b" + print -rP "" + print -rP "The following lines have been appended to %4F$__p9k_zshrc_u%f:" + print -rP "" + print -lrP -- ' '${^comments} " %3F[[%f %B-f $__p9k_cfg_path_u%b %3F]]%f && %2Fsource%f %B$__p9k_cfg_path_u%b" } if (( force )); then @@ -1032,9 +1032,9 @@ done clear -print -P "Powerlevel10k configuration has been written to %2F$__p9k_cfg_path_u%f." +print -rP "Powerlevel10k configuration has been written to %2F$__p9k_cfg_path_u%f." if [[ -n $config_backup ]]; then - print -P "The backup of the previuos version is at %3F$config_backup_u%f." + print -rP "The backup of the previuos version is at %3F$config_backup_u%f." fi if (( write_config )); then @@ -1043,9 +1043,9 @@ fi write_zshrc || return -print -P "" -print -P "File feature requests and bug reports at $(href https://github.com/romkatv/powerlevel10k/issues)." -print -P "Send praise and complaints to $(href https://www.reddit.com/r/zsh)." -print -P "" +print -rP "" +print -rP "File feature requests and bug reports at $(href https://github.com/romkatv/powerlevel10k/issues)." +print -rP "Send praise and complaints to $(href https://www.reddit.com/r/zsh)." +print -rP "" } "$@" diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 95bce71b..6bef5f39 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -19,6 +19,7 @@ fi () { emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} if (( $+__p9k_sourced )); then prompt_powerlevel9k_setup -- cgit v1.2.3 From d0fadfff9797af0badabe1507ff40b802eafd97d Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 5 Aug 2019 10:43:40 +0200 Subject: add another option for i686 users --- internal/p10k.zsh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index dcf3ff44..0068d1e8 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -4117,6 +4117,11 @@ _p9k_init() { >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}" >&2 echo -E - "${(%):- * Git prompt will be %Bslow%b.}" >&2 echo -E - "" + >&2 echo -E - "${(%):- - Upgrade to a 64-bit OS.}" + >&2 echo -E - "" + >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}" + >&2 echo -E - "${(%):- * Git prompt will be %Bfast%b.}" + >&2 echo -E - "" >&2 echo -E - "${(%):- - Compile %Bgitstatusd%b and set %BGITSTATUS_DAEMON=/path/to/gitstatusd%b at}" >&2 echo -E - "${(%):- the bottom of %B$__p9k_zshrc_u%b. See instructions at}" >&2 echo -E - "${(%):- https://github.com/romkatv/gitstatus/blob/master/README.md#compiling.}" -- cgit v1.2.3 From d8c509f5c92d850de92417c7fdad4ce7fcb18fb4 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 5 Aug 2019 11:17:34 +0200 Subject: require zsh 5.3 for nordvpn segment; fixes #148 --- config/p10k-classic.zsh | 2 +- config/p10k-lean.zsh | 2 +- internal/p10k.zsh | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index ac4750e8..cbb4de47 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -58,7 +58,7 @@ fi # rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) kubecontext # current kubernetes context (https://kubernetes.io/) context # user@host - # nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) + nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) # =========================[ Line #2 ]========================= newline # public_ip # public IP address diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 6e998971..52dcdcf4 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -60,7 +60,7 @@ fi # rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) kubecontext # current kubernetes context (https://kubernetes.io/) context # user@host - # nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) + nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) # =========================[ Line #2 ]========================= newline # public_ip # public IP address diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 0068d1e8..4196e18a 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -4196,7 +4196,8 @@ _p9k_init() { print -rP -- 'Either install %F{green}jq%f or change the value of %BPOWERLEVEL9K_SHORTEN_STRATEGY%b.' fi - if (( !$+__p9k_char2byte )) && _p9k_segment_in_use nordvpn; then + # There is no q+ flag before 5.3. + if (( !$+__p9k_char2byte )) && _p9k_segment_in_use nordvpn && is-at-least 5.3; then typeset -gA __p9k_char2byte=() local -i x=0 y=0 for x in {0..7}; do -- cgit v1.2.3 From 59e96984a1cde0c50a1c37e4b8ed9fe7b028b3c4 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 5 Aug 2019 20:23:30 +0200 Subject: be more tolerant towards misconfigured locales; users with non-utf-8 locales will still have broken shells but at least p10k will work --- config/p10k-classic.zsh | 34 +++++++++++++++------------------- config/p10k-lean.zsh | 33 ++++++++++++++------------------- internal/configure.zsh | 46 +++++++++++++++++++++++++++++----------------- internal/p10k.zsh | 8 ++++++++ internal/wizard.zsh | 1 + 5 files changed, 67 insertions(+), 55 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index cbb4de47..4946a28a 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -1,19 +1,12 @@ -# Config for Powerlevel10k with classic powerline prompt style. Requires a powerline font. -# The color scheme is suitable for dark terminal background. -# -# Once you've installed Powerlevel10k, run these commands to apply classic style. -# -# curl -fsSL -o ~/p10k-classic.zsh https://raw.githubusercontent.com/romkatv/powerlevel10k/master/config/p10k-classic.zsh -# echo 'source ~/p10k-classic.zsh' >>! ~/.zshrc -# -# To customize your prompt, open ~/p10k-classic.zsh in your favorite text editor, change it and -# restart ZSH. The file is well-documented. +# Config for Powerlevel10k with classic powerline prompt style. Type `p10k configure` to generate +# your own config based on it. # # Tip: Looking for a nice color? Here's a one-liner to print colormap. # # for i in {0..255}; do print -Pn "%${i}F${(l:3::0:)i}%f " ${${(M)$((i%8)):#7}:+$'\n'}; done if [[ -o 'aliases' ]]; then + # Temporarily disable aliases. 'builtin' 'unsetopt' 'aliases' local p9k_classic_restore_aliases=1 else @@ -23,6 +16,7 @@ fi () { emulate -L zsh setopt no_unset + local LC_ALL=C.UTF-8 # Unset all configuration options. This allows you to apply configiguration changes without # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. @@ -277,6 +271,13 @@ fi # typeset -g POWERLEVEL9K_DIR_CLASSES=() #####################################[ vcs: git status ]###################################### + # Branch icon. Set this parameter to '\uF126' for the popular Powerline branch icon. + typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= + + # Untracked files icon. It's really a question mark, your font isn't broken. + # Change the value of this parameter to show a different icon. + typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' + # Git status: feature:master#tag ⇣42⇡42 *42 merge ~42 +42 !42 ?42. # # You can edit the lines below to customize how Git status looks. @@ -285,7 +286,7 @@ fi # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. local vcs='' # 'feature' or '@72f5c8a' if not on a branch. - vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' + vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}'${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' vcs+=':-%f@%76F${VCS_STATUS_COMMIT[1,8]}}' # ':master' if the tracking branch name differs from local branch. vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%f:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}' @@ -309,17 +310,10 @@ fi # ?42 if have untracked files. It's really a question mark, your font isn't broken. # See POWERLEVEL9K_VCS_UNTRACKED_ICON below if you want to use a different icon. # Remove the next line if you don't want to see untracked files at all. - vcs+='${${VCS_STATUS_NUM_UNTRACKED:#0}:+ %39F${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}}' + vcs+='${${VCS_STATUS_NUM_UNTRACKED:#0}:+ %39F'${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}'${VCS_STATUS_NUM_UNTRACKED}}' # If P9K_CONTENT is not empty, leave it unchanged. It's either "loading" or from vcs_info. vcs="\${P9K_CONTENT:-$vcs}" - # Branch icon. Set this parameter to $'\uF126' for the popular Powerline branch icon. - typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= - - # Untracked files icon. It's really a question mark, your font isn't broken. - # Change the value of this parameter to show a different icon. - typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' - # Disable the default Git status formatting. typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true # Install our own Git status formatter. @@ -330,6 +324,8 @@ fi # Enable counters for staged, unstaged, etc. typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 + # Icon color. + typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76 # Custom icon. # typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION='⭐' # Custom prefix. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 52dcdcf4..8b994bbd 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -1,13 +1,5 @@ -# Config for Powerlevel10k with lean prompt style. Doesn't require a custom font but can take -# advantage of it if available. The color scheme is suitable for dark terminal background. -# -# Once you've installed Powerlevel10k, run these commands to apply lean style. -# -# curl -fsSL -o ~/p10k-lean.zsh https://raw.githubusercontent.com/romkatv/powerlevel10k/master/config/p10k-lean.zsh -# echo 'source ~/p10k-lean.zsh' >>! ~/.zshrc -# -# To customize your prompt, open ~/p10k-lean.zsh in your favorite text editor, change it and -# restart ZSH. The file is well-documented. +# Config for Powerlevel10k with classic powerline prompt style. Type `p10k configure` to generate +# your own config based on it. # # Tip: Looking for a nice color? Here's a one-liner to print colormap. # @@ -24,6 +16,7 @@ fi () { emulate -L zsh setopt no_unset + local LC_ALL=C.UTF-8 # Unset all configuration options. This allows you to apply configiguration changes without # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. @@ -262,6 +255,13 @@ fi # typeset -g POWERLEVEL9K_DIR_CLASSES=() #####################################[ vcs: git status ]###################################### + # Branch icon. Set this parameter to '\uF126' for the popular Powerline branch icon. + typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= + + # Untracked files icon. It's really a question mark, your font isn't broken. + # Change the value of this parameter to show a different icon. + typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' + # Git status: feature:master#tag ⇣42⇡42 *42 merge ~42 +42 !42 ?42. # # You can edit the lines below to customize how Git status looks. @@ -270,7 +270,7 @@ fi # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. local vcs='' # 'feature' or '@72f5c8a' if not on a branch. - vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' + vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}'${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' vcs+=':-%f@%76F${VCS_STATUS_COMMIT[1,8]}}' # ':master' if the tracking branch name differs from local branch. vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%f:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}' @@ -294,17 +294,10 @@ fi # ?42 if have untracked files. It's really a question mark, your font isn't broken. # See POWERLEVEL9K_VCS_UNTRACKED_ICON below if you want to use a different icon. # Remove the next line if you don't want to see untracked files at all. - vcs+='${${VCS_STATUS_NUM_UNTRACKED:#0}:+ %39F${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}}' + vcs+='${${VCS_STATUS_NUM_UNTRACKED:#0}:+ %39F'${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}'${VCS_STATUS_NUM_UNTRACKED}}' # If P9K_CONTENT is not empty, leave it unchanged. It's either "loading" or from vcs_info. vcs="\${P9K_CONTENT:-$vcs}" - # Branch icon. Set this parameter to $'\uF126' for the popular Powerline branch icon. - typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= - - # Untracked files icon. It's really a question mark, your font isn't broken. - # Change the value of this parameter to show a different icon. - typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' - # Disable the default Git status formatting. typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true # Install our own Git status formatter. @@ -315,6 +308,8 @@ fi # Enable counters for staged, unstaged, etc. typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 + # Icon color. + typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76 # Custom icon. # typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION='⭐' # Custom prefix. diff --git a/internal/configure.zsh b/internal/configure.zsh index 1c69fa85..5b054291 100644 --- a/internal/configure.zsh +++ b/internal/configure.zsh @@ -11,36 +11,48 @@ typeset -gr __p9k_root_dir_u=${${${(q-)__p9k_root_dir}/#(#b)$HOME(|\/*)/'~'$matc function _p9k_can_configure() { emulate -L zsh - setopt err_return extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} + setopt extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} [[ $1 == '-q' ]] && local -i q=1 || local -i q=0 function $0_error() { (( q )) || print -rP "%1F[ERROR]%f %Bp10k configure%b: $1" >&2 - return 1 } { - [[ -t 0 && -t 1 ]] || $0_error "no TTY" - [[ -o multibyte ]] || $0_error "multibyte option is not set" - [[ "${#$(print '\u276F' 2>/dev/null)}" == 1 ]] || $0_error "shell doesn't support unicode" - [[ -e $__p9k_zd ]] || $0_error "$__p9k_zd_u does not exist" - [[ -d $__p9k_zd ]] || $0_error "$__p9k_zd_u is not a directory" - [[ -w $__p9k_zd ]] || $0_error "$__p9k_zd_u is not writable" - [[ ! -d $__p9k_cfg_path ]] || $0_error "$__p9k_cfg_path_u is a directory" - [[ ! -d $__p9k_zshrc ]] || $0_error "$__p9k_zshrc_u is a directory" + [[ -t 0 && -t 1 ]] || { $0_error "no TTY"; return 1 } + [[ -o multibyte ]] || { $0_error "multibyte option is not set"; return 1 } + [[ -e $__p9k_zd ]] || { $0_error "$__p9k_zd_u does not exist"; return 1 } + [[ -d $__p9k_zd ]] || { $0_error "$__p9k_zd_u is not a directory"; return 1 } + [[ -w $__p9k_zd ]] || { $0_error "$__p9k_zd_u is not writable"; return 1 } + [[ ! -d $__p9k_cfg_path ]] || { $0_error "$__p9k_cfg_path_u is a directory"; return 1 } + [[ ! -d $__p9k_zshrc ]] || { $0_error "$__p9k_zshrc_u is a directory"; return 1 } - [[ ! -e $__p9k_cfg_path || -f $__p9k_cfg_path || -h $__p9k_cfg_path ]] || + [[ ! -e $__p9k_cfg_path || -f $__p9k_cfg_path || -h $__p9k_cfg_path ]] || { $0_error "$__p9k_cfg_path_u is a special file" - [[ -r $__p9k_root_dir/config/p10k-lean.zsh ]] || + return 1 + } + [[ -r $__p9k_root_dir/config/p10k-lean.zsh ]] || { $0_error "cannot read $__p9k_root_dir_u/config/p10k-lean.zsh" - [[ -r $__p9k_root_dir/config/p10k-classic.zsh ]] || + return 1 + } + [[ -r $__p9k_root_dir/config/p10k-classic.zsh ]] || { $0_error "cannot read $__p9k_root_dir_u/config/p10k-classic.zsh" - [[ ! -e $__p9k_zshrc || -f $__p9k_zshrc || -h $__p9k_zshrc ]] || + return 1 + } + [[ ! -e $__p9k_zshrc || -f $__p9k_zshrc || -h $__p9k_zshrc ]] || { $0_error "$__p9k_zshrc_u a special file" - [[ ! -e $__p9k_zshrc || -r $__p9k_zshrc ]] || + return 1 + } + [[ ! -e $__p9k_zshrc || -r $__p9k_zshrc ]] || { $0_error "$__p9k_zshrc_u is not readable" - [[ ! -e $__p9k_zshrc || -w $__p9k_zshrc ]] || + return 1 + } + [[ ! -e $__p9k_zshrc || -w $__p9k_zshrc ]] || { $0_error "$__p9k_zshrc_u is not writable" - (( LINES >= __p9k_wizard_lines && COLUMNS >= __p9k_wizard_columns )) || + return 1 + } + (( LINES >= __p9k_wizard_lines && COLUMNS >= __p9k_wizard_columns )) || { $0_error "terminal size too small; must be at least $__p9k_wizard_columns x $__p9k_wizard_lines" + return 1 + } } always { unfunction $0_error } diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 4196e18a..2a751e65 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -147,6 +147,7 @@ function _p9k_declare() { (( set )) && typeset -g _$2=${(P)2} || typeset -g _$2=$3 ;; -e) + local LC_ALL=C.UTF-8 if (( set )); then local v=${(P)2} typeset -g _$2=${(g::)v} @@ -329,6 +330,7 @@ _p9k_get_icon() { if [[ $_p9k_ret == $'\1'* ]]; then _p9k_ret=${_p9k_ret[2,-1]} else + local LC_ALL=C.UTF-8 _p9k_ret=${(g::)_p9k_ret} [[ $_p9k_ret != $'\b'? ]] || _p9k_ret="%{$_p9k_ret%}" # penance for past sins fi @@ -549,6 +551,7 @@ _p9k_left_prompt_segment() { p+='${${_p9k_e:#00}:+${${_p9k_t[$_p9k_n]/'$ss'/$_p9k_ss}/'$s'/$_p9k_s}' + local LC_ALL=C.UTF-8 _p9k_param $1 ICON_BEFORE_CONTENT '' if [[ $_p9k_ret != false ]]; then _p9k_param $1 PREFIX '' @@ -749,6 +752,7 @@ _p9k_right_prompt_segment() { p+='${${_p9k_e:#00}:+${_p9k_t[$_p9k_n]/'$w'/$_p9k_w}' + local LC_ALL=C.UTF-8 _p9k_param $1 ICON_BEFORE_CONTENT '' if [[ $_p9k_ret != true ]]; then _p9k_param $1 PREFIX '' @@ -1087,6 +1091,7 @@ prompt_context() { if [[ -z $content ]]; then local var=POWERLEVEL9K_CONTEXT_${state}_TEMPLATE if (( $+parameters[$var] )); then + local LC_ALL=C.UTF-8 content=${(P)var} content=${(g::)content} else @@ -3508,6 +3513,7 @@ _p9k_init_params() { if [[ $parameters[POWERLEVEL9K_BATTERY_STAGES] == scalar ]]; then _p9k_declare -e POWERLEVEL9K_BATTERY_STAGES else + local LC_ALL=C.UTF-8 _p9k_declare -a POWERLEVEL9K_BATTERY_STAGES -- _POWERLEVEL9K_BATTERY_STAGES=("${(@g::)_POWERLEVEL9K_BATTERY_STAGES}") fi @@ -3765,6 +3771,7 @@ _p9k_build_gap_post() { } _p9k_init_lines() { + local LC_ALL=C.UTF-8 local -a left_segments=($_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS) local -a right_segments=($_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS) @@ -4167,6 +4174,7 @@ _p9k_init() { if _p9k_segment_in_use dir; then if (( $+_POWERLEVEL9K_DIR_CLASSES )); then + local LC_ALL=C.UTF-8 local -i i=3 for ((; i <= $#_POWERLEVEL9K_DIR_CLASSES; i+=3)); do _POWERLEVEL9K_DIR_CLASSES[i]=${(g::)_POWERLEVEL9K_DIR_CLASSES[i]} diff --git a/internal/wizard.zsh b/internal/wizard.zsh index ae8322a4..c59e0edf 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -5,6 +5,7 @@ setopt noaliases () { setopt extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} +local LC_ALL=C.UTF-8 typeset -g __p9k_root_dir typeset -gi force=0 -- cgit v1.2.3 From 96b59dab349ee678112a1fe46eaad9e18b6eacc9 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 5 Aug 2019 22:23:39 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index 6750aa4a..a68614e4 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -273,7 +273,7 @@ function gitstatus_start() { local -i max_num_untracked=1 local -i dirty_max_index_size=-1 while true; do - getopts "t:s:u:d:m:" opt || break + getopts "t:s:u:c:d:m:" opt || break case $opt in t) timeout=$OPTARG;; s) max_num_staged=$OPTARG;; -- cgit v1.2.3 From 9d6dfeae736267a00c10dcae82e4a04ca72d4e4e Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 5 Aug 2019 22:26:23 +0200 Subject: add POWERLEVEL9K_VCS_CONFLICTED_MAX_NUM --- config/p10k-classic.zsh | 2 +- config/p10k-lean.zsh | 2 +- internal/p10k.zsh | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 4946a28a..b0fc9a86 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -322,7 +322,7 @@ fi typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION=${${vcs//\%f}//\%<->F} typeset -g POWERLEVEL9K_VCS_LOADING_FOREGROUND=244 # Enable counters for staged, unstaged, etc. - typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 + typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 # Icon color. typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76 diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 8b994bbd..ef9ab648 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -306,7 +306,7 @@ fi typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION=${${vcs//\%f}//\%<->F} typeset -g POWERLEVEL9K_VCS_LOADING_FOREGROUND=244 # Enable counters for staged, unstaged, etc. - typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 + typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 # Icon color. typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76 diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 2a751e65..aec5e24c 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3638,6 +3638,7 @@ _p9k_init_params() { _p9k_declare -i POWERLEVEL9K_VCS_STAGED_MAX_NUM 1 _p9k_declare -i POWERLEVEL9K_VCS_UNSTAGED_MAX_NUM 1 _p9k_declare -i POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM 1 + _p9k_declare -i POWERLEVEL9K_VCS_CONFLICTED_MAX_NUM 1 _p9k_declare -i POWERLEVEL9K_VCS_COMMITS_AHEAD_MAX_NUM -1 _p9k_declare -i POWERLEVEL9K_VCS_COMMITS_BEHIND_MAX_NUM -1 _p9k_declare -b POWERLEVEL9K_DISABLE_GITSTATUS 0 @@ -4141,6 +4142,7 @@ _p9k_init() { -s $_POWERLEVEL9K_VCS_STAGED_MAX_NUM \ -u $_POWERLEVEL9K_VCS_UNSTAGED_MAX_NUM \ -d $_POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM \ + -c $_POWERLEVEL9K_VCS_CONFLICTED_MAX_NUM \ -m $_POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY \ POWERLEVEL9K || _POWERLEVEL9K_DISABLE_GITSTATUS=1 fi -- cgit v1.2.3 From 36d2c588f12d1dd94949a9caadaf3d72cffb7444 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 6 Aug 2019 09:57:04 +0200 Subject: ignore zshexit hook calls done from forks --- internal/p10k.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index aec5e24c..25455796 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3246,6 +3246,8 @@ _p9k_deinit_async_pump() { rm -f $_p9k_async_pump_lock _p9k_async_pump_lock='' fi + _p9k_async_pump_subshell=-1 + _p9k_async_pump_shell_pid=-1 add-zsh-hook -D zshexit _p9k_kill_async_pump } @@ -3327,7 +3329,7 @@ function _p9k_async_pump() { function _p9k_kill_async_pump() { emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} - if (( ZSH_SUBSHELL == _p9k_async_pump_subshell )); then + if [[ $ZSH_SUBSHELL == $_p9k_async_pump_subshell && $$ == $_p9k_async_pump_shell_pid ]]; then _p9k_deinit_async_pump fi } @@ -3365,6 +3367,7 @@ _p9k_init_async_pump() { IFS='' read -t 5 -r -u $_p9k_async_pump_fd _p9k_async_pump_pid && (( _p9k_async_pump_pid )) _p9k_async_pump_subshell=$ZSH_SUBSHELL + _p9k_async_pump_shell_pid=$$ add-zsh-hook zshexit _p9k_kill_async_pump } @@ -3431,6 +3434,7 @@ _p9k_init_vars() { typeset -gi _p9k_async_pump_fd typeset -gi _p9k_async_pump_pid typeset -gi _p9k_async_pump_subshell + typeset -gi _p9k_async_pump_shell_pid typeset -ga _p9k_line_segments_left typeset -ga _p9k_line_segments_right typeset -ga _p9k_line_prefix_left -- cgit v1.2.3 From b4a2de947806b6b8232203e8246e2165791fc672 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 6 Aug 2019 09:57:33 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index a68614e4..ce227f60 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -385,16 +385,16 @@ function gitstatus_start() { read -r -d $'\x1e' -u $resp_fd -t $timeout reply [[ $reply == $'hello\x1f0' ]] - function _gitstatus_cleanup_${ZSH_SUBSHELL}_${daemon_pid}() { + function _gitstatus_cleanup_$$_${ZSH_SUBSHELL}_${daemon_pid}() { emulate -L zsh setopt err_return no_unset local fname=${(%):-%N} - local prefix=_gitstatus_cleanup_${ZSH_SUBSHELL}_ + local prefix=_gitstatus_cleanup_$$_${ZSH_SUBSHELL}_ [[ $fname == ${prefix}* ]] || return 0 local -i daemon_pid=${fname#$prefix} kill -- -$daemon_pid &>/dev/null || true } - add-zsh-hook zshexit _gitstatus_cleanup_${ZSH_SUBSHELL}_${daemon_pid} + add-zsh-hook zshexit _gitstatus_cleanup_$$_${ZSH_SUBSHELL}_${daemon_pid} [[ $stderr_fd == -1 ]] || { unsetopt xtrace @@ -413,7 +413,7 @@ function gitstatus_start() { unset -f gitstatus_start_impl } || { unsetopt err_return - add-zsh-hook -d zshexit _gitstatus_cleanup_${ZSH_SUBSHELL}_${daemon_pid} + add-zsh-hook -d zshexit _gitstatus_cleanup_$$_${ZSH_SUBSHELL}_${daemon_pid} [[ $daemon_pid -gt 0 ]] && kill -- -$daemon_pid &>/dev/null [[ $stderr_fd -ge 0 ]] && { exec 2>&$stderr_fd {stderr_fd}>&- } [[ $lock_fd -ge 0 ]] && zsystem flock -u $lock_fd @@ -482,7 +482,7 @@ function gitstatus_stop() { local lock_fd=${(P)lock_fd_var:-} local daemon_pid=${(P)daemon_pid_var:-} - local cleanup_func=_gitstatus_cleanup_${ZSH_SUBSHELL}_${daemon_pid} + local cleanup_func=_gitstatus_cleanup_$$_${ZSH_SUBSHELL}_${daemon_pid} [[ -n $daemon_pid ]] && kill -- -$daemon_pid &>/dev/null [[ -n $req_fd ]] && exec {req_fd}>&- -- cgit v1.2.3 From 90caf479e0e1ec0ad95f985e2d161c8b6bf2ea36 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 6 Aug 2019 10:21:21 +0200 Subject: add FAQ about the python logo not rendering in the wizard; fixes #151 --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 09f1618d..f9692145 100644 --- a/README.md +++ b/README.md @@ -195,6 +195,15 @@ repository. Type `git status` to see these files. You can change this symbol or disable the display of untracked files altogether. Search for `untracked files` in `~/.p10k.zsh`. +### I've installed the recommended font but I still don't see the Python logo in the configuration wizard. + +When using a font from Nerd Fonts such as +[the recommended font](#recommended-meslo-nerd-font-patched-for-powerlevel10k), the Python logo +isn't supposed to render _in the configuration wizard_. Your telling the wizard that the logo +doesn't render effectively says that you are using Nerd Fonts. As long as you correctly tell the +wizard which icons render and which don't, it'll be able to figure out which font you are using. +You'll get all icons in your prompt, including the Python logo. + ### Why does Powerlevel10k spawn extra processes? Powerlevel10k uses [gitstatus](https://github.com/romkatv/gitstatus) as the backend behind `vcs` -- cgit v1.2.3 From ad14a651657cfdd5a7a63ab9f4ee1e4b32466e97 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 6 Aug 2019 10:22:12 +0200 Subject: update toc --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f9692145..94e8e5b8 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ prompt. 1. [FAQ](#faq) 1. [Why my icons and/or powerline symbols look bad?](#why-my-icons-andor-powerline-symbols-look-bad) 1. [Why do I have a question mark symbol in my prompt? Is my font broken?](#why-do-i-have-a-question-mark-symbol-in-my-prompt-is-my-font-broken) + 1. [I've installed the recommended font but I still don't see the Python logo in the configuration wizard.](#ive-installed-the-recommended-font-but-i-still-dont-see-the-python-logo-in-the-configuration-wizard) 1. [Why does Powerlevel10k spawn extra processes?](#why-does-powerlevel10k-spawn-extra-processes) 1. [Are there configuration options that make Powerlevel10k slow?](#are-there-configuration-options-that-make-powerlevel10k-slow) 1. [Is Powerlevel10k fast to load?](#is-powerlevel10k-fast-to-load) -- cgit v1.2.3 From fb1e7a689c35537c169a796c718569a82d472b02 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 6 Aug 2019 13:05:17 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/bin/gitstatusd-freebsd-amd64 | Bin 3252072 -> 3258248 bytes gitstatus/gitstatus.plugin.zsh | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/gitstatus/bin/gitstatusd-freebsd-amd64 b/gitstatus/bin/gitstatusd-freebsd-amd64 index 20d77a41..7a39061a 100755 Binary files a/gitstatus/bin/gitstatusd-freebsd-amd64 and b/gitstatus/bin/gitstatusd-freebsd-amd64 differ diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index ce227f60..e897128b 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -359,7 +359,7 @@ function gitstatus_start() { echo -nE $'bye\x1f0\x1e'" local setsid=${commands[setsid]:-/usr/local/opt/util-linux/bin/setsid} [[ -f $setsid ]] && setsid=${(q)setsid} || setsid= - cmd="$setsid zsh -dfxc ${(q)cmd} &!" + cmd="cd /; $setsid zsh -dfxc ${(q)cmd} &!" # We use `zsh -c` instead of plain {} or () to work around bugs in zplug. It hangs on startup. # Double fork is to daemonize. Some macOS users had issues when gitstatusd was a child process # of the interactive zsh. For example, https://github.com/romkatv/powerlevel10k/issues/123 -- cgit v1.2.3 From 58fa653b903df0efd825809fad73015cd73daa50 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 7 Aug 2019 08:38:04 +0200 Subject: don't trust $PWD as it can be changed; use ${(%):-%/} instead It's possible that #156 is caused by some code changing PWD. --- internal/p10k.zsh | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 25455796..017b5c23 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1200,7 +1200,7 @@ function _p9k_shorten_delim_len() { ################################################################ # Dir: current working directory prompt_dir() { - (( _POWERLEVEL9K_DIR_PATH_ABSOLUTE )) && local p=$PWD || local p=${(%):-%~} + (( _POWERLEVEL9K_DIR_PATH_ABSOLUTE )) && local p=$_p9k_pwd || local p=${(%):-%~} if [[ $p == '~['* ]]; then # If "${(%):-%~}" expands to "~[a]/]/b", is the first component "~[a]" or "~[a]/]"? @@ -1211,7 +1211,7 @@ prompt_dir() { local func='' local -a parts=() for func in zsh_directory_name $zsh_directory_name_functions; do - if (( $+functions[$func] )) && $func d $PWD && [[ $p == '~['$reply[1]']'* ]]; then + if (( $+functions[$func] )) && $func d $_p9k_pwd && [[ $p == '~['$reply[1]']'* ]]; then parts+='~['$reply[1]']' break fi @@ -1219,7 +1219,7 @@ prompt_dir() { if (( $#parts )); then parts+=(${(s:/:)${p#$parts[1]}}) else - p=$PWD + p=$_p9k_pwd parts=("${(s:/:)p}") fi else @@ -1258,7 +1258,7 @@ prompt_dir() { $+commands[jq] == 1 && $#_POWERLEVEL9K_DIR_PACKAGE_FILES > 0 ]] || return local pat="(${(j:|:)_POWERLEVEL9K_DIR_PACKAGE_FILES})" local -i i=$#parts - local dir=$PWD + local dir=$_p9k_pwd for (( ; i > 0; --i )); do local pkg_file='' for pkg_file in $dir/${~pat}(N); do @@ -1308,7 +1308,7 @@ prompt_dir() { delim=${_POWERLEVEL9K_SHORTEN_DELIMITER-'*'} local -i i=2 [[ $p[1] == / ]] && (( ++i )) - local parent="${PWD%/${(pj./.)parts[i,-1]}}" + local parent="${_p9k_pwd%/${(pj./.)parts[i,-1]}}" if (( i <= $#parts )); then local mtime=() zstat -A mtime +mtime -- ${(@)${:-{$i..$#parts}}/(#b)(*)/$parent/${(pj./.)parts[i,$match[1]]}} 2>/dev/null || mtime=() @@ -1362,7 +1362,7 @@ prompt_dir() { ;; truncate_with_folder_marker) if [[ -n $_POWERLEVEL9K_SHORTEN_FOLDER_MARKER ]]; then - local dir=$PWD + local dir=$_p9k_pwd local -a m=() local -i i=$(($#parts - 1)) for (( ; i > 1; --i )); do @@ -1386,9 +1386,9 @@ prompt_dir() { ;; esac - [[ $_POWERLEVEL9K_DIR_SHOW_WRITABLE == 1 && ! -w $PWD ]] + [[ $_POWERLEVEL9K_DIR_SHOW_WRITABLE == 1 && ! -w $_p9k_pwd ]] local w=$? - if ! _p9k_cache_get $0 $PWD $w $fake_first "${parts[@]}"; then + if ! _p9k_cache_get $0 $_p9k_pwd $w $fake_first "${parts[@]}"; then local state=$0 local icon='' if (( ! w )); then @@ -1397,7 +1397,7 @@ prompt_dir() { else local a='' b='' c='' for a b c in "${_POWERLEVEL9K_DIR_CLASSES[@]}"; do - if [[ $PWD == ${~a} ]]; then + if [[ $_p9k_pwd == ${~a} ]]; then [[ -n $b ]] && state+=_${(U)b} icon=$'\1'$c break @@ -1485,7 +1485,7 @@ prompt_dir() { local content="${(pj.$sep.)parts}" if (( _POWERLEVEL9K_DIR_HYPERLINK )); then - local pref=$'%{\e]8;;file://'${${PWD//\%/%%25}//'#'/%%23}$'\a%}' + local pref=$'%{\e]8;;file://'${${_p9k_pwd//\%/%%25}//'#'/%%23}$'\a%}' local suf=$'%{\e]8;;\a%}' if (( expand )); then _p9k_escape $pref @@ -1535,8 +1535,8 @@ prompt_go_version() { p="$(go env GOPATH 2>/dev/null)" && [[ -n $p ]] || return fi fi - if [[ $PWD/ != $p/* ]]; then - local dir=$PWD + if [[ $_p9k_pwd/ != $p/* ]]; then + local dir=$_p9k_pwd while [[ ! -e $dir/go.mod ]]; do [[ $dir == / ]] && return dir=${dir:h} @@ -1662,7 +1662,7 @@ prompt_node_version() { (( $+commands[node] )) || return if (( _POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY )); then - local dir=$PWD + local dir=$_p9k_pwd while true; do [[ $dir == / ]] && return [[ -e $dir/package.json ]] && break @@ -1821,7 +1821,7 @@ prompt_nodenv() { (( $+commands[nodenv] )) || return _p9k_ret=$NODENV_VERSION if [[ -z $_p9k_ret ]]; then - [[ $NODENV_DIR == /* ]] && local dir=$NODENV_DIR || local dir="$PWD/$NODENV_DIR" + [[ $NODENV_DIR == /* ]] && local dir=$NODENV_DIR || local dir="$_p9k_pwd/$NODENV_DIR" while [[ $dir != //[^/]# ]]; do _p9k_read_nodenv_version_file $dir/.node-version && break [[ $dir == / ]] && break @@ -1909,7 +1909,7 @@ prompt_rbenv() { (( $+commands[rbenv] )) || return local v=$RBENV_VERSION if [[ -z $v ]]; then - [[ $RBENV_DIR == /* ]] && local dir=$RBENV_DIR || local dir="$PWD/$RBENV_DIR" + [[ $RBENV_DIR == /* ]] && local dir=$RBENV_DIR || local dir="$_p9k_pwd/$RBENV_DIR" while true; do if _p9k_read_rbenv_version_file $dir/.ruby-version; then v=$_p9k_ret @@ -2428,7 +2428,7 @@ function _p9k_vcs_render() { local state if (( $+_p9k_next_vcs_dir )); then - if _p9k_vcs_status_for_dir ${${GIT_DIR:a}:-$PWD}; then + if _p9k_vcs_status_for_dir ${${GIT_DIR:A}:-$_p9k_pwd_a}; then _p9k_vcs_status_restore $_p9k_ret state=LOADING else @@ -2598,8 +2598,8 @@ function _p9k_vcs_resume() { if [[ -z $_p9k_next_vcs_dir ]]; then unset _p9k_next_vcs_dir case $VCS_STATUS_RESULT in - norepo-async) (( $1 )) && _p9k_vcs_status_purge ${${GIT_DIR:a}:-$PWD};; - ok-async) (( $1 )) || _p9k_next_vcs_dir=${${GIT_DIR:a}:-$PWD};; + norepo-async) (( $1 )) && _p9k_vcs_status_purge ${${GIT_DIR:A}:-$_p9k_pwd_a};; + ok-async) (( $1 )) || _p9k_next_vcs_dir=${${GIT_DIR:A}:-$_p9k_pwd_a};; esac fi @@ -2622,9 +2622,9 @@ function _p9k_vcs_resume() { function _p9k_vcs_gitstatus() { if [[ $_p9k_refresh_reason == precmd ]]; then if (( $+_p9k_next_vcs_dir )); then - _p9k_next_vcs_dir=${${GIT_DIR:a}:-$PWD} + _p9k_next_vcs_dir=${${GIT_DIR:A}:-$_p9k_pwd_a} else - local dir=${${GIT_DIR:a}:-$PWD} + local dir=${${GIT_DIR:A}:-$_p9k_pwd_a} local -F timeout=_POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS if ! _p9k_vcs_status_for_dir $dir; then gitstatus_query -d $dir -t $timeout -p -c '_p9k_vcs_resume 0' POWERLEVEL9K || return 1 @@ -2641,7 +2641,7 @@ function _p9k_vcs_gitstatus() { 1) timeout=0; break;; esac done - dir=${${GIT_DIR:a}:-$PWD} + dir=${${GIT_DIR:A}:-$_p9k_pwd_a} fi if ! gitstatus_query -d $dir -t $timeout -c '_p9k_vcs_resume 1' POWERLEVEL9K; then unset VCS_STATUS_RESULT @@ -2737,7 +2737,7 @@ prompt_pyenv() { (( $+commands[pyenv] )) || return local v=${(j.:.)${(@)${(s.:.)PYENV_VERSION}#python-}} if [[ -z $v ]]; then - [[ $PYENV_DIR == /* ]] && local dir=$PYENV_DIR || local dir="$PWD/$PYENV_DIR" + [[ $PYENV_DIR == /* ]] && local dir=$PYENV_DIR || local dir="$_p9k_pwd/$PYENV_DIR" while true; do if _p9k_read_pyenv_version_file $dir/.python-version; then v=$_p9k_ret @@ -2784,7 +2784,7 @@ prompt_swift_version() { ################################################################ # dir_writable: Display information about the user's permission to write in the current directory prompt_dir_writable() { - if [[ ! -w "$PWD" ]]; then + if [[ ! -w "$_p9k_pwd" ]]; then _p9k_prompt_segment "$0_FORBIDDEN" "red" "yellow1" 'LOCK_ICON' 0 '' '' fi } @@ -3032,6 +3032,8 @@ function _p9k_build_segment() { function _p9k_set_prompt() { local ifs=$IFS IFS=$' \t\n\0' + _p9k_pwd=${(%):-%/} + _p9k_pwd_a=${_p9k_pwd:A} PROMPT=$_p9k_prompt_prefix_left RPROMPT= @@ -3472,6 +3474,8 @@ _p9k_init_vars() { typeset -g _p9k_w typeset -gi _p9k_dir_len typeset -gi _p9k_num_cpus + typeset -g _p9k_pwd + typeset -g _p9k_pwd_a typeset -gF P9K_COMMAND_DURATION_SECONDS typeset -g P9K_VISUAL_IDENTIFIER -- cgit v1.2.3 From 38055589a89045da82719bd78a901a768d17f0b4 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 7 Aug 2019 08:44:18 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index e897128b..48fb3dd3 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -376,7 +376,13 @@ function gitstatus_start() { rm -f $req_fifo $resp_fifo $lock_file function _gitstatus_process_response_${name}() { - _gitstatus_process_response ${${(%)${:-%N}}#_gitstatus_process_response_} 0 '' + local name=${${(%):-%N}#_gitstatus_process_response_} + (( ARGC == 1 )) && { + _gitstatus_process_response $name 0 '' + true + } || { + gitstatus_stop $name + } } zle -F $resp_fd _gitstatus_process_response_${name} @@ -414,11 +420,12 @@ function gitstatus_start() { } || { unsetopt err_return add-zsh-hook -d zshexit _gitstatus_cleanup_$$_${ZSH_SUBSHELL}_${daemon_pid} - [[ $daemon_pid -gt 0 ]] && kill -- -$daemon_pid &>/dev/null - [[ $stderr_fd -ge 0 ]] && { exec 2>&$stderr_fd {stderr_fd}>&- } - [[ $lock_fd -ge 0 ]] && zsystem flock -u $lock_fd - [[ $req_fd -ge 0 ]] && exec {req_fd}>&- [[ $resp_fd -ge 0 ]] && { zle -F $resp_fd; exec {resp_fd}>&- } + [[ $req_fd -ge 0 ]] && exec {req_fd}>&- + [[ $lock_fd -ge 0 ]] && zsystem flock -u $lock_fd + [[ $stderr_fd -ge 0 ]] && { exec 2>&$stderr_fd {stderr_fd}>&- } + [[ $daemon_pid -gt 0 ]] && kill -- -$daemon_pid &>/dev/null + rm -f $lock_file $req_fifo $resp_fifo unset -f gitstatus_start_impl @@ -476,6 +483,7 @@ function gitstatus_stop() { local lock_fd_var=_GITSTATUS_LOCK_FD_${name} local daemon_pid_var=GITSTATUS_DAEMON_PID_${name} local client_pid_var=_GITSTATUS_CLIENT_PID_${name} + local dirty_size_var=_GITSTATUS_DIRTY_MAX_INDEX_SIZE_${name} local req_fd=${(P)req_fd_var:-} local resp_fd=${(P)resp_fd_var:-} @@ -484,12 +492,12 @@ function gitstatus_stop() { local cleanup_func=_gitstatus_cleanup_$$_${ZSH_SUBSHELL}_${daemon_pid} - [[ -n $daemon_pid ]] && kill -- -$daemon_pid &>/dev/null - [[ -n $req_fd ]] && exec {req_fd}>&- [[ -n $resp_fd ]] && { zle -F $resp_fd; exec {resp_fd}>&- } + [[ -n $req_fd ]] && exec {req_fd}>&- [[ -n $lock_fd ]] && zsystem flock -u $lock_fd + [[ -n $daemon_pid ]] && kill -- -$daemon_pid &>/dev/null - unset $req_fd_var $resp_fd_var $lock_fd_var $daemon_pid_var $client_pid_var + unset $req_fd_var $resp_fd_var $lock_fd_var $daemon_pid_var $client_pid_var $dirty_size_var if (( $+functions[$cleanup_func] )); then add-zsh-hook -d zshexit $cleanup_func -- cgit v1.2.3 From 24a5261a395d5e1d531275b70ed48de479abe38a Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 7 Aug 2019 11:04:35 +0200 Subject: wizard: enable os_icon for users who like many icons --- config/p10k-classic.zsh | 3 ++- config/p10k-lean.zsh | 2 +- internal/configure.zsh | 2 +- internal/p10k.zsh | 9 ++++--- internal/wizard.zsh | 66 +++++++++++++++++++++++++++++++++++++++++++------ 5 files changed, 69 insertions(+), 13 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index b0fc9a86..ce42b9a6 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -25,6 +25,7 @@ fi # The list of segments shown on the left. Fill it with the most important segments. typeset -ga POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( # =========================[ Line #1 ]========================= + # os_icon # os identifier dir # current directory vcs # git status # =========================[ Line #2 ]========================= @@ -173,7 +174,7 @@ fi #################################[ os_icon: os identifier ]################################## # Foreground color. - typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND=7 + typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND=209 # Display this icon instead of the default. # typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='⭐' diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index ef9ab648..db1900eb 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -163,7 +163,7 @@ fi #################################[ os_icon: os identifier ]################################## # OS identifier color. - typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND=212 + typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND=209 # Display this icon instead of the default. # typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='⭐' diff --git a/internal/configure.zsh b/internal/configure.zsh index 5b054291..d7a253d9 100644 --- a/internal/configure.zsh +++ b/internal/configure.zsh @@ -1,4 +1,4 @@ -typeset -gr __p9k_wizard_columns=76 +typeset -gr __p9k_wizard_columns=80 typeset -gr __p9k_wizard_lines=21 typeset -gr __p9k_zd=${${ZDOTDIR:-$HOME}:A} typeset -gr __p9k_zd_u=${${${(q-)__p9k_zd}/#(#b)$HOME(|\/*)/'~'$match[1]}//\%/%%} diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 017b5c23..035475d6 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -4037,9 +4037,12 @@ _p9k_init() { Linux) _p9k_os='Linux' local os_release_id - [[ -f /etc/os-release && - "${(f)$((/dev/null)}" =~ "ID=([A-Za-z]+)" ]] && os_release_id="${match[1]}" - case "$os_release_id" in + if [[ -r /etc/os-release ]]; then + local lines=(${(f)"$(/dev/null)" == Android ]]; then + echo ANDROID_ICON + else + case $uname in + SunOS) echo SUNOS_ICON;; + Darwin) echo APPLE_ICON;; + CYGWIN_NT-* | MSYS_NT-*) echo WINDOWS_ICON;; + FreeBSD|OpenBSD|DragonFly) echo FREEBSD_ICON;; + Linux) + local os_release_id + if [[ -r /etc/os-release ]]; then + local lines=(${(f)"$( Date: Wed, 7 Aug 2019 12:44:51 +0200 Subject: change os_icon style --- config/p10k-classic.zsh | 8 ++++---- config/p10k-lean.zsh | 6 +++--- internal/wizard.zsh | 10 ++++++++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index ce42b9a6..925f08a0 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -173,10 +173,10 @@ fi typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL= #################################[ os_icon: os identifier ]################################## - # Foreground color. - typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND=209 - # Display this icon instead of the default. - # typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='⭐' + # OS identifier color. + typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND=255 + # Make the icon bold. + typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='%B${P9K_CONTENT}' ################################[ prompt_char: prompt symbol ]################################ # Transparent background. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index db1900eb..175a0d41 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -163,9 +163,9 @@ fi #################################[ os_icon: os identifier ]################################## # OS identifier color. - typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND=209 - # Display this icon instead of the default. - # typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='⭐' + typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND= + # Make the icon bold. + typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='%B${P9K_CONTENT}' ################################[ prompt_char: prompt symbol ]################################ # Green prompt symbol if the last command succeeded. diff --git a/internal/wizard.zsh b/internal/wizard.zsh index a47fc210..ac9fd8f6 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -51,7 +51,7 @@ typeset -r vertical_bar='|' typeset -r slanted_bar='\uE0BD' typeset -ra lean_left=( - '' '${extra_icons[1]:+%209F$extra_icons[1] }%31F$extra_icons[2]%B%39F~%b%31F/%B%39Fpowerlevel10k%b%f $prefixes[1]%76F$extra_icons[3]master ⇡2%f ' + '' '${extra_icons[1]:+$extra_icons[1] }%31F$extra_icons[2]%B%39F~%b%31F/%B%39Fpowerlevel10k%b%f $prefixes[1]%76F$extra_icons[3]master ⇡2%f ' '' '%76F❯%f █' ) @@ -61,7 +61,7 @@ typeset -ra lean_right=( ) typeset -ra classic_left=( - '%$frame_color[$color]F╭─' '%F{$bg_color[$color]}$left_tail%K{$bg_color[$color]} ${extra_icons[1]:+%209F$extra_icons[1] %$sep_color[$color]F$left_subsep%f }%31F$extra_icons[2]%B%39F~%b%K{$bg_color[$color]}%31F/%B%39Fpowerlevel10k%b%K{$bg_color[$color]} %$sep_color[$color]F$left_subsep%f %$prefix_color[$color]F$prefixes[1]%76F$extra_icons[3]master ⇡2 %k%$bg_color[$color]F$left_head%f' + '%$frame_color[$color]F╭─' '%F{$bg_color[$color]}$left_tail%K{$bg_color[$color]} ${extra_icons[1]:+$extra_icons[1]%K{$bg_color[$color]\} %$sep_color[$color]F$left_subsep%f }%31F$extra_icons[2]%B%39F~%b%K{$bg_color[$color]}%31F/%B%39Fpowerlevel10k%b%K{$bg_color[$color]} %$sep_color[$color]F$left_subsep%f %$prefix_color[$color]F$prefixes[1]%76F$extra_icons[3]master ⇡2 %k%$bg_color[$color]F$left_head%f' '%$frame_color[$color]F╰─' '%f █' ) @@ -418,6 +418,12 @@ function ask_extra_icons() { vcs_icon=${vcs_icon// } branch_icon=${branch_icon// } fi + if [[ $style == classic ]]; then + os_icon="%255F$os_icon%f" + else + os_icon="%f$os_icon" + fi + os_icon="%B$os_icon%b" local many=("$os_icon" "$dir_icon " "$vcs_icon $branch_icon ") while true; do clear -- cgit v1.2.3 From 305b56a5e3c54e6f616d3cac9d1ca6fbc3e55233 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 7 Aug 2019 18:20:29 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index 48fb3dd3..7faa196c 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -63,7 +63,8 @@ zmodload zsh/datetime zsh/system # ## Usage: gitstatus_query [OPTION]... NAME # -# -d STR Directory to query. Defaults to ${${GIT_DIR:-$PWD}:a}. Must be absolute. +# -d STR Directory to query. Must be absolute. Defaults to $GIT_DIR or the current +# directory if GIT_DIR is not set. # -c STR Callback function to call once the results are available. Called only after # gitstatus_query returns 0 with VCS_STATUS_RESULT=tout. # -t FLOAT Timeout in seconds. Will block for at most this long. If no results are @@ -126,8 +127,8 @@ function gitstatus_query() { setopt err_return no_unset local opt - local dir=${${GIT_DIR:-$PWD}:a} - local callback='' + local dir=${GIT_DIR:-} + local callback local -F timeout=-1 local no_diff=0 while true; do @@ -150,6 +151,8 @@ function gitstatus_query() { local client_pid_var=_GITSTATUS_CLIENT_PID_${name} [[ ${(P)client_pid_var} == $$ ]] + [[ $dir == /* ]] || dir=${(%):-%/}/$dir + local req_fd_var=_GITSTATUS_REQ_FD_${name} local -i req_fd=${(P)req_fd_var} local -r req_id="$EPOCHREALTIME" -- cgit v1.2.3 From 429b07d4f890421d473abc76e1748ba239855dd3 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 7 Aug 2019 19:10:17 +0200 Subject: add P9K_PROMPT_CHAR_STATE; it's experimental, don't use unless you are a trusted tester --- internal/p10k.zsh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 035475d6..6b566ef3 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -2030,14 +2030,15 @@ prompt_status() { } prompt_prompt_char() { + unset P9K_PROMPT_CHAR_STATE if (( _p9k_status )); then - _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${KEYMAP:-0}:#(vicmd|vivis|vivli)}' '❯' - _p9k_prompt_segment $0_ERROR_VICMD "$_p9k_color1" 196 '' 0 '${(M)${:-$KEYMAP$_p9k_region_active}:#vicmd0}' '❮' - _p9k_prompt_segment $0_ERROR_VIVIS "$_p9k_color1" 196 '' 0 '${(M)${:-$KEYMAP$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' + _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${${KEYMAP:-0}:#(vicmd|vivis|vivli)}:+${P9K_PROMPT_CHAR_STATE::=ERROR_VIINS}}' '❯' + _p9k_prompt_segment $0_ERROR_VICMD "$_p9k_color1" 196 '' 0 '${${(M)${:-$KEYMAP$_p9k_region_active}:#vicmd0}:+${P9K_PROMPT_CHAR_STATE::=ERROR_VICMD}}' '❮' + _p9k_prompt_segment $0_ERROR_VIVIS "$_p9k_color1" 196 '' 0 '${${(M)${:-$KEYMAP$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}:+${P9K_PROMPT_CHAR_STATE::=ERROR_VIVIS}}' 'Ⅴ' else - _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${KEYMAP:-0}:#(vicmd|vivis|vivli)}' '❯' - _p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${(M)${:-$KEYMAP$_p9k_region_active}:#vicmd0}' '❮' - _p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${(M)${:-$KEYMAP$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' + _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${${KEYMAP:-0}:#(vicmd|vivis|vivli)}:+${P9K_PROMPT_CHAR_STATE::=OK_VIINS}}' '❯' + _p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${${(M)${:-$KEYMAP$_p9k_region_active}:#vicmd0}:+${P9K_PROMPT_CHAR_STATE::=OK_VICMD}}' '❮' + _p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${${(M)${:-$KEYMAP$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}:+${P9K_PROMPT_CHAR_STATE::=OK_VIVIS}}' 'Ⅴ' fi } -- cgit v1.2.3 From 71a0b76ac048867d9e7790a5509d7988dfc73061 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 8 Aug 2019 11:28:22 +0200 Subject: better distinguish between fontawesome and nerd fonts There are fonts that aren't from Nerd Fonts and that cannot display the python logo from Font Awesome. Classify them as awesome-fontconfig and manually set an alternative icon for all Python segments in the config. Fixes #157. --- internal/wizard.zsh | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index ac9fd8f6..f4558ce5 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -251,6 +251,33 @@ function ask_python() { done } +function ask_debian() { + while true; do + clear + centered "%BDoes this look like a %b%2FDebian logo%f%B (swirl/spiral)?%b" + centered "reference: $(href https://www.debian.org/logos/openlogo-nd-100.jpg)" + print -P "" + centered "---> \uF306 <---" + print -P "" + print -P "%B(y) Yes.%b" + print -P "" + print -P "%B(n) No.%b" + print -P "" + print -P "(r) Restart from the beginning." + print -P "(q) Quit and do nothing." + print -P "" + + local key= + read -k key${(%):-"?%BChoice [ynrq]: %b"} || quit + case $key in + q) quit;; + r) return 1;; + y) cap_debian=1; break;; + n) cap_debian=0; break;; + esac + done +} + function ask_narrow_icons() { if [[ $POWERLEVEL9K_MODE == (powerline|compatible) ]]; then cap_narrow_icons=0 @@ -882,6 +909,15 @@ function generate_config() { sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'⇶'" fi + if [[ $POWERLEVEL9K_MODE == awesome-fontconfig && $cap_python == 0 ]]; then + uncomment 'typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION' + uncomment 'typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION' + uncomment 'typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION' + sub VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION '🐍' + sub ANACONDA_VISUAL_IDENTIFIER_EXPANSION '🐍' + sub PYENV_VISUAL_IDENTIFIER_EXPANSION '🐍' + fi + if [[ $style == classic ]]; then sub BACKGROUND $bg_color[$color] sub MULTILINE_FIRST_PROMPT_GAP_FOREGROUND $frame_color[$color] @@ -1029,7 +1065,7 @@ while true; do local POWERLEVEL9K_MODE= style= config_backup= config_backup_u= gap_char=' ' local left_subsep= right_subsep= left_tail= right_tail= left_head= right_head= local -i num_lines=0 write_config=0 empty_line=0 color=2 left_frame=1 right_frame=1 - local -i cap_diamond=0 cap_python=0 cap_narrow_icons=0 cap_lock=0 + local -i cap_diamond=0 cap_python=0 cap_debian=0 cap_narrow_icons=0 cap_lock=0 local -a extra_icons=('' '' '') local -a prefixes=('' '') local -a options=() @@ -1049,8 +1085,13 @@ while true; do elif (( ! cap_diamond )); then POWERLEVEL9K_MODE=awesome-fontconfig else - ask_python || continue - (( cap_python )) && POWERLEVEL9K_MODE=awesome-fontconfig || POWERLEVEL9K_MODE=nerdfont-complete + ask_debian || continue + if (( cap_debian )); then + POWERLEVEL9K_MODE=nerdfont-complete + else + POWERLEVEL9K_MODE=awesome-fontconfig + ask_python || continue + fi fi fi if [[ $POWERLEVEL9K_MODE == powerline ]]; then -- cgit v1.2.3 From b2ddbdb90d865c5d04c721b79d4a99d22287f340 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 8 Aug 2019 11:42:31 +0200 Subject: remove one space after VCS_BRANCH_ICON when using wide icons --- config/p10k-classic.zsh | 2 +- config/p10k-lean.zsh | 2 +- internal/wizard.zsh | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 925f08a0..c9cc2e59 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -272,7 +272,7 @@ fi # typeset -g POWERLEVEL9K_DIR_CLASSES=() #####################################[ vcs: git status ]###################################### - # Branch icon. Set this parameter to '\uF126' for the popular Powerline branch icon. + # Branch icon. Set this parameter to '\uF126 ' for the popular Powerline branch icon. typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= # Untracked files icon. It's really a question mark, your font isn't broken. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 175a0d41..d34d0c2b 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -255,7 +255,7 @@ fi # typeset -g POWERLEVEL9K_DIR_CLASSES=() #####################################[ vcs: git status ]###################################### - # Branch icon. Set this parameter to '\uF126' for the popular Powerline branch icon. + # Branch icon. Set this parameter to '\uF126 ' for the popular Powerline branch icon. typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= # Untracked files icon. It's really a question mark, your font isn't broken. diff --git a/internal/wizard.zsh b/internal/wizard.zsh index f4558ce5..e78129f5 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -443,8 +443,8 @@ function ask_extra_icons() { os_icon=${os_icon// } dir_icon=${dir_icon// } vcs_icon=${vcs_icon// } - branch_icon=${branch_icon// } fi + branch_icon=${branch_icon// } if [[ $style == classic ]]; then os_icon="%255F$os_icon%f" else @@ -938,8 +938,7 @@ function generate_config() { fi if [[ -n ${(j::)extra_icons} ]]; then - local branch_icon=$icons[VCS_BRANCH_ICON] - (( cap_narrow_icons )) && branch_icon=${branch_icon// } + local branch_icon=${icons[VCS_BRANCH_ICON]// } sub VCS_BRANCH_ICON "'$branch_icon '" uncomment os_icon else -- cgit v1.2.3 From d6401aad69b583bcb51a7862e64e13b530e939cb Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 8 Aug 2019 12:05:58 +0200 Subject: add a space after all os icons --- internal/icons.zsh | 180 ++++++++++++++++++++++++++--------------------------- 1 file changed, 90 insertions(+), 90 deletions(-) diff --git a/internal/icons.zsh b/internal/icons.zsh index af920bcc..9b40e6a0 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -33,30 +33,30 @@ function _p9k_init_icons() { MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ - APPLE_ICON '\uE26E' #  - WINDOWS_ICON '\uE26F' #  + APPLE_ICON '\uE26E ' #  + WINDOWS_ICON '\uE26F ' #  FREEBSD_ICON '\U1F608 ' # 😈 - ANDROID_ICON '\uE270' #  - LINUX_ICON '\uE271' #  - LINUX_ARCH_ICON '\uE271' #  - LINUX_DEBIAN_ICON '\uE271' #  - LINUX_RASPBIAN_ICON '\uE271' #  - LINUX_UBUNTU_ICON '\uE271' #  - LINUX_CENTOS_ICON '\uE271' #  - LINUX_COREOS_ICON '\uE271' #  - LINUX_ELEMENTARY_ICON '\uE271' #  - LINUX_MINT_ICON '\uE271' #  - LINUX_FEDORA_ICON '\uE271' #  - LINUX_GENTOO_ICON '\uE271' #  - LINUX_MAGEIA_ICON '\uE271' #  - LINUX_NIXOS_ICON '\uE271' #  - LINUX_MANJARO_ICON '\uE271' #  - LINUX_DEVUAN_ICON '\uE271' #  - LINUX_ALPINE_ICON '\uE271' #  - LINUX_AOSC_ICON '\uE271' #  - LINUX_OPENSUSE_ICON '\uE271' #  - LINUX_SABAYON_ICON '\uE271' #  - LINUX_SLACKWARE_ICON '\uE271' #  + ANDROID_ICON '\uE270 ' #  + LINUX_ICON '\uE271 ' #  + LINUX_ARCH_ICON '\uE271 ' #  + LINUX_DEBIAN_ICON '\uE271 ' #  + LINUX_RASPBIAN_ICON '\uE271 ' #  + LINUX_UBUNTU_ICON '\uE271 ' #  + LINUX_CENTOS_ICON '\uE271 ' #  + LINUX_COREOS_ICON '\uE271 ' #  + LINUX_ELEMENTARY_ICON '\uE271 ' #  + LINUX_MINT_ICON '\uE271 ' #  + LINUX_FEDORA_ICON '\uE271 ' #  + LINUX_GENTOO_ICON '\uE271 ' #  + LINUX_MAGEIA_ICON '\uE271 ' #  + LINUX_NIXOS_ICON '\uE271 ' #  + LINUX_MANJARO_ICON '\uE271 ' #  + LINUX_DEVUAN_ICON '\uE271 ' #  + LINUX_ALPINE_ICON '\uE271 ' #  + LINUX_AOSC_ICON '\uE271 ' #  + LINUX_OPENSUSE_ICON '\uE271 ' #  + LINUX_SABAYON_ICON '\uE271 ' #  + LINUX_SLACKWARE_ICON '\uE271 ' #  SUNOS_ICON '\U1F31E ' # 🌞 HOME_ICON '\uE12C' #  HOME_SUB_ICON '\uE18D' #  @@ -134,30 +134,30 @@ function _p9k_init_icons() { MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ - APPLE_ICON '\uF179' #  - WINDOWS_ICON '\uF17A' #  + APPLE_ICON '\uF179 ' #  + WINDOWS_ICON '\uF17A ' #  FREEBSD_ICON '\U1F608 ' # 😈 - ANDROID_ICON '\uE17B' #  - LINUX_ICON '\uF17C' #  - LINUX_ARCH_ICON '\uF17C' #  - LINUX_DEBIAN_ICON '\uF17C' #  - LINUX_RASPBIAN_ICON '\uF17C' #  - LINUX_UBUNTU_ICON '\uF17C' #  - LINUX_CENTOS_ICON '\uF17C' #  - LINUX_COREOS_ICON '\uF17C' #  - LINUX_ELEMENTARY_ICON '\uF17C' #  - LINUX_MINT_ICON '\uF17C' #  - LINUX_FEDORA_ICON '\uF17C' #  - LINUX_GENTOO_ICON '\uF17C' #  - LINUX_MAGEIA_ICON '\uF17C' #  - LINUX_NIXOS_ICON '\uF17C' #  - LINUX_MANJARO_ICON '\uF17C' #  - LINUX_DEVUAN_ICON '\uF17C' #  - LINUX_ALPINE_ICON '\uF17C' #  - LINUX_AOSC_ICON '\uF17C' #  - LINUX_OPENSUSE_ICON '\uF17C' #  - LINUX_SABAYON_ICON '\uF17C' #  - LINUX_SLACKWARE_ICON '\uF17C' #  + ANDROID_ICON '\uE17B ' #  + LINUX_ICON '\uF17C ' #  + LINUX_ARCH_ICON '\uF17C ' #  + LINUX_DEBIAN_ICON '\uF17C ' #  + LINUX_RASPBIAN_ICON '\uF17C ' #  + LINUX_UBUNTU_ICON '\uF17C ' #  + LINUX_CENTOS_ICON '\uF17C ' #  + LINUX_COREOS_ICON '\uF17C ' #  + LINUX_ELEMENTARY_ICON '\uF17C ' #  + LINUX_MINT_ICON '\uF17C ' #  + LINUX_FEDORA_ICON '\uF17C ' #  + LINUX_GENTOO_ICON '\uF17C ' #  + LINUX_MAGEIA_ICON '\uF17C ' #  + LINUX_NIXOS_ICON '\uF17C ' #  + LINUX_MANJARO_ICON '\uF17C ' #  + LINUX_DEVUAN_ICON '\uF17C ' #  + LINUX_ALPINE_ICON '\uF17C ' #  + LINUX_AOSC_ICON '\uF17C ' #  + LINUX_OPENSUSE_ICON '\uF17C ' #  + LINUX_SABAYON_ICON '\uF17C ' #  + LINUX_SLACKWARE_ICON '\uF17C ' #  SUNOS_ICON '\uF185 ' #  HOME_ICON '\uF015' #  HOME_SUB_ICON '\uF07C' #  @@ -238,28 +238,28 @@ function _p9k_init_icons() { MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ - APPLE_ICON '\u'$CODEPOINT_OF_AWESOME_APPLE #  + APPLE_ICON '\u'$CODEPOINT_OF_AWESOME_APPLE' ' #  FREEBSD_ICON '\U1F608 ' # 😈 - LINUX_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_ARCH_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_DEBIAN_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_RASPBIAN_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_UBUNTU_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_CENTOS_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_COREOS_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_ELEMENTARY_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_MINT_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_FEDORA_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_GENTOO_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_MAGEIA_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_NIXOS_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_MANJARO_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_DEVUAN_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_ALPINE_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_AOSC_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_OPENSUSE_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_SABAYON_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  - LINUX_SLACKWARE_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #  + LINUX_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_ARCH_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_DEBIAN_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_RASPBIAN_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_UBUNTU_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_CENTOS_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_COREOS_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_ELEMENTARY_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_MINT_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_FEDORA_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_GENTOO_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_MAGEIA_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_NIXOS_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_MANJARO_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_DEVUAN_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_ALPINE_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_AOSC_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_OPENSUSE_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_SABAYON_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  + LINUX_SLACKWARE_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  SUNOS_ICON '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' #  HOME_ICON '\u'$CODEPOINT_OF_AWESOME_HOME #  HOME_SUB_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN #  @@ -333,30 +333,30 @@ function _p9k_init_icons() { MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ - APPLE_ICON '\uF179' #  - WINDOWS_ICON '\uF17A' #  + APPLE_ICON '\uF179 ' #  + WINDOWS_ICON '\uF17A ' #  FREEBSD_ICON '\UF30C ' #  - ANDROID_ICON '\uF17B' #  - LINUX_ARCH_ICON '\uF303' #  - LINUX_CENTOS_ICON '\uF304' #  - LINUX_COREOS_ICON '\uF305' #  - LINUX_DEBIAN_ICON '\uF306' #  - LINUX_RASPBIAN_ICON '\uF315' #  - LINUX_ELEMENTARY_ICON '\uF309' #  - LINUX_FEDORA_ICON '\uF30a' #  - LINUX_GENTOO_ICON '\uF30d' #  - LINUX_MAGEIA_ICON '\uF310' #  - LINUX_MINT_ICON '\uF30e' #  - LINUX_NIXOS_ICON '\uF313' #  - LINUX_MANJARO_ICON '\uF312' #  - LINUX_DEVUAN_ICON '\uF307' #  - LINUX_ALPINE_ICON '\uF300' #  - LINUX_AOSC_ICON '\uF301' #  - LINUX_OPENSUSE_ICON '\uF314' #  - LINUX_SABAYON_ICON '\uF317' #  - LINUX_SLACKWARE_ICON '\uF319' #  - LINUX_UBUNTU_ICON '\uF31b' #  - LINUX_ICON '\uF17C' #  + ANDROID_ICON '\uF17B ' #  + LINUX_ARCH_ICON '\uF303 ' #  + LINUX_CENTOS_ICON '\uF304 ' #  + LINUX_COREOS_ICON '\uF305 ' #  + LINUX_DEBIAN_ICON '\uF306 ' #  + LINUX_RASPBIAN_ICON '\uF315 ' #  + LINUX_ELEMENTARY_ICON '\uF309 ' #  + LINUX_FEDORA_ICON '\uF30a ' #  + LINUX_GENTOO_ICON '\uF30d ' #  + LINUX_MAGEIA_ICON '\uF310 ' #  + LINUX_MINT_ICON '\uF30e ' #  + LINUX_NIXOS_ICON '\uF313 ' #  + LINUX_MANJARO_ICON '\uF312 ' #  + LINUX_DEVUAN_ICON '\uF307 ' #  + LINUX_ALPINE_ICON '\uF300 ' #  + LINUX_AOSC_ICON '\uF301 ' #  + LINUX_OPENSUSE_ICON '\uF314 ' #  + LINUX_SABAYON_ICON '\uF317 ' #  + LINUX_SLACKWARE_ICON '\uF319 ' #  + LINUX_UBUNTU_ICON '\uF31b ' #  + LINUX_ICON '\uF17C ' #  SUNOS_ICON '\uF185 ' #  HOME_ICON '\uF015' #  HOME_SUB_ICON '\uF07C' #  -- cgit v1.2.3 From cf8b0594a32d0d16343515855aba276410a4c493 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 9 Aug 2019 09:18:00 +0200 Subject: Revert "add P9K_PROMPT_CHAR_STATE; it's experimental, don't use unless you are a trusted tester" This reverts commit 429b07d4f890421d473abc76e1748ba239855dd3. Fixes #154. --- internal/p10k.zsh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 6b566ef3..035475d6 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -2030,15 +2030,14 @@ prompt_status() { } prompt_prompt_char() { - unset P9K_PROMPT_CHAR_STATE if (( _p9k_status )); then - _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${${KEYMAP:-0}:#(vicmd|vivis|vivli)}:+${P9K_PROMPT_CHAR_STATE::=ERROR_VIINS}}' '❯' - _p9k_prompt_segment $0_ERROR_VICMD "$_p9k_color1" 196 '' 0 '${${(M)${:-$KEYMAP$_p9k_region_active}:#vicmd0}:+${P9K_PROMPT_CHAR_STATE::=ERROR_VICMD}}' '❮' - _p9k_prompt_segment $0_ERROR_VIVIS "$_p9k_color1" 196 '' 0 '${${(M)${:-$KEYMAP$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}:+${P9K_PROMPT_CHAR_STATE::=ERROR_VIVIS}}' 'Ⅴ' + _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${KEYMAP:-0}:#(vicmd|vivis|vivli)}' '❯' + _p9k_prompt_segment $0_ERROR_VICMD "$_p9k_color1" 196 '' 0 '${(M)${:-$KEYMAP$_p9k_region_active}:#vicmd0}' '❮' + _p9k_prompt_segment $0_ERROR_VIVIS "$_p9k_color1" 196 '' 0 '${(M)${:-$KEYMAP$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' else - _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${${KEYMAP:-0}:#(vicmd|vivis|vivli)}:+${P9K_PROMPT_CHAR_STATE::=OK_VIINS}}' '❯' - _p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${${(M)${:-$KEYMAP$_p9k_region_active}:#vicmd0}:+${P9K_PROMPT_CHAR_STATE::=OK_VICMD}}' '❮' - _p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${${(M)${:-$KEYMAP$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}:+${P9K_PROMPT_CHAR_STATE::=OK_VIVIS}}' 'Ⅴ' + _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${KEYMAP:-0}:#(vicmd|vivis|vivli)}' '❯' + _p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${(M)${:-$KEYMAP$_p9k_region_active}:#vicmd0}' '❮' + _p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${(M)${:-$KEYMAP$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' fi } -- cgit v1.2.3 From a169132721f1dd406ef805fd39d16a1251eeb4af Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 9 Aug 2019 09:53:06 +0200 Subject: whitespace --- gitstatus/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/gitstatus/README.md b/gitstatus/README.md index 2196d30f..bfe8c3e3 100644 --- a/gitstatus/README.md +++ b/gitstatus/README.md @@ -1,2 +1 @@ This is a bundled copy of [gitstatus](https://github.com/romkatv/gitstatus) ZSH plugin. - -- cgit v1.2.3 From 9efe06875aced2ad400f08a87c6de0fed6182a3a Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 9 Aug 2019 09:53:23 +0200 Subject: font docs --- README.md | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 94e8e5b8..ac455806 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,6 @@ prompt. 1. [FAQ](#faq) 1. [Why my icons and/or powerline symbols look bad?](#why-my-icons-andor-powerline-symbols-look-bad) 1. [Why do I have a question mark symbol in my prompt? Is my font broken?](#why-do-i-have-a-question-mark-symbol-in-my-prompt-is-my-font-broken) - 1. [I've installed the recommended font but I still don't see the Python logo in the configuration wizard.](#ive-installed-the-recommended-font-but-i-still-dont-see-the-python-logo-in-the-configuration-wizard) 1. [Why does Powerlevel10k spawn extra processes?](#why-does-powerlevel10k-spawn-extra-processes) 1. [Are there configuration options that make Powerlevel10k slow?](#are-there-configuration-options-that-make-powerlevel10k-slow) 1. [Is Powerlevel10k fast to load?](#is-powerlevel10k-fast-to-load) @@ -191,19 +190,13 @@ It's likely your font's fault. ### Why do I have a question mark symbol in my prompt? Is my font broken? If it looks like a regular `?`, that's normal. It means you have untracked files in the current Git -repository. Type `git status` to see these files. +repository. Type `git status` to see these files. You can change this symbol or disable the display +of untracked files altogether. Search for `untracked files` in `~/.p10k.zsh`. -You can change this symbol or disable the display of untracked files altogether. Search for -`untracked files` in `~/.p10k.zsh`. - -### I've installed the recommended font but I still don't see the Python logo in the configuration wizard. - -When using a font from Nerd Fonts such as -[the recommended font](#recommended-meslo-nerd-font-patched-for-powerlevel10k), the Python logo -isn't supposed to render _in the configuration wizard_. Your telling the wizard that the logo -doesn't render effectively says that you are using Nerd Fonts. As long as you correctly tell the -wizard which icons render and which don't, it'll be able to figure out which font you are using. -You'll get all icons in your prompt, including the Python logo. +You can also get a weird-looking question mark in your prompt if your terminal's font is missing +some glyphs. To fix this problem, +[install the recommended font](#recommended-meslo-nerd-font-patched-for-powerlevel10k) and run +`p10k configure`. ### Why does Powerlevel10k spawn extra processes? -- cgit v1.2.3 From 3f9957c30adce11d9615ba67f6afc66b0dd4fdf4 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 9 Aug 2019 22:42:24 +0200 Subject: add an FAQ entry for people who cannot click on a ttf file and press Install --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index ac455806..f8f3084f 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ prompt. 1. [License](#license) 1. [FAQ](#faq) 1. [Why my icons and/or powerline symbols look bad?](#why-my-icons-andor-powerline-symbols-look-bad) + 1. [I cannot install the recommended font. Help!](#i-cannot-install-the-recommended-font-help) 1. [Why do I have a question mark symbol in my prompt? Is my font broken?](#why-do-i-have-a-question-mark-symbol-in-my-prompt-is-my-font-broken) 1. [Why does Powerlevel10k spawn extra processes?](#why-does-powerlevel10k-spawn-extra-processes) 1. [Are there configuration options that make Powerlevel10k slow?](#are-there-configuration-options-that-make-powerlevel10k-slow) @@ -187,6 +188,11 @@ It's likely your font's fault. [Install the recommended font](#recommended-meslo-nerd-font-patched-for-powerlevel10k) and run `p10k configure`. +### I cannot install the recommended font. Help! + +Once you download [the recommended font](#recommended-meslo-nerd-font-patched-for-powerlevel10k), +you can install it just like any other font. Google "how to install fonts on *your-OS*". + ### Why do I have a question mark symbol in my prompt? Is my font broken? If it looks like a regular `?`, that's normal. It means you have untracked files in the current Git -- cgit v1.2.3 From 8a320aaf4e0e983f42a9717babba02f904d7b94e Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 10 Aug 2019 07:58:10 +0200 Subject: don't assume that people know how to download files from a browser --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f8f3084f..34e7e74a 100644 --- a/README.md +++ b/README.md @@ -110,9 +110,13 @@ the default system fonts. The full choice of style options is available only whe ### Recommended: Meslo Nerd Font patched for Powerlevel10k -Download these -[four ttf files](https://github.com/romkatv/dotfiles-public/tree/master/.local/share/fonts/NerdFonts), -double-click on each and press "Install". This will make `MesloLGS NF` font available to all +Download these four ttf files: +- [MesloLGS NF Regular.ttf](https://github.com/romkatv/dotfiles-public/raw/master/.local/share/fonts/NerdFonts/MesloLGS%20NF%20Regular.ttf) +- [MesloLGS NF Bold.ttf](https://github.com/romkatv/dotfiles-public/raw/master/.local/share/fonts/NerdFonts/MesloLGS%20NF%20Bold.ttf) +- [MesloLGS NF Italic.ttf](https://github.com/romkatv/dotfiles-public/raw/master/.local/share/fonts/NerdFonts/MesloLGS%20NF%20Italic.ttf) +- [MesloLGS NF Bold Italic.ttf](https://github.com/romkatv/dotfiles-public/raw/master/.local/share/fonts/NerdFonts/MesloLGS%20NF%20Bold%20Italic.ttf) + +Double-click on each file and press "Install". This will make `MesloLGS NF` font available to all applications on your system. Configure your terminal to use this font: - **iTerm2**: Open *iTerm2 → Preferences → Profiles → Text* and set *Font* to `MesloLGS NF`. -- cgit v1.2.3 From 626056865d5c5f19f2b9873462c4f4dac508d141 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 10 Aug 2019 10:47:22 +0200 Subject: add POWERLEVEL9K_RVM_SHOW_GEMSET and POWERLEVEL9K_RVM_SHOW_PREFIX Some users want them. See https://github.com/Powerlevel9k/powerlevel9k/pull/1353. --- internal/p10k.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 035475d6..72b974ea 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1974,7 +1974,9 @@ prompt_rspec_stats() { prompt_rvm() { (( $+commands[rvm-prompt] )) || return [[ $GEM_HOME == *rvm* && $ruby_string != $rvm_path/bin/ruby ]] || return - local v=${${${GEM_HOME:t}%%${rvm_gemset_separator:-@}*}#*-} + local v=${GEM_HOME:t} + (( _POWERLEVEL9K_RVM_SHOW_GEMSET )) || v=${v%%${rvm_gemset_separator:-@}*} + (( _POWERLEVEL9K_RVM_SHOW_PREFIX )) || v=${v#*-} [[ -n $v ]] || return _p9k_prompt_segment "$0" "240" "$_p9k_color1" 'RUBY_ICON' 0 '' "${v//\%/%%}" } @@ -3608,6 +3610,8 @@ _p9k_init_params() { _p9k_declare -b POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -b POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY 0 _p9k_declare -b POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW 0 + _p9k_declare -b POWERLEVEL9K_RVM_SHOW_GEMSET 0 + _p9k_declare -b POWERLEVEL9K_RVM_SHOW_PREFIX 0 _p9k_declare -b POWERLEVEL9K_CHRUBY_SHOW_VERSION 1 _p9k_declare -b POWERLEVEL9K_CHRUBY_SHOW_ENGINE 1 _p9k_declare -b POWERLEVEL9K_STATUS_CROSS 0 -- cgit v1.2.3 From 987123f378b0ecb9340b9db747855d5712ff150a Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 10 Aug 2019 10:49:04 +0200 Subject: add rvm to lean and classic configs --- config/p10k-classic.zsh | 11 +++++++++++ config/p10k-lean.zsh | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index c9cc2e59..cb252578 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -51,6 +51,7 @@ fi # node_version # node.js version # go_version # golang version # rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) + rvm # ruby version from rvm (https://rvm.io) kubecontext # current kubernetes context (https://kubernetes.io/) context # user@host nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) @@ -505,6 +506,16 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_RBENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + #######################[ rvm: ruby version from rvm (https://rvm.io) ]######################## + # Rvm color. + typeset -g POWERLEVEL9K_RVM_FOREGROUND=168 + # Don't show @gemset at the end. + typeset -g POWERLEVEL9K_RVM_SHOW_GEMSET=false + # Don't show ruby- at the front. + typeset -g POWERLEVEL9K_RVM_SHOW_PREFIX=false + # Custom icon. + # typeset -g POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# # Kubernetes context classes for the purpose of using different colors, icons and expansions with # different contexts. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index d34d0c2b..8ce65e83 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -51,6 +51,7 @@ fi # node_version # node.js version # go_version # golang version # rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) + rvm # ruby version from rvm (https://rvm.io) kubecontext # current kubernetes context (https://kubernetes.io/) context # user@host nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) @@ -488,6 +489,16 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_RBENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + #######################[ rvm: ruby version from rvm (https://rvm.io) ]######################## + # Rvm color. + typeset -g POWERLEVEL9K_RVM_FOREGROUND=168 + # Don't show @gemset at the end. + typeset -g POWERLEVEL9K_RVM_SHOW_GEMSET=false + # Don't show ruby- at the front. + typeset -g POWERLEVEL9K_RVM_SHOW_PREFIX=false + # Custom icon. + # typeset -g POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# # Kubernetes context classes for the purpose of using different colors, icons and expansions with # different contexts. -- cgit v1.2.3 From 79cfbd12e7662e5bdf7a6539c8e787295823ca64 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 10 Aug 2019 10:49:36 +0200 Subject: enable rbenv by default in lean and classic configs --- config/p10k-classic.zsh | 2 +- config/p10k-lean.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index cb252578..240868ef 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -50,7 +50,7 @@ fi nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) # node_version # node.js version # go_version # golang version - # rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) + rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rvm # ruby version from rvm (https://rvm.io) kubecontext # current kubernetes context (https://kubernetes.io/) context # user@host diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 8ce65e83..f2144d79 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -50,7 +50,7 @@ fi nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) # node_version # node.js version # go_version # golang version - # rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) + rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rvm # ruby version from rvm (https://rvm.io) kubecontext # current kubernetes context (https://kubernetes.io/) context # user@host -- cgit v1.2.3 From 55a1b92bcad16de8cd6a311e265de555138448d3 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 10 Aug 2019 11:01:47 +0200 Subject: strip spaces from os_icon when using narrow icons --- internal/wizard.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index e78129f5..5f9d6f96 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -899,6 +899,7 @@ function generate_config() { if (( cap_narrow_icons )); then sub VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER// }'" sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER// }'" + sub OS_ICON_CONTENT_EXPANSION "'%B\${P9K_CONTENT// }'" else sub VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER}'" sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER}'" -- cgit v1.2.3 From 0d7ba09c4fddd1719f5f24fcbd6a27b999e1cd10 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 12 Aug 2019 08:29:59 +0200 Subject: short rust_version only when in a subdirectory of a cargo package fixes #164 --- internal/p10k.zsh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 72b974ea..4b503e01 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1956,6 +1956,11 @@ prompt_rust_version() { _p9k_cached_cmd_stdout rustc --version || return local v=${${_p9k_ret#rustc }%% *} [[ -n $v ]] || return + local dir=$_p9k_pwd_a + while [[ ! -e $dir/Cargo.toml ]]; do + [[ $dir == / ]] && return + dir=${dir:h} + done _p9k_prompt_segment "$0" "darkorange" "$_p9k_color1" 'RUST_ICON' 0 '' "${v//\%/%%}" } -- cgit v1.2.3 From 36174484cc9e9055f5b37bd53b5e7aa1935cdc5e Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 12 Aug 2019 08:40:19 +0200 Subject: slightly better icons --- internal/icons.zsh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/icons.zsh b/internal/icons.zsh index 9b40e6a0..55d1b33e 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -88,16 +88,16 @@ function _p9k_init_icons() { VCS_GIT_BITBUCKET_ICON '\uE20E ' # VCS_GIT_GITLAB_ICON '\uE20E ' # VCS_HG_ICON '\uE1C3 ' #  - VCS_SVN_ICON '(svn) ' - RUST_ICON '(rust)' # TODO: try 𝗥. - PYTHON_ICON '\ue63c' #  + VCS_SVN_ICON 'svn' + RUST_ICON 'R' + PYTHON_ICON '\ue63c' #  SWIFT_ICON '' GO_ICON '' PUBLIC_IP_ICON '' LOCK_ICON '\UE138' #  EXECUTION_TIME_ICON '\UE89C' #  - SSH_ICON '(ssh)' - VPN_ICON '(vpn)' + SSH_ICON 'ssh' + VPN_ICON 'vpn' KUBERNETES_ICON '\U2388' # ⎈ DROPBOX_ICON '\UF16B' #  DATE_ICON '\uE184' #  @@ -185,7 +185,7 @@ function _p9k_init_icons() { VCS_GIT_BITBUCKET_ICON '\uF171 ' #  VCS_GIT_GITLAB_ICON '\uF296 ' #  VCS_HG_ICON '\uF0C3 ' #  - VCS_SVN_ICON '(svn) ' + VCS_SVN_ICON 'svn' RUST_ICON '\uE6A8' #  PYTHON_ICON '\ue63c' #  SWIFT_ICON '' @@ -193,7 +193,7 @@ function _p9k_init_icons() { PUBLIC_IP_ICON '' LOCK_ICON '\UF023' #  EXECUTION_TIME_ICON '\uF253' - SSH_ICON '(ssh)' + SSH_ICON 'ssh' VPN_ICON '\uF023' KUBERNETES_ICON '\U2388' # ⎈ DROPBOX_ICON '\UF16B' #  @@ -287,14 +287,14 @@ function _p9k_init_icons() { VCS_GIT_BITBUCKET_ICON '\u'$CODEPOINT_OF_AWESOME_BITBUCKET' ' #  VCS_GIT_GITLAB_ICON '\u'$CODEPOINT_OF_AWESOME_GITLAB' ' #  VCS_HG_ICON '\u'$CODEPOINT_OF_AWESOME_FLASK' ' #  - VCS_SVN_ICON '(svn) ' + VCS_SVN_ICON 'svn' RUST_ICON '\uE6A8' #  - PYTHON_ICON '\U1F40D' # 🐍 + PYTHON_ICON '🐍' SWIFT_ICON '\uE655' #  PUBLIC_IP_ICON '\u'$CODEPOINT_OF_AWESOME_GLOBE #  LOCK_ICON '\u'$CODEPOINT_OF_AWESOME_LOCK #  EXECUTION_TIME_ICON '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END #  - SSH_ICON '(ssh)' + SSH_ICON 'ssh' VPN_ICON '\u'$CODEPOINT_OF_AWESOME_LOCK KUBERNETES_ICON '\U2388' # ⎈ DROPBOX_ICON '\u'$CODEPOINT_OF_AWESOME_DROPBOX #  @@ -393,7 +393,7 @@ function _p9k_init_icons() { LOCK_ICON '\UF023' #  EXECUTION_TIME_ICON '\uF252' #  SSH_ICON '\uF489' #  - VPN_ICON '(vpn)' + VPN_ICON 'vpn' KUBERNETES_ICON '\U2388' # ⎈ DROPBOX_ICON '\UF16B' #  DATE_ICON '\uF073 ' #  @@ -482,7 +482,7 @@ function _p9k_init_icons() { VCS_GIT_GITLAB_ICON '' VCS_HG_ICON '' VCS_SVN_ICON '' - RUST_ICON 'Rust' # TODO: try 𝗥. + RUST_ICON 'R' PYTHON_ICON 'Py' SWIFT_ICON 'Swift' GO_ICON 'Go' -- cgit v1.2.3 From 40f40c29948c20e71d16b2003b459346c14fbdc6 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 12 Aug 2019 08:40:55 +0200 Subject: add rust_version to lean and classic configs --- config/p10k-classic.zsh | 11 +++++++++-- config/p10k-lean.zsh | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 240868ef..739ba6dd 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -49,7 +49,8 @@ fi nvm # node.js version from nvm (https://github.com/nvm-sh/nvm) nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) # node_version # node.js version - # go_version # golang version + # go_version # go version (https://golang.org) + # rust_version # rustc version (https://www.rust-lang.org) rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rvm # ruby version from rvm (https://rvm.io) kubecontext # current kubernetes context (https://kubernetes.io/) @@ -492,12 +493,18 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_NODE_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - ################################[ go_version: golang version ]################################ + #######################[ go_version: go version (https://golang.org) ]######################## # Golang version color. typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=37 # Custom icon. # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + #################[ rust_version: rustc version (https://www.rust-lang.org) ]################## + # Rust version color. + typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=37 + # Custom icon. + # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## # Rbenv color. typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index f2144d79..d9c7a40e 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -49,7 +49,8 @@ fi nvm # node.js version from nvm (https://github.com/nvm-sh/nvm) nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) # node_version # node.js version - # go_version # golang version + # go_version # go version (https://golang.org) + # rust_version # rustc version (https://www.rust-lang.org) rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rvm # ruby version from rvm (https://rvm.io) kubecontext # current kubernetes context (https://kubernetes.io/) @@ -475,12 +476,18 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_NODE_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - ################################[ go_version: golang version ]################################ + #######################[ go_version: go version (https://golang.org) ]######################## # Golang version color. typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=37 # Custom icon. # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + #################[ rust_version: rustc version (https://www.rust-lang.org) ]################## + # Rust version color. + typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=37 + # Custom icon. + # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## # Rbenv color. typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 -- cgit v1.2.3 From bafade896322cdf6d6db220bd41fee2595e8d1a7 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 12 Aug 2019 08:56:47 +0200 Subject: add POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY and POWERLEVEL9K_GO_VERSION_PROJECT_ONLY --- config/p10k-classic.zsh | 6 +++++- config/p10k-lean.zsh | 6 +++++- internal/p10k.zsh | 50 ++++++++++++++++++++++++++++--------------------- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 739ba6dd..1237a4b3 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -494,14 +494,18 @@ fi # typeset -g POWERLEVEL9K_NODE_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' #######################[ go_version: go version (https://golang.org) ]######################## - # Golang version color. + # Go version color. typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=37 + # Show go version only when in a go project subdirectory. + typeset -g POWERLEVEL9K_GO_VERSION_PROJECT_ONLY=true # Custom icon. # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' #################[ rust_version: rustc version (https://www.rust-lang.org) ]################## # Rust version color. typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=37 + # Show rust version only when in a rust project subdirectory. + typeset -g POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY=true # Custom icon. # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index d9c7a40e..ea74b926 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -477,14 +477,18 @@ fi # typeset -g POWERLEVEL9K_NODE_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' #######################[ go_version: go version (https://golang.org) ]######################## - # Golang version color. + # Go version color. typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=37 + # Show go version only when in a go project subdirectory. + typeset -g POWERLEVEL9K_GO_VERSION_PROJECT_ONLY=true # Custom icon. # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' #################[ rust_version: rustc version (https://www.rust-lang.org) ]################## # Rust version color. typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=37 + # Show rust version only when in a rust project subdirectory. + typeset -g POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY=true # Custom icon. # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 4b503e01..b56c9da5 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1527,20 +1527,23 @@ prompt_go_version() { local -a match [[ $_p9k_ret == (#b)*go([[:digit:].]##)* ]] || return local v=$match[1] - local p=$GOPATH - if [[ -z $p ]]; then - if [[ -d $HOME/go ]]; then - p=$HOME/go - else - p="$(go env GOPATH 2>/dev/null)" && [[ -n $p ]] || return + if (( _POWERLEVEL9K_GO_VERSION_PROJECT_ONLY )); then + local p=$GOPATH + if [[ -z $p ]]; then + if [[ -d $HOME/go ]]; then + p=$HOME/go + else + p="$(go env GOPATH 2>/dev/null)" && [[ -n $p ]] || return + fi + fi + if [[ $_p9k_pwd/ != $p/* && $_p9k_pwd_a/ != $p/* ]]; then + local dir=$_p9k_pwd_a + while true; do + [[ $dir == / ]] && return + [[ -e $dir/go.mod ]] && break + dir=${dir:h} + done fi - fi - if [[ $_p9k_pwd/ != $p/* ]]; then - local dir=$_p9k_pwd - while [[ ! -e $dir/go.mod ]]; do - [[ $dir == / ]] && return - dir=${dir:h} - done fi _p9k_prompt_segment "$0" "green" "grey93" "GO_ICON" 0 '' "${v//\%/%%}" } @@ -1821,7 +1824,7 @@ prompt_nodenv() { (( $+commands[nodenv] )) || return _p9k_ret=$NODENV_VERSION if [[ -z $_p9k_ret ]]; then - [[ $NODENV_DIR == /* ]] && local dir=$NODENV_DIR || local dir="$_p9k_pwd/$NODENV_DIR" + [[ $NODENV_DIR == /* ]] && local dir=$NODENV_DIR || local dir="$_p9k_pwd_a/$NODENV_DIR" while [[ $dir != //[^/]# ]]; do _p9k_read_nodenv_version_file $dir/.node-version && break [[ $dir == / ]] && break @@ -1909,7 +1912,7 @@ prompt_rbenv() { (( $+commands[rbenv] )) || return local v=$RBENV_VERSION if [[ -z $v ]]; then - [[ $RBENV_DIR == /* ]] && local dir=$RBENV_DIR || local dir="$_p9k_pwd/$RBENV_DIR" + [[ $RBENV_DIR == /* ]] && local dir=$RBENV_DIR || local dir="$_p9k_pwd_a/$RBENV_DIR" while true; do if _p9k_read_rbenv_version_file $dir/.ruby-version; then v=$_p9k_ret @@ -1956,11 +1959,14 @@ prompt_rust_version() { _p9k_cached_cmd_stdout rustc --version || return local v=${${_p9k_ret#rustc }%% *} [[ -n $v ]] || return - local dir=$_p9k_pwd_a - while [[ ! -e $dir/Cargo.toml ]]; do - [[ $dir == / ]] && return - dir=${dir:h} - done + if (( _POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY )); then + local dir=$_p9k_pwd_a + while true; do + [[ $dir == / ]] && return + [[ -e $dir/Cargo.toml ]] && break + dir=${dir:h} + done + fi _p9k_prompt_segment "$0" "darkorange" "$_p9k_color1" 'RUST_ICON' 0 '' "${v//\%/%%}" } @@ -2744,7 +2750,7 @@ prompt_pyenv() { (( $+commands[pyenv] )) || return local v=${(j.:.)${(@)${(s.:.)PYENV_VERSION}#python-}} if [[ -z $v ]]; then - [[ $PYENV_DIR == /* ]] && local dir=$PYENV_DIR || local dir="$_p9k_pwd/$PYENV_DIR" + [[ $PYENV_DIR == /* ]] && local dir=$PYENV_DIR || local dir="$_p9k_pwd_a/$PYENV_DIR" while true; do if _p9k_read_pyenv_version_file $dir/.python-version; then v=$_p9k_ret @@ -3614,6 +3620,8 @@ _p9k_init_params() { _p9k_declare -i POWERLEVEL9K_LOAD_WHICH 5 _p9k_declare -b POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -b POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY 0 + _p9k_declare -b POWERLEVEL9K_GO_VERSION_PROJECT_ONLY 1 + _p9k_declare -b POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY 1 _p9k_declare -b POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -b POWERLEVEL9K_RVM_SHOW_GEMSET 0 _p9k_declare -b POWERLEVEL9K_RVM_SHOW_PREFIX 0 -- cgit v1.2.3 From 7dd52c276ca20701051938c463887ef3e4173485 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 12 Aug 2019 15:00:39 +0200 Subject: add two more faq entries that recommended the recommended font --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index 34e7e74a..579a9914 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ prompt. 1. [License](#license) 1. [FAQ](#faq) 1. [Why my icons and/or powerline symbols look bad?](#why-my-icons-andor-powerline-symbols-look-bad) + 1. [Why is my cursor in the wrong place?](#why-is-my-cursor-in-the-wrong-place) + 1. [Why is my right prompt wrapping around in a weird way?](why-is-my-right-prompt-wrapping-around-in-a-weird-way) 1. [I cannot install the recommended font. Help!](#i-cannot-install-the-recommended-font-help) 1. [Why do I have a question mark symbol in my prompt? Is my font broken?](#why-do-i-have-a-question-mark-symbol-in-my-prompt-is-my-font-broken) 1. [Why does Powerlevel10k spawn extra processes?](#why-does-powerlevel10k-spawn-extra-processes) @@ -192,6 +194,32 @@ It's likely your font's fault. [Install the recommended font](#recommended-meslo-nerd-font-patched-for-powerlevel10k) and run `p10k configure`. +### Why is my cursor in the wrong place? + +It's likely your font's fault. +[Install the recommended font](#recommended-meslo-nerd-font-patched-for-powerlevel10k) and run +`p10k configure`. + +If this doesn't help, type `unset ZLE_RPROMPT_INDENT`. If fixes the issue, make the change +permanent: + +```zsh +echo 'unset ZLE_RPROMPT_INDENT' >>! ~/.zshrc +``` + +### Why is my right prompt wrapping around in a weird way? + +It's likely your font's fault. +[Install the recommended font](#recommended-meslo-nerd-font-patched-for-powerlevel10k) and run +`p10k configure`. + +If this doesn't help, type `unset ZLE_RPROMPT_INDENT`. If fixes the issue, make the change +permanent: + +```zsh +echo 'unset ZLE_RPROMPT_INDENT' >>! ~/.zshrc +``` + ### I cannot install the recommended font. Help! Once you download [the recommended font](#recommended-meslo-nerd-font-patched-for-powerlevel10k), -- cgit v1.2.3 From 3da8913ff786a35ba1335b225dee3b9381549b84 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 12 Aug 2019 15:01:22 +0200 Subject: add missing # --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 579a9914..366d72c6 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ prompt. 1. [FAQ](#faq) 1. [Why my icons and/or powerline symbols look bad?](#why-my-icons-andor-powerline-symbols-look-bad) 1. [Why is my cursor in the wrong place?](#why-is-my-cursor-in-the-wrong-place) - 1. [Why is my right prompt wrapping around in a weird way?](why-is-my-right-prompt-wrapping-around-in-a-weird-way) + 1. [Why is my right prompt wrapping around in a weird way?](#why-is-my-right-prompt-wrapping-around-in-a-weird-way) 1. [I cannot install the recommended font. Help!](#i-cannot-install-the-recommended-font-help) 1. [Why do I have a question mark symbol in my prompt? Is my font broken?](#why-do-i-have-a-question-mark-symbol-in-my-prompt-is-my-font-broken) 1. [Why does Powerlevel10k spawn extra processes?](#why-does-powerlevel10k-spawn-extra-processes) -- cgit v1.2.3 From 7c57ca92e76fdd2cc53205342cf73fb1e2598ee0 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 13 Aug 2019 08:17:27 +0200 Subject: enable nvm prompt if function nvm is defined Same thing with a few other env prompts. Fixes #166. --- internal/p10k.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index b56c9da5..1c9b1b59 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1777,7 +1777,7 @@ _p9k_nvm_ls_current() { # Segment to display Node version from NVM # Only prints the segment if different than the default value prompt_nvm() { - (( $+commands[nvm] )) || return + (( $+commands[nvm] || $+functions[nvm] )) || return [[ -n $NVM_DIR ]] && _p9k_nvm_ls_current || return local current=$_p9k_ret ! _p9k_nvm_ls_default || [[ $_p9k_ret != $current ]] || return @@ -1821,7 +1821,7 @@ function _p9k_nodenv_global_version() { # Segment to display nodenv information # https://github.com/nodenv/nodenv prompt_nodenv() { - (( $+commands[nodenv] )) || return + (( $+commands[nodenv] || $+functions[nodenv] )) || return _p9k_ret=$NODENV_VERSION if [[ -z $_p9k_ret ]]; then [[ $NODENV_DIR == /* ]] && local dir=$NODENV_DIR || local dir="$_p9k_pwd_a/$NODENV_DIR" @@ -1909,7 +1909,7 @@ function _p9k_rbenv_global_version() { # Segment to display rbenv information # https://github.com/rbenv/rbenv#choosing-the-ruby-version prompt_rbenv() { - (( $+commands[rbenv] )) || return + (( $+commands[rbenv] || $+functions[rbenv] )) || return local v=$RBENV_VERSION if [[ -z $v ]]; then [[ $RBENV_DIR == /* ]] && local dir=$RBENV_DIR || local dir="$_p9k_pwd_a/$RBENV_DIR" @@ -1983,7 +1983,7 @@ prompt_rspec_stats() { ################################################################ # Segment to display Ruby Version Manager information prompt_rvm() { - (( $+commands[rvm-prompt] )) || return + (( $+commands[rvm-prompt] || $+functions[rvm-prompt] )) || return [[ $GEM_HOME == *rvm* && $ruby_string != $rvm_path/bin/ruby ]] || return local v=${GEM_HOME:t} (( _POWERLEVEL9K_RVM_SHOW_GEMSET )) || v=${v%%${rvm_gemset_separator:-@}*} @@ -2747,7 +2747,7 @@ function _p9k_pyenv_global_version() { # Segment to display pyenv information # https://github.com/pyenv/pyenv#choosing-the-python-version prompt_pyenv() { - (( $+commands[pyenv] )) || return + (( $+commands[pyenv] || $+functions[pyenv] )) || return local v=${(j.:.)${(@)${(s.:.)PYENV_VERSION}#python-}} if [[ -z $v ]]; then [[ $PYENV_DIR == /* ]] && local dir=$PYENV_DIR || local dir="$_p9k_pwd_a/$PYENV_DIR" -- cgit v1.2.3 From d68bd813aeba8d0c19f2ff4a04c50ce5971a9915 Mon Sep 17 00:00:00 2001 From: Roman Perepelitsa Date: Wed, 14 Aug 2019 05:08:43 +0200 Subject: spelling --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 366d72c6..0b90fa52 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ prompt. 1. [Fonts](#fonts) 1. [Recommended: Meslo Nerd Font patched for Powerlevel10k](#recommended-meslo-nerd-font-patched-for-powerlevel10k) 1. [Try it in Docker](#try-it-in-docker) -1. [Is it really faster?](#is-it-really-fast) +1. [Is it really fast?](#is-it-really-fast) 1. [License](#license) 1. [FAQ](#faq) 1. [Why my icons and/or powerline symbols look bad?](#why-my-icons-andor-powerline-symbols-look-bad) @@ -200,7 +200,7 @@ It's likely your font's fault. [Install the recommended font](#recommended-meslo-nerd-font-patched-for-powerlevel10k) and run `p10k configure`. -If this doesn't help, type `unset ZLE_RPROMPT_INDENT`. If fixes the issue, make the change +If this doesn't help, type `unset ZLE_RPROMPT_INDENT`. If it fixes the issue, make the change permanent: ```zsh @@ -213,7 +213,7 @@ It's likely your font's fault. [Install the recommended font](#recommended-meslo-nerd-font-patched-for-powerlevel10k) and run `p10k configure`. -If this doesn't help, type `unset ZLE_RPROMPT_INDENT`. If fixes the issue, make the change +If this doesn't help, type `unset ZLE_RPROMPT_INDENT`. If it fixes the issue, make the change permanent: ```zsh -- cgit v1.2.3 From 4ba78dc2be7bc5cb10231d5fbeefaa0f2967b0f4 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 14 Aug 2019 06:57:25 +0200 Subject: shorten git branch name if over 32 chars long; tune colors --- config/p10k-classic.zsh | 21 +++++++++++++-------- config/p10k-lean.zsh | 11 ++++++++--- internal/wizard.zsh | 6 ++++++ 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 1237a4b3..45b2a520 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -156,9 +156,9 @@ fi typeset -g POWERLEVEL9K_BACKGROUND=238 # Separator between same-color segments on the left. - typeset -g POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR='%244F\uE0B1' + typeset -g POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR='%246F\uE0B1' # Separator between same-color segments on the right. - typeset -g POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR='%244F\uE0B3' + typeset -g POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR='%246F\uE0B3' # Separator between different-color segments on the left. typeset -g POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\uE0B0' # Separator between different-color segments on the right. @@ -288,13 +288,18 @@ fi # VCS_STATUS parameters are set by gitstatus plugin. See reference: # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. local vcs='' - # 'feature' or '@72f5c8a' if not on a branch. - vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}'${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' - vcs+=':-%f@%76F${VCS_STATUS_COMMIT[1,8]}}' + # If on a branch... + vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON} + # If branch name is at most 32 characters long, show it in full. + vcs+='${${${$(($#VCS_STATUS_LOCAL_BRANCH<=32)):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' + # If branch name is over 32 characters long, show the first 12 … the last 12. + vcs+=':-${VCS_STATUS_LOCAL_BRANCH[1,12]//\%/%%}%28F…%76F${VCS_STATUS_LOCAL_BRANCH[-12,-1]//\%/%%}}}' + # '@72f5c8a' if not on a branch. + vcs+=':-%248F@%76F${VCS_STATUS_COMMIT[1,8]}}' # ':master' if the tracking branch name differs from local branch. - vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%f:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}' + vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%248F:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}' # '#tag' if on a tag. - vcs+='${VCS_STATUS_TAG:+%f#%76F${VCS_STATUS_TAG//\%/%%}}' + vcs+='${VCS_STATUS_TAG:+%248F#%76F${VCS_STATUS_TAG//\%/%%}}' # ⇣42 if behind the remote. vcs+='${${VCS_STATUS_COMMITS_BEHIND:#0}:+ %76F⇣${VCS_STATUS_COMMITS_BEHIND}}' # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. @@ -323,7 +328,6 @@ fi typeset -g POWERLEVEL9K_VCS_{CLEAN,UNTRACKED,MODIFIED}_CONTENT_EXPANSION=$vcs # When Git status is being refreshed asynchronously, display the last known repo status in grey. typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION=${${vcs//\%f}//\%<->F} - typeset -g POWERLEVEL9K_VCS_LOADING_FOREGROUND=244 # Enable counters for staged, unstaged, etc. typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 @@ -339,6 +343,7 @@ fi # isn't in an svn or hg reposotiry. typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) + typeset -g POWERLEVEL9K_VCS_LOADING_FOREGROUND=246 # These settings are used for respositories other than Git or when gitstatusd fails and # Powerlevel10k has to fall back to using vcs_info. typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76 diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index ea74b926..b383213c 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -271,8 +271,13 @@ fi # VCS_STATUS parameters are set by gitstatus plugin. See reference: # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. local vcs='' - # 'feature' or '@72f5c8a' if not on a branch. - vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}'${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' + # If on a branch... + vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON} + # If local branch name is at most 32 characters long, show it in full. + vcs+='${${${$(($#VCS_STATUS_LOCAL_BRANCH<=32)):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' + # If local branch name is over 32 characters long, show the first 12 … the last 12. + vcs+=':-${VCS_STATUS_LOCAL_BRANCH[1,12]//\%/%%}%28F…%76F${VCS_STATUS_LOCAL_BRANCH[-12,-1]//\%/%%}}}' + # '@72f5c8a' if not on a branch. vcs+=':-%f@%76F${VCS_STATUS_COMMIT[1,8]}}' # ':master' if the tracking branch name differs from local branch. vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%f:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}' @@ -306,7 +311,6 @@ fi typeset -g POWERLEVEL9K_VCS_{CLEAN,UNTRACKED,MODIFIED}_CONTENT_EXPANSION=$vcs # When Git status is being refreshed asynchronously, display the last known repo status in grey. typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION=${${vcs//\%f}//\%<->F} - typeset -g POWERLEVEL9K_VCS_LOADING_FOREGROUND=244 # Enable counters for staged, unstaged, etc. typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 @@ -322,6 +326,7 @@ fi # isn't in an svn or hg reposotiry. typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) + typeset -g POWERLEVEL9K_VCS_LOADING_FOREGROUND=244 # These settings are used for respositories other than Git or when gitstatusd fails and # Powerlevel10k has to fall back to using vcs_info. typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76 diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 5f9d6f96..364446b2 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -894,6 +894,10 @@ function generate_config() { lines=("${(@)lines/#(#b)([[:space:]]#)\# $1( |)/$match[1]$1$match[2]$match[2]}") } + function rep() { + lines=("${(@)lines//$1/$2}") + } + sub MODE $POWERLEVEL9K_MODE if (( cap_narrow_icons )); then @@ -936,6 +940,8 @@ function generate_config() { sub LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL "'$left_head'" sub RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL "'$right_head'" sub RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL "'$right_tail'" + sub VCS_LOADING_FOREGROUND $sep_color[$color] + rep '%248F' "%$prefix_color[$color]F" fi if [[ -n ${(j::)extra_icons} ]]; then -- cgit v1.2.3 From 620a20fc9f94a86a0abe5de793267463c9c162a7 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 14 Aug 2019 07:24:09 +0200 Subject: support branch shortening when using gitstatusd --- internal/p10k.zsh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 1c9b1b59..0c45ef5c 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1995,7 +1995,7 @@ prompt_rvm() { ################################################################ # Segment to display SSH icon when connected prompt_ssh() { - if [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then + if (( _P9K_SSH )); then _p9k_prompt_segment "$0" "$_p9k_color1" "yellow" 'SSH_ICON' 0 '' '' fi } @@ -2536,8 +2536,24 @@ function _p9k_vcs_render() { fi if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then - (( _POWERLEVEL9K_HIDE_BRANCH_ICON )) && _p9k_ret='' || _p9k_get_icon prompt_vcs_$state VCS_BRANCH_ICON - _$0_fmt BRANCH "$ws$_p9k_ret${VCS_STATUS_LOCAL_BRANCH//\%/%%}" + local branch=$ws + if (( !_POWERLEVEL9K_HIDE_BRANCH_ICON )); then + _p9k_get_icon prompt_vcs_$state VCS_BRANCH_ICON + branch+=$_p9k_ret + fi + if (( $+_POWERLEVEL9K_VCS_SHORTEN_LENGTH && $+_POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH && + $#VCS_STATUS_LOCAL_BRANCH > _POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH && + $#VCS_STATUS_LOCAL_BRANCH > _POWERLEVEL9K_VCS_SHORTEN_LENGTH )) && + [[ $_POWERLEVEL9K_VCS_SHORTEN_STRATEGY == (truncate_middle|truncate_from_right) ]]; then + branch+=${VCS_STATUS_LOCAL_BRANCH[1,_POWERLEVEL9K_VCS_SHORTEN_LENGTH]//\%/%%}${_POWERLEVEL9K_VCS_SHORTEN_DELIMITER} + if [[ $_POWERLEVEL9K_VCS_SHORTEN_STRATEGY == truncate_middle ]]; then + _p9k_vcs_style $state BRANCH + branch+=${_p9k_ret}${VCS_STATUS_LOCAL_BRANCH[-_POWERLEVEL9K_VCS_SHORTEN_LENGTH,-1]//\%/%%} + fi + else + branch+=${VCS_STATUS_LOCAL_BRANCH//\%/%%} + fi + _$0_fmt BRANCH $branch fi if [[ $_POWERLEVEL9K_VCS_HIDE_TAGS == 0 && -n $VCS_STATUS_TAG ]]; then @@ -3511,7 +3527,7 @@ _p9k_init_params() { _p9k_declare -i POWERLEVEL9K_VCS_SHORTEN_LENGTH _p9k_declare -i POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH _p9k_declare -s POWERLEVEL9K_VCS_SHORTEN_STRATEGY - _p9k_declare -s POWERLEVEL9K_VCS_SHORTEN_DELIMITER + _p9k_declare -e POWERLEVEL9K_VCS_SHORTEN_DELIMITER '\u2026' _p9k_declare -b POWERLEVEL9K_HIDE_BRANCH_ICON 0 _p9k_declare -b POWERLEVEL9K_VCS_HIDE_TAGS 0 _p9k_declare -i POWERLEVEL9K_CHANGESET_HASH_LENGTH 8 -- cgit v1.2.3 From 5f63a9658128c42b02d126b60893206699ea5675 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 16 Aug 2019 09:52:11 +0200 Subject: spello --- config/p10k-classic.zsh | 2 +- config/p10k-lean.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 45b2a520..461ff82d 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -429,7 +429,7 @@ fi # Context format when running with privileges: %n is username, %m is hostname. typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%n@%m' - # Don't show context unless running with privileges on in SSH. + # Don't show context unless running with privileges or in SSH. typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= typeset -g POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index b383213c..ceb802e4 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -412,7 +412,7 @@ fi # Context format when running with privileges: %n is username, %m is hostname. typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%n@%m' - # Don't show context unless running with privileges on in SSH. + # Don't show context unless running with privileges or in SSH. typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= typeset -g POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true -- cgit v1.2.3 From e6d0da1c2e1b95e2a0169b7abcd6ef8b7650b4bf Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 16 Aug 2019 09:54:32 +0200 Subject: remove POWERLEVEL9K_ALWAYS_SHOW_CONTEXT from configs as it confuses users --- config/p10k-classic.zsh | 1 - config/p10k-lean.zsh | 1 - 2 files changed, 2 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 461ff82d..affca816 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -431,7 +431,6 @@ fi # Don't show context unless running with privileges or in SSH. typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= - typeset -g POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true # Custom icon. # typeset -g POWERLEVEL9K_CONTEXT_VISUAL_IDENTIFIER_EXPANSION='⭐' diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index ceb802e4..5b4183ff 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -414,7 +414,6 @@ fi # Don't show context unless running with privileges or in SSH. typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= - typeset -g POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true # Custom icon. # typeset -g POWERLEVEL9K_CONTEXT_VISUAL_IDENTIFIER_EXPANSION='⭐' -- cgit v1.2.3 From 96ba1b6f7d54b455c008b61318c97ec0965b0033 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 16 Aug 2019 20:26:28 +0200 Subject: bug fix: don't hide command execution status on reset-prompt fixes #171 --- internal/p10k.zsh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 0c45ef5c..5e8d7a27 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1151,8 +1151,7 @@ _p9k_custom_prompt() { ################################################################ # Display the duration the command needed to run. prompt_command_execution_time() { - (( _p9k_timer_start )) || return - P9K_COMMAND_DURATION_SECONDS=$((_p9k_timer_end - _p9k_timer_start)) + (( $+P9K_COMMAND_DURATION_SECONDS )) || return (( P9K_COMMAND_DURATION_SECONDS >= _POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD )) || return if (( P9K_COMMAND_DURATION_SECONDS < 60 )); then @@ -3240,6 +3239,11 @@ _p9k_precmd() { setopt nopromptbang prompt{cr,percent,sp,subst} _p9k_timer_end=EPOCHREALTIME + if (( _p9k_timer_start )); then + typeset -gF P9K_COMMAND_DURATION_SECONDS=$((_p9k_timer_end - _p9k_timer_start)) + else + unset P9K_COMMAND_DURATION_SECONDS + fi _p9k_save_status powerlevel9k_refresh_prompt_inplace @@ -3506,7 +3510,6 @@ _p9k_init_vars() { typeset -g _p9k_pwd typeset -g _p9k_pwd_a - typeset -gF P9K_COMMAND_DURATION_SECONDS typeset -g P9K_VISUAL_IDENTIFIER typeset -g P9K_CONTENT typeset -g P9K_GAP -- cgit v1.2.3 From 33e1dd77908c0ae9a12b07b8e88f4ae16a9e53bd Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 17 Aug 2019 09:22:31 +0200 Subject: Try harder when running on a system with incorrectly configured locale. ZSH will still be broken when locale is misconfigured but at least p10k will work so users will look for help elsewhere. Fixes #173. --- config/p10k-classic.zsh | 4 +++- config/p10k-lean.zsh | 4 +++- internal/icons.zsh | 6 ++++++ internal/p10k.zsh | 16 ++++++++-------- internal/wizard.zsh | 4 +++- 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index affca816..7d73e965 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -16,7 +16,9 @@ fi () { emulate -L zsh setopt no_unset - local LC_ALL=C.UTF-8 + if [[ ${LC_ALL:-${LANG:-}} != *.(utf|UTF)(-|)8 ]]; then + local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} + fi # Unset all configuration options. This allows you to apply configiguration changes without # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 5b4183ff..2a9f8f2a 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -16,7 +16,9 @@ fi () { emulate -L zsh setopt no_unset - local LC_ALL=C.UTF-8 + if [[ ${LC_ALL:-${LANG:-}} != *.(utf|UTF)(-|)8 ]]; then + local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} + fi # Unset all configuration options. This allows you to apply configiguration changes without # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. diff --git a/internal/icons.zsh b/internal/icons.zsh index 55d1b33e..2b47339d 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -3,6 +3,10 @@ typeset -gA icons function _p9k_init_icons() { [[ $+_p9k_icon_mode == 1 && $_p9k_icon_mode == $POWERLEVEL9K_MODE ]] && return typeset -g _p9k_icon_mode=$POWERLEVEL9K_MODE + typeset -g _p9k_locale=${LC_ALL:-$LANG} + if [[ $_p9k_locale != *.(utf|UTF)(-|)8 ]]; then + _p9k_locale=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} + fi case $POWERLEVEL9K_MODE in 'flat'|'awesome-patched') @@ -521,6 +525,7 @@ function _p9k_init_icons() { function print_icon() { emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} _p9k_init_icons + local LC_ALL=$_p9k_locale local icon_name=$1 local var_name=POWERLEVEL9K_${icon_name} if [[ -n "${(tP)var_name}" ]]; then @@ -538,6 +543,7 @@ function print_icon() { function get_icon_names() { emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} _p9k_init_icons + local LC_ALL=$_p9k_locale # Iterate over a ordered list of keys of the icons array for key in ${(@kon)icons}; do echo -n "POWERLEVEL9K_$key: " diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 5e8d7a27..16f2452c 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -147,7 +147,7 @@ function _p9k_declare() { (( set )) && typeset -g _$2=${(P)2} || typeset -g _$2=$3 ;; -e) - local LC_ALL=C.UTF-8 + local LC_ALL=$_p9k_locale if (( set )); then local v=${(P)2} typeset -g _$2=${(g::)v} @@ -330,7 +330,7 @@ _p9k_get_icon() { if [[ $_p9k_ret == $'\1'* ]]; then _p9k_ret=${_p9k_ret[2,-1]} else - local LC_ALL=C.UTF-8 + local LC_ALL=$_p9k_locale _p9k_ret=${(g::)_p9k_ret} [[ $_p9k_ret != $'\b'? ]] || _p9k_ret="%{$_p9k_ret%}" # penance for past sins fi @@ -551,7 +551,7 @@ _p9k_left_prompt_segment() { p+='${${_p9k_e:#00}:+${${_p9k_t[$_p9k_n]/'$ss'/$_p9k_ss}/'$s'/$_p9k_s}' - local LC_ALL=C.UTF-8 + local LC_ALL=$_p9k_locale _p9k_param $1 ICON_BEFORE_CONTENT '' if [[ $_p9k_ret != false ]]; then _p9k_param $1 PREFIX '' @@ -752,7 +752,7 @@ _p9k_right_prompt_segment() { p+='${${_p9k_e:#00}:+${_p9k_t[$_p9k_n]/'$w'/$_p9k_w}' - local LC_ALL=C.UTF-8 + local LC_ALL=$_p9k_locale _p9k_param $1 ICON_BEFORE_CONTENT '' if [[ $_p9k_ret != true ]]; then _p9k_param $1 PREFIX '' @@ -1091,7 +1091,7 @@ prompt_context() { if [[ -z $content ]]; then local var=POWERLEVEL9K_CONTEXT_${state}_TEMPLATE if (( $+parameters[$var] )); then - local LC_ALL=C.UTF-8 + local LC_ALL=$_p9k_locale content=${(P)var} content=${(g::)content} else @@ -3553,7 +3553,7 @@ _p9k_init_params() { if [[ $parameters[POWERLEVEL9K_BATTERY_STAGES] == scalar ]]; then _p9k_declare -e POWERLEVEL9K_BATTERY_STAGES else - local LC_ALL=C.UTF-8 + local LC_ALL=$_p9k_locale _p9k_declare -a POWERLEVEL9K_BATTERY_STAGES -- _POWERLEVEL9K_BATTERY_STAGES=("${(@g::)_POWERLEVEL9K_BATTERY_STAGES}") fi @@ -3816,7 +3816,7 @@ _p9k_build_gap_post() { } _p9k_init_lines() { - local LC_ALL=C.UTF-8 + local LC_ALL=$_p9k_locale local -a left_segments=($_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS) local -a right_segments=($_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS) @@ -4223,7 +4223,7 @@ _p9k_init() { if _p9k_segment_in_use dir; then if (( $+_POWERLEVEL9K_DIR_CLASSES )); then - local LC_ALL=C.UTF-8 + local LC_ALL=$_p9k_locale local -i i=3 for ((; i <= $#_POWERLEVEL9K_DIR_CLASSES; i+=3)); do _POWERLEVEL9K_DIR_CLASSES[i]=${(g::)_POWERLEVEL9K_DIR_CLASSES[i]} diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 364446b2..b6bbd445 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -5,7 +5,9 @@ setopt noaliases () { setopt extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} -local LC_ALL=C.UTF-8 +if [[ ${LC_ALL:-$LANG} != *.(utf|UTF)(-|)8 ]]; then + local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} +fi typeset -g __p9k_root_dir typeset -gi force=0 -- cgit v1.2.3 From 49063ee757c2339c2a0cde14e886896373cd6a54 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 17 Aug 2019 10:01:06 +0200 Subject: add ranger prompt; see #171 --- config/p10k-classic.zsh | 7 +++++++ config/p10k-lean.zsh | 7 +++++++ internal/icons.zsh | 5 +++++ internal/p10k.zsh | 5 +++++ 4 files changed, 24 insertions(+) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 7d73e965..24b73abb 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -58,6 +58,7 @@ fi kubecontext # current kubernetes context (https://kubernetes.io/) context # user@host nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) + ranger # ranger shell (https://github.com/ranger/ranger) # =========================[ Line #2 ]========================= newline # public_ip # public IP address @@ -420,6 +421,12 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_NORDVPN_VISUAL_IDENTIFIER_EXPANSION='⭐' + #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]################## + # Ranger shell color. + typeset -g POWERLEVEL9K_RANGER_FOREGROUND=221 + # Custom icon. + # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' + ####################################[ context: user@host ]#################################### # Default context color. typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=180 diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 2a9f8f2a..420ef42c 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -58,6 +58,7 @@ fi kubecontext # current kubernetes context (https://kubernetes.io/) context # user@host nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) + ranger # ranger shell (https://github.com/ranger/ranger) # =========================[ Line #2 ]========================= newline # public_ip # public IP address @@ -403,6 +404,12 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_NORDVPN_VISUAL_IDENTIFIER_EXPANSION='⭐' + #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]################## + # Ranger shell color. + typeset -g POWERLEVEL9K_RANGER_FOREGROUND=221 + # Custom icon. + # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' + ####################################[ context: user@host ]#################################### # Default context color. typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=180 diff --git a/internal/icons.zsh b/internal/icons.zsh index 2b47339d..3693bfb3 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -108,6 +108,7 @@ function _p9k_init_icons() { TIME_ICON '\uE12E' #  JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' + RANGER_ICON '\u2B50' # ⭐ ) ;; 'awesome-fontconfig') @@ -205,6 +206,7 @@ function _p9k_init_icons() { TIME_ICON '\uF017 ' #  JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' + RANGER_ICON '\u2B50' # ⭐ ) ;; 'awesome-mapped-fontconfig') @@ -306,6 +308,7 @@ function _p9k_init_icons() { TIME_ICON '\uF017 ' #  JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' + RANGER_ICON '\u2B50' # ⭐ ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -404,6 +407,7 @@ function _p9k_init_icons() { TIME_ICON '\uF017 ' #  JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '\ue73f ' #  + RANGER_ICON '\u2B50' # ⭐ ) ;; *) @@ -501,6 +505,7 @@ function _p9k_init_icons() { TIME_ICON '' JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' + RANGER_ICON '\u2B50' # ⭐ ) ;; esac diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 16f2452c..3b7897ca 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3034,6 +3034,11 @@ function prompt_nordvpn() { esac } +function prompt_ranger() { + [[ -n $RANGER_LEVEL ]] || return + _p9k_prompt_segment $0 $_p9k_color1 yellow RANGER_ICON 0 '' $RANGER_LEVEL +} + _p9k_preexec() { if (( $+_p9k_real_zle_rprompt_indent )); then if [[ -n $_p9k_real_zle_rprompt_indent ]]; then -- cgit v1.2.3 From 3434c0e0a92c7b4840782fff5d4532dff9f290ee Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 19 Aug 2019 10:52:41 +0200 Subject: correctly deduce p10k directory when using zprezto with zsh 5.1 see #174 --- powerlevel9k.zsh-theme | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 6bef5f39..6e4969d7 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -17,36 +17,16 @@ else local __p9k_restore_aliases=0 fi +typeset -g __p9k_root_dir=${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}} + () { emulate -L zsh setopt no_hist_expand extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} - if (( $+__p9k_sourced )); then prompt_powerlevel9k_setup return fi typeset -gr __p9k_sourced=1 - typeset -g __p9k_root_dir='' - - if [[ -n $POWERLEVEL9K_INSTALLATION_DIR ]]; then - __p9k_root_dir=${POWERLEVEL9K_INSTALLATION_DIR:A} - else - if [[ ${(%):-%N} == '(eval)' ]]; then - if [[ $0 == '-antigen-load' && -r powerlevel9k.zsh-theme ]]; then - # Antigen uses eval to load things so it can change the plugin (!!) - # https://github.com/zsh-users/antigen/issues/581 - __p9k_root_dir=$PWD - else - >&2 print -P '%F{red}[ERROR]%f Powerlevel10k cannot figure out its installation directory.' - >&2 print -P 'Please set %F{green}POWERLEVEL9K_INSTALLATION_DIR.%f' - return - fi - else - __p9k_root_dir=${${(%):-%x}:A:h} - fi - fi - - typeset -gr __p9k_root_dir source $__p9k_root_dir/internal/p10k.zsh || true } -- cgit v1.2.3 From 925ade3d2946cdf7343a093d91ed0849d5aad693 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 19 Aug 2019 12:18:11 +0200 Subject: make ZLE_RPROMPT_INDENT emulation condition less strict --- internal/p10k.zsh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 3b7897ca..7ba7b69d 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3934,6 +3934,13 @@ _p9k_init_lines() { fi } +_p9k_all_params_eq() { + local key + for key in ${parameters[(I)${~1}]}; do + [[ ${(P)key} == $2 ]] || return + done +} + _p9k_init_prompt() { _p9k_init_lines @@ -3958,9 +3965,11 @@ _p9k_init_prompt() { # If affects most terminals when RPROMPT is non-empty and ZLE_RPROMPT_INDENT is zero. # We can work around it as long as RPROMPT ends with a space. if [[ -n $_p9k_line_segments_right[-1] && $_p9k_line_never_empty_right[-1] == 0 && - $ZLE_RPROMPT_INDENT == 0 && ${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS:- } == ' ' && - -z "$(typeset -m 'POWERLEVEL9K_*(RIGHT_RIGHT_WHITESPACE|RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL)')" ]] && - ! is-at-least 5.7.2; then + $ZLE_RPROMPT_INDENT == 0 ]] && + _p9k_all_params_eq 'POWERLEVEL9K_*WHITESPACE_BETWEEN_RIGHT_SEGMENTS' ' ' && + _p9k_all_params_eq 'POWERLEVEL9K_*RIGHT_RIGHT_WHITESPACE' ' ' && + _p9k_all_params_eq 'POWERLEVEL9K_*RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL' '' && + ! is-at-least 5.7.2; then _p9k_emulate_zero_rprompt_indent=1 _p9k_prompt_prefix_left+='${${:-${_p9k_real_zle_rprompt_indent:=$ZLE_RPROMPT_INDENT}${ZLE_RPROMPT_INDENT::=1}${_p9k_ind::=0}}+}' _p9k_line_suffix_right[-1]='${_p9k_sss:+${_p9k_sss% }%E}' -- cgit v1.2.3 From 37c6ea091e0cc64f6741ca874d91db5ad579406f Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 19 Aug 2019 13:54:42 +0200 Subject: make all colors visible on white and solarized-light background; see #177 --- config/p10k-classic.zsh | 18 +++++++++--------- config/p10k-lean.zsh | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 24b73abb..532a1a08 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -270,8 +270,8 @@ fi # FOREGROUND, SHORTENED_FOREGROUND and ANCHOR_FOREGROUND for every directory class that you wish # to have its own color. # - # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=12 - # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=4 + # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=31 + # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=103 # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=39 # # typeset -g POWERLEVEL9K_DIR_CLASSES=() @@ -315,9 +315,9 @@ fi # ~42 if have merge conflicts. vcs+='${${VCS_STATUS_NUM_CONFLICTED:#0}:+ %196F~${VCS_STATUS_NUM_CONFLICTED}}' # +42 if have staged changes. - vcs+='${${VCS_STATUS_NUM_STAGED:#0}:+ %227F+${VCS_STATUS_NUM_STAGED}}' + vcs+='${${VCS_STATUS_NUM_STAGED:#0}:+ %178F+${VCS_STATUS_NUM_STAGED}}' # !42 if have unstaged changes. - vcs+='${${VCS_STATUS_NUM_UNSTAGED:#0}:+ %227F!${VCS_STATUS_NUM_UNSTAGED}}' + vcs+='${${VCS_STATUS_NUM_UNSTAGED:#0}:+ %178F!${VCS_STATUS_NUM_UNSTAGED}}' # ?42 if have untracked files. It's really a question mark, your font isn't broken. # See POWERLEVEL9K_VCS_UNTRACKED_ICON below if you want to use a different icon. # Remove the next line if you don't want to see untracked files at all. @@ -351,7 +351,7 @@ fi # Powerlevel10k has to fall back to using vcs_info. typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76 typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=76 - typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=227 + typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=178 ##########################[ status: exit code of the last command ]########################### # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and @@ -423,7 +423,7 @@ fi #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]################## # Ranger shell color. - typeset -g POWERLEVEL9K_RANGER_FOREGROUND=221 + typeset -g POWERLEVEL9K_RANGER_FOREGROUND=178 # Custom icon. # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' @@ -434,7 +434,7 @@ fi typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m' # Context color when running with privileges. - typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=227 + typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178 # Context format when running with privileges: %n is username, %m is hostname. typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%n@%m' @@ -557,7 +557,7 @@ fi # # You can define different colors, icons and content expansions for different classes: # - # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_FOREGROUND=2 + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_FOREGROUND=28 # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( @@ -621,7 +621,7 @@ fi ################################[ battery: internal battery ]################################# # Show battery in red when it's below this level and not connected to power supply. typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 - typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=1 + typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=160 # Show battery in green when it's charging. typeset -g POWERLEVEL9K_BATTERY_CHARGING_FOREGROUND=2 # Show battery in yellow when not connected to power supply. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 420ef42c..f55781a9 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -253,8 +253,8 @@ fi # FOREGROUND, SHORTENED_FOREGROUND and ANCHOR_FOREGROUND for every directory class that you wish # to have its own color. # - # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=12 - # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=4 + # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=31 + # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=103 # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=39 # # typeset -g POWERLEVEL9K_DIR_CLASSES=() @@ -298,9 +298,9 @@ fi # ~42 if have merge conflicts. vcs+='${${VCS_STATUS_NUM_CONFLICTED:#0}:+ %196F~${VCS_STATUS_NUM_CONFLICTED}}' # +42 if have staged changes. - vcs+='${${VCS_STATUS_NUM_STAGED:#0}:+ %227F+${VCS_STATUS_NUM_STAGED}}' + vcs+='${${VCS_STATUS_NUM_STAGED:#0}:+ %178F+${VCS_STATUS_NUM_STAGED}}' # !42 if have unstaged changes. - vcs+='${${VCS_STATUS_NUM_UNSTAGED:#0}:+ %227F!${VCS_STATUS_NUM_UNSTAGED}}' + vcs+='${${VCS_STATUS_NUM_UNSTAGED:#0}:+ %178F!${VCS_STATUS_NUM_UNSTAGED}}' # ?42 if have untracked files. It's really a question mark, your font isn't broken. # See POWERLEVEL9K_VCS_UNTRACKED_ICON below if you want to use a different icon. # Remove the next line if you don't want to see untracked files at all. @@ -334,7 +334,7 @@ fi # Powerlevel10k has to fall back to using vcs_info. typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76 typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=76 - typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=227 + typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=178 ##########################[ status: exit code of the last command ]########################### # Status on success. No content, just an icon. @@ -406,7 +406,7 @@ fi #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]################## # Ranger shell color. - typeset -g POWERLEVEL9K_RANGER_FOREGROUND=221 + typeset -g POWERLEVEL9K_RANGER_FOREGROUND=178 # Custom icon. # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' @@ -417,7 +417,7 @@ fi typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m' # Context color when running with privileges. - typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=227 + typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178 # Context format when running with privileges: %n is username, %m is hostname. typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%n@%m' @@ -540,7 +540,7 @@ fi # # You can define different colors, icons and content expansions for different classes: # - # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_FOREGROUND=2 + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_FOREGROUND=28 # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( @@ -604,7 +604,7 @@ fi ################################[ battery: internal battery ]################################# # Show battery in red when it's below this level and not connected to power supply. typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 - typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=1 + typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=160 # Show battery in green when it's charging. typeset -g POWERLEVEL9K_BATTERY_CHARGING_FOREGROUND=70 # Show battery in yellow when not connected to power supply. -- cgit v1.2.3 From 4c12eb7224b053a511a06da0b3efe26f067a4942 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 19 Aug 2019 16:07:59 +0200 Subject: add terraform prompt segment --- config/p10k-classic.zsh | 7 +++++++ config/p10k-lean.zsh | 7 +++++++ internal/icons.zsh | 5 +++++ internal/p10k.zsh | 12 ++++++++++++ 4 files changed, 31 insertions(+) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 532a1a08..5eb4f7de 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -56,6 +56,7 @@ fi rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rvm # ruby version from rvm (https://rvm.io) kubecontext # current kubernetes context (https://kubernetes.io/) + terraform # terraform workspace (https://www.terraform.io) context # user@host nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) @@ -540,6 +541,12 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + ################[ terraform: terraform workspace (https://www.terraform.io) ]################# + # Terraform color. + typeset -g POWERLEVEL9K_TERRAFORM_FOREGROUND=38 + # Custom icon. + # typeset -g POWERLEVEL9K_TERRAFORM_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# # Kubernetes context classes for the purpose of using different colors, icons and expansions with # different contexts. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index f55781a9..8704c59b 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -56,6 +56,7 @@ fi rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rvm # ruby version from rvm (https://rvm.io) kubecontext # current kubernetes context (https://kubernetes.io/) + terraform # terraform workspace (https://www.terraform.io) context # user@host nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) @@ -595,6 +596,12 @@ fi # Custom prefix. # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%fat ' + ################[ terraform: terraform workspace (https://www.terraform.io) ]################# + # Terraform color. + typeset -g POWERLEVEL9K_TERRAFORM_FOREGROUND=38 + # Custom icon. + # typeset -g POWERLEVEL9K_TERRAFORM_VISUAL_IDENTIFIER_EXPANSION='⭐' + ###############################[ public_ip: public IP address ]############################### # Public IP color. typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=94 diff --git a/internal/icons.zsh b/internal/icons.zsh index 3693bfb3..52155cab 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -109,6 +109,7 @@ function _p9k_init_icons() { JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ + TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ ) ;; 'awesome-fontconfig') @@ -207,6 +208,7 @@ function _p9k_init_icons() { JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ + TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ ) ;; 'awesome-mapped-fontconfig') @@ -309,6 +311,7 @@ function _p9k_init_icons() { JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ + TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -408,6 +411,7 @@ function _p9k_init_icons() { JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '\ue73f ' #  RANGER_ICON '\u2B50' # ⭐ + TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ ) ;; *) @@ -506,6 +510,7 @@ function _p9k_init_icons() { JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ + TERRAFORM_ICON 'TF' ) ;; esac diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 7ba7b69d..698a45c6 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3039,6 +3039,18 @@ function prompt_ranger() { _p9k_prompt_segment $0 $_p9k_color1 yellow RANGER_ICON 0 '' $RANGER_LEVEL } +function prompt_terraform() { + (( $+commands[terraform] )) || return + local ws=default + if [[ -n $TF_WORKSPACE ]]; then + ws=$TF_WORKSPACE + else + local f=${TF_DATA_DIR:-.terraform}/environment + [[ -r $f ]] && _p9k_read_file $f && ws=$_p9k_ret + fi + [[ $ws == default ]] || _p9k_prompt_segment $0 $_p9k_color1 blue TERRAFORM_ICON 0 '' $ws +} + _p9k_preexec() { if (( $+_p9k_real_zle_rprompt_indent )); then if [[ -n $_p9k_real_zle_rprompt_indent ]]; then -- cgit v1.2.3 From b3010c015648712568bd7a5377eec585bba6fbc7 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 19 Aug 2019 16:09:56 +0200 Subject: use hammer and wrench emoji for terraform with all fonts --- internal/icons.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/icons.zsh b/internal/icons.zsh index 52155cab..e93712c4 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -510,7 +510,7 @@ function _p9k_init_icons() { JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ - TERRAFORM_ICON 'TF' + TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ ) ;; esac -- cgit v1.2.3 From 3090ae6633aedc50b43524e6c2ce1482b0a15772 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 19 Aug 2019 16:35:26 +0200 Subject: trip terraform whitespace --- internal/p10k.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 698a45c6..437a87cf 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3048,6 +3048,7 @@ function prompt_terraform() { local f=${TF_DATA_DIR:-.terraform}/environment [[ -r $f ]] && _p9k_read_file $f && ws=$_p9k_ret fi + ws=${${ws##[[:space:]]#}%%[[:space:]]#} [[ $ws == default ]] || _p9k_prompt_segment $0 $_p9k_color1 blue TERRAFORM_ICON 0 '' $ws } -- cgit v1.2.3 From 727d42ff489f9be998df97e90f4356b2faaffbc5 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 20 Aug 2019 11:19:11 +0200 Subject: expose P9K_SSH and make it available as soon as p10k is sourced --- internal/p10k.zsh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 437a87cf..467985d7 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1062,7 +1062,7 @@ prompt_context() { if ! _p9k_cache_get $0 "${(%):-%#}"; then local -i enabled=1 local content - if [[ $_POWERLEVEL9K_ALWAYS_SHOW_CONTEXT == 0 && -n $DEFAULT_USER && $_P9K_SSH == 0 ]]; then + if [[ $_POWERLEVEL9K_ALWAYS_SHOW_CONTEXT == 0 && -n $DEFAULT_USER && $P9K_SSH == 0 ]]; then local user="$(whoami)" if [[ $user == $DEFAULT_USER ]]; then if (( _POWERLEVEL9K_ALWAYS_SHOW_USER )); then @@ -1078,7 +1078,7 @@ prompt_context() { state="DEFAULT" if [[ "${(%):-%#}" == '#' ]]; then state="ROOT" - elif (( _P9K_SSH )); then + elif (( P9K_SSH )); then if [[ -n "$SUDO_COMMAND" ]]; then state="REMOTE_SUDO" else @@ -1128,7 +1128,7 @@ prompt_user() { ################################################################ # Host: machine (where am I) prompt_host() { - if (( _P9K_SSH )); then + if (( P9K_SSH )); then _p9k_prompt_segment "$0_REMOTE" "${_p9k_color1}" yellow SSH_ICON 0 '' "$_POWERLEVEL9K_HOST_TEMPLATE" else _p9k_prompt_segment "$0_LOCAL" "${_p9k_color1}" yellow HOST_ICON 0 '' "$_POWERLEVEL9K_HOST_TEMPLATE" @@ -1994,7 +1994,7 @@ prompt_rvm() { ################################################################ # Segment to display SSH icon when connected prompt_ssh() { - if (( _P9K_SSH )); then + if (( P9K_SSH )); then _p9k_prompt_segment "$0" "$_p9k_color1" "yellow" 'SSH_ICON' 0 '' '' fi } @@ -4039,25 +4039,27 @@ _p9k_init_ssh() { # # License: https://github.com/sindresorhus/pure/blob/e8abf9d37185ec9b7b4398ca9c5eba555a1028eb/license. - [[ -n $_P9K_SSH ]] && return - export _P9K_SSH=0 + [[ -n $P9K_SSH ]] && return + typeset -gix P9K_SSH=0 if [[ -n $SSH_CLIENT || -n $SSH_TTY || -n $SSH_CONNECTION ]]; then - _P9K_SSH=1 + P9K_SSH=1 return fi # When changing user on a remote system, the $SSH_CONNECTION environment variable can be lost. # Attempt detection via `who`. (( $+commands[who] )) || return - local w && w="$(who -m 2>/dev/null)" || w=${(@M)${(f)"$(who 2>/dev/null)"}:#*[[:space:]]${TTY#/dev/}[[:space:]]*} local ipv6='(([0-9a-fA-F]+:)|:){2,}[0-9a-fA-F]+' # Simplified, only checks partial pattern. local ipv4='([0-9]{1,3}\.){3}[0-9]+' # Simplified, allows invalid ranges. # Assume two non-consecutive periods represents a hostname. Matches `x.y.z`, but not `x.y`. local hostname='([.][^. ]+){2}' + local w + w="$(who -m 2>/dev/null)" || w=${(@M)${(f)"$(who 2>/dev/null)"}:#*[[:space:]]${TTY#/dev/}[[:space:]]*} + # Usually the remote address is surrounded by parenthesis but not on all systems (e.g., Busybox). - [[ $w =~ "\(?($ipv4|$ipv6|$hostname)\)?\$" ]] && _P9K_SSH=1 + [[ $w =~ "\(?($ipv4|$ipv6|$hostname)\)?\$" ]] && P9K_SSH=1 } _p9k_must_init() { @@ -4086,7 +4088,6 @@ _p9k_init() { _p9k_init_vars _p9k_init_params _p9k_init_prompt - _p9k_init_ssh local uname="$(uname)" if [[ $uname == Linux && "$(uname -o 2>/dev/null)" == Android ]]; then @@ -4505,4 +4506,5 @@ zmodload zsh/system zmodload -F zsh/stat b:zstat zmodload -F zsh/net/socket b:zsocket +_p9k_init_ssh prompt_powerlevel9k_setup -- cgit v1.2.3 From a5e9af847d7052d920a340e12b823e600ae10a9e Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 20 Aug 2019 14:22:27 +0200 Subject: simplify nordvpn --- internal/p10k.zsh | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 467985d7..30499b66 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -2954,12 +2954,11 @@ function _p9k_fetch_nordvpn_status() { IFS='' read -t 0.25 -r tag <&3 tag=$'\015' while true; do - tag=${__p9k_char2byte[${(q+)tag}]:-0} + tag=$((#tag)) (( (tag >>= 3) && tag <= $#__p9k_nordvpn_tag )) || break tag=$__p9k_nordvpn_tag[tag] sysread -c n -s 1 -t 0.25 len <&3 - len=${__p9k_char2byte[${(q+)len}]} - [[ -n $len ]] + len=$((#len)) val= (( ! len )) || { sysread -c n -s $len -t 0.25 val <&3 @@ -4281,18 +4280,6 @@ _p9k_init() { print -rP -- 'Either install %F{green}jq%f or change the value of %BPOWERLEVEL9K_SHORTEN_STRATEGY%b.' fi - # There is no q+ flag before 5.3. - if (( !$+__p9k_char2byte )) && _p9k_segment_in_use nordvpn && is-at-least 5.3; then - typeset -gA __p9k_char2byte=() - local -i x=0 y=0 - for x in {0..7}; do - for y in {0..7}; do - __p9k_char2byte[${(q+)${(g:o:):-\\$x$y}}]=$((8*x+y)) - done - done - typeset -grA __p9k_char2byte - fi - if _p9k_segment_in_use status; then typeset -g _p9k_exitcode2str=({0..255}) local -i i=2 -- cgit v1.2.3 From e537a0ee628341741f20a7d2d96ea1c4fac74c4a Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 20 Aug 2019 14:56:43 +0200 Subject: better utf-8 handling --- config/p10k-classic.zsh | 3 ++- config/p10k-lean.zsh | 3 ++- internal/icons.zsh | 12 +++++++----- internal/p10k.zsh | 16 ++++++++-------- internal/wizard.zsh | 3 ++- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 5eb4f7de..6be7c45c 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -16,7 +16,8 @@ fi () { emulate -L zsh setopt no_unset - if [[ ${LC_ALL:-${LANG:-}} != *.(utf|UTF)(-|)8 ]]; then + zmodload zsh/langinfo + if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} fi diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 8704c59b..696d6a4e 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -16,7 +16,8 @@ fi () { emulate -L zsh setopt no_unset - if [[ ${LC_ALL:-${LANG:-}} != *.(utf|UTF)(-|)8 ]]; then + zmodload zsh/langinfo + if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} fi diff --git a/internal/icons.zsh b/internal/icons.zsh index e93712c4..fd2ab1be 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -3,9 +3,11 @@ typeset -gA icons function _p9k_init_icons() { [[ $+_p9k_icon_mode == 1 && $_p9k_icon_mode == $POWERLEVEL9K_MODE ]] && return typeset -g _p9k_icon_mode=$POWERLEVEL9K_MODE - typeset -g _p9k_locale=${LC_ALL:-$LANG} - if [[ $_p9k_locale != *.(utf|UTF)(-|)8 ]]; then - _p9k_locale=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} + zmodload zsh/langinfo + if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then + typeset -g _p9k_locale=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} + else + typeset -g _p9k_locale= fi case $POWERLEVEL9K_MODE in @@ -535,7 +537,7 @@ function _p9k_init_icons() { function print_icon() { emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} _p9k_init_icons - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale local icon_name=$1 local var_name=POWERLEVEL9K_${icon_name} if [[ -n "${(tP)var_name}" ]]; then @@ -553,7 +555,7 @@ function print_icon() { function get_icon_names() { emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} _p9k_init_icons - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale # Iterate over a ordered list of keys of the icons array for key in ${(@kon)icons}; do echo -n "POWERLEVEL9K_$key: " diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 30499b66..255919a4 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -147,7 +147,7 @@ function _p9k_declare() { (( set )) && typeset -g _$2=${(P)2} || typeset -g _$2=$3 ;; -e) - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale if (( set )); then local v=${(P)2} typeset -g _$2=${(g::)v} @@ -330,7 +330,7 @@ _p9k_get_icon() { if [[ $_p9k_ret == $'\1'* ]]; then _p9k_ret=${_p9k_ret[2,-1]} else - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale _p9k_ret=${(g::)_p9k_ret} [[ $_p9k_ret != $'\b'? ]] || _p9k_ret="%{$_p9k_ret%}" # penance for past sins fi @@ -551,7 +551,7 @@ _p9k_left_prompt_segment() { p+='${${_p9k_e:#00}:+${${_p9k_t[$_p9k_n]/'$ss'/$_p9k_ss}/'$s'/$_p9k_s}' - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale _p9k_param $1 ICON_BEFORE_CONTENT '' if [[ $_p9k_ret != false ]]; then _p9k_param $1 PREFIX '' @@ -752,7 +752,7 @@ _p9k_right_prompt_segment() { p+='${${_p9k_e:#00}:+${_p9k_t[$_p9k_n]/'$w'/$_p9k_w}' - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale _p9k_param $1 ICON_BEFORE_CONTENT '' if [[ $_p9k_ret != true ]]; then _p9k_param $1 PREFIX '' @@ -1091,7 +1091,7 @@ prompt_context() { if [[ -z $content ]]; then local var=POWERLEVEL9K_CONTEXT_${state}_TEMPLATE if (( $+parameters[$var] )); then - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale content=${(P)var} content=${(g::)content} else @@ -3570,7 +3570,7 @@ _p9k_init_params() { if [[ $parameters[POWERLEVEL9K_BATTERY_STAGES] == scalar ]]; then _p9k_declare -e POWERLEVEL9K_BATTERY_STAGES else - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale _p9k_declare -a POWERLEVEL9K_BATTERY_STAGES -- _POWERLEVEL9K_BATTERY_STAGES=("${(@g::)_POWERLEVEL9K_BATTERY_STAGES}") fi @@ -3833,7 +3833,7 @@ _p9k_build_gap_post() { } _p9k_init_lines() { - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale local -a left_segments=($_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS) local -a right_segments=($_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS) @@ -4250,7 +4250,7 @@ _p9k_init() { if _p9k_segment_in_use dir; then if (( $+_POWERLEVEL9K_DIR_CLASSES )); then - local LC_ALL=$_p9k_locale + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale local -i i=3 for ((; i <= $#_POWERLEVEL9K_DIR_CLASSES; i+=3)); do _POWERLEVEL9K_DIR_CLASSES[i]=${(g::)_POWERLEVEL9K_DIR_CLASSES[i]} diff --git a/internal/wizard.zsh b/internal/wizard.zsh index b6bbd445..9941f7ed 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -5,7 +5,8 @@ setopt noaliases () { setopt extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} -if [[ ${LC_ALL:-$LANG} != *.(utf|UTF)(-|)8 ]]; then +zmodload zsh/langinfo +if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} fi -- cgit v1.2.3 From c1acb62cf4aab3b30633839430d362293fc8a702 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 20 Aug 2019 20:28:27 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/bin/gitstatusd-android-aarch64 | Bin 1064360 -> 1076696 bytes gitstatus/bin/gitstatusd-cygwin_nt-10.0-x86_64 | Bin 2147840 -> 2167296 bytes gitstatus/bin/gitstatusd-darwin-x86_64 | Bin 2073216 -> 2095156 bytes gitstatus/bin/gitstatusd-freebsd-amd64 | Bin 3258248 -> 3268488 bytes gitstatus/bin/gitstatusd-linux-aarch64 | Bin 2261776 -> 2286400 bytes gitstatus/bin/gitstatusd-linux-armv7l | Bin 1865248 -> 1877556 bytes gitstatus/bin/gitstatusd-linux-x86_64 | Bin 2315464 -> 2336008 bytes gitstatus/bin/gitstatusd-linux-x86_64-static | Bin 2045144 -> 2065632 bytes gitstatus/gitstatus.plugin.zsh | 10 ++++++++-- 9 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gitstatus/bin/gitstatusd-android-aarch64 b/gitstatus/bin/gitstatusd-android-aarch64 index 3da517d3..e9b22e72 100755 Binary files a/gitstatus/bin/gitstatusd-android-aarch64 and b/gitstatus/bin/gitstatusd-android-aarch64 differ diff --git a/gitstatus/bin/gitstatusd-cygwin_nt-10.0-x86_64 b/gitstatus/bin/gitstatusd-cygwin_nt-10.0-x86_64 index 51a1f0a0..a1baa948 100755 Binary files a/gitstatus/bin/gitstatusd-cygwin_nt-10.0-x86_64 and b/gitstatus/bin/gitstatusd-cygwin_nt-10.0-x86_64 differ diff --git a/gitstatus/bin/gitstatusd-darwin-x86_64 b/gitstatus/bin/gitstatusd-darwin-x86_64 index 31eb9db3..e5c46cc2 100755 Binary files a/gitstatus/bin/gitstatusd-darwin-x86_64 and b/gitstatus/bin/gitstatusd-darwin-x86_64 differ diff --git a/gitstatus/bin/gitstatusd-freebsd-amd64 b/gitstatus/bin/gitstatusd-freebsd-amd64 index 7a39061a..de7e0f24 100755 Binary files a/gitstatus/bin/gitstatusd-freebsd-amd64 and b/gitstatus/bin/gitstatusd-freebsd-amd64 differ diff --git a/gitstatus/bin/gitstatusd-linux-aarch64 b/gitstatus/bin/gitstatusd-linux-aarch64 index ebae869a..b99ecfee 100755 Binary files a/gitstatus/bin/gitstatusd-linux-aarch64 and b/gitstatus/bin/gitstatusd-linux-aarch64 differ diff --git a/gitstatus/bin/gitstatusd-linux-armv7l b/gitstatus/bin/gitstatusd-linux-armv7l index 89b59a74..3d301aa9 100755 Binary files a/gitstatus/bin/gitstatusd-linux-armv7l and b/gitstatus/bin/gitstatusd-linux-armv7l differ diff --git a/gitstatus/bin/gitstatusd-linux-x86_64 b/gitstatus/bin/gitstatusd-linux-x86_64 index 802f71ac..e81bb09a 100755 Binary files a/gitstatus/bin/gitstatusd-linux-x86_64 and b/gitstatus/bin/gitstatusd-linux-x86_64 differ diff --git a/gitstatus/bin/gitstatusd-linux-x86_64-static b/gitstatus/bin/gitstatusd-linux-x86_64-static index 8eee5b55..b561edd9 100755 Binary files a/gitstatus/bin/gitstatusd-linux-x86_64-static and b/gitstatus/bin/gitstatusd-linux-x86_64-static differ diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index 7faa196c..244c34e5 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -264,6 +264,8 @@ function _gitstatus_process_response() { # # -m INT If a repo has more files in its index than this, override -u and -d (but not -s) # with zeros. Negative value means infinity. Defaults to -1. +# +# -e Count files within untracked directories like `git status --untracked-files`. function gitstatus_start() { emulate -L zsh setopt err_return no_unset no_bg_nice @@ -275,8 +277,9 @@ function gitstatus_start() { local -i max_num_conflicted=1 local -i max_num_untracked=1 local -i dirty_max_index_size=-1 + local recurse_untracked_dirs while true; do - getopts "t:s:u:c:d:m:" opt || break + getopts "t:s:u:c:d:m:e" opt || break case $opt in t) timeout=$OPTARG;; s) max_num_staged=$OPTARG;; @@ -284,6 +287,8 @@ function gitstatus_start() { c) max_num_conflicted=$OPTARG;; d) max_num_untracked=$OPTARG;; m) dirty_max_index_size=$OPTARG;; + e) recurse_untracked_dirs='--recurse-untracked-dirs';; + +e) recurse_untracked_dirs=;; ?) return 1;; esac done @@ -349,7 +354,8 @@ function gitstatus_start() { --max-num-conflicted=${(q)max_num_conflicted} --max-num-untracked=${(q)max_num_untracked} --dirty-max-index-size=${(q)dirty_max_index_size} - ${${log_level:#INFO}:+--log-level=$log_level}) + --log-level=${(q)log_level} + $recurse_untracked_dirs) local cmd=" echo \$\$ -- cgit v1.2.3 From 13266b014ab7e6b593b1bfc9a56bc80347364aeb Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 20 Aug 2019 21:18:57 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index 244c34e5..6cd39479 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -354,7 +354,7 @@ function gitstatus_start() { --max-num-conflicted=${(q)max_num_conflicted} --max-num-untracked=${(q)max_num_untracked} --dirty-max-index-size=${(q)dirty_max_index_size} - --log-level=${(q)log_level} + --log-level=${(q)log_level:-INFO} $recurse_untracked_dirs) local cmd=" -- cgit v1.2.3 From 7b120bc76f11efd78226795bfa9d2ce390273b3e Mon Sep 17 00:00:00 2001 From: calico Date: Fri, 23 Aug 2019 21:53:01 -0400 Subject: Adding Hyper to README.md font instructions --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0b90fa52..0671ce11 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,7 @@ Double-click on each file and press "Install". This will make `MesloLGS NF` font applications on your system. Configure your terminal to use this font: - **iTerm2**: Open *iTerm2 → Preferences → Profiles → Text* and set *Font* to `MesloLGS NF`. +- **Hyper**: Open *Hyper → Edit → Preferences* and change the value for `fontFamily` to `MesloLGS NF` under module.exports.config. - **Visual Studio Code**: Open *File → Preferences → Settings*, enter `terminal.integrated.fontFamily` in the search box and set value to `MesloLGS NF`. - **Windows Command Prompt** (the old thing): Click the icon in the top left corner, then -- cgit v1.2.3 From 08026f50713484f0c301d5e42762beaf0e19cca5 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 24 Aug 2019 11:33:15 +0200 Subject: style --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0671ce11..9cfbceb9 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,8 @@ Double-click on each file and press "Install". This will make `MesloLGS NF` font applications on your system. Configure your terminal to use this font: - **iTerm2**: Open *iTerm2 → Preferences → Profiles → Text* and set *Font* to `MesloLGS NF`. -- **Hyper**: Open *Hyper → Edit → Preferences* and change the value for `fontFamily` to `MesloLGS NF` under module.exports.config. +- **Hyper**: Open *Hyper → Edit → Preferences* and change the value for `fontFamily` to + `MesloLGS NF` under `module.exports.config`. - **Visual Studio Code**: Open *File → Preferences → Settings*, enter `terminal.integrated.fontFamily` in the search box and set value to `MesloLGS NF`. - **Windows Command Prompt** (the old thing): Click the icon in the top left corner, then -- cgit v1.2.3 From cb1f6c48156e503a85a782194218c38ac28fec4b Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 24 Aug 2019 12:58:55 +0200 Subject: make custom prompts more compatible with p9k --- internal/p10k.zsh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 255919a4..0c9948f8 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1141,9 +1141,10 @@ prompt_host() { _p9k_custom_prompt() { local segment_name=${1:u} local command=POWERLEVEL9K_CUSTOM_${segment_name} - local -a cmd=("${(@Q)${(z)${(P)command}}}") - whence $cmd[1] &>/dev/null || return - local content="$("$cmd[@]")" + command=${(P)command} + local cmd="${(Q)${(z)command}[1]}" + (( $+functions[$cmd] || $+commands[$cmd] )) || return + local content="$(eval $command)" [[ -n $content ]] || return _p9k_prompt_segment "prompt_custom_$segment_name" $_p9k_color2 $_p9k_color1 "CUSTOM_${segment_name}_ICON" 0 '' "$content" } -- cgit v1.2.3 From 06ddd559227ae502bf2995280a6f0fb3979f770d Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 26 Aug 2019 10:19:55 +0200 Subject: ask awesome-patched font users about python logo; some are stuck with old fonts that don't have it --- internal/wizard.zsh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 9941f7ed..5c5572d9 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -917,7 +917,7 @@ function generate_config() { sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'⇶'" fi - if [[ $POWERLEVEL9K_MODE == awesome-fontconfig && $cap_python == 0 ]]; then + if [[ $POWERLEVEL9K_MODE == (awesome-patched|awesome-fontconfig) && $cap_python == 0 ]]; then uncomment 'typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION' uncomment 'typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION' uncomment 'typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION' @@ -1087,7 +1087,12 @@ while true; do if (( ! cap_lock )); then ask_lock '\uE138' "Let's try another one." || continue if (( cap_lock )); then - (( cap_diamond )) && POWERLEVEL9K_MODE=awesome-patched || POWERLEVEL9K_MODE=flat + if (( cap_diamond )); then + POWERLEVEL9K_MODE=awesome-patched + ask_python || continue + else + POWERLEVEL9K_MODE=flat + fi else (( cap_diamond )) && POWERLEVEL9K_MODE=powerline || POWERLEVEL9K_MODE=compatible fi @@ -1110,6 +1115,7 @@ while true; do else options+="$POWERLEVEL9K_MODE" fi + (( cap_python )) && options[-1] += ' + python' if (( cap_diamond )); then left_subsep=$right_angle right_subsep=$left_angle -- cgit v1.2.3 From b3abfc089a86f6a4e71d91c46361f3f56acd6b9f Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 26 Aug 2019 12:05:42 +0200 Subject: fix detection of awesome-mapped-fontconfig in the wizard --- internal/configure.zsh | 8 +++++++- internal/p10k.zsh | 9 ++++++++- internal/wizard.zsh | 7 +++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/internal/configure.zsh b/internal/configure.zsh index d7a253d9..c04ad413 100644 --- a/internal/configure.zsh +++ b/internal/configure.zsh @@ -60,6 +60,12 @@ function _p9k_can_configure() { function p9k_configure() { emulate -L zsh && setopt no_hist_expand extended_glob - $__p9k_root_dir/internal/wizard.zsh -d $__p9k_root_dir -f || return + ( + local p=("${(@)parameters[(I)AWESOME_*|CODEPOINT_*]}") + if (( $#p )); then + typeset -x -- $p + fi + $__p9k_root_dir/internal/wizard.zsh -d $__p9k_root_dir -f $awesome + ) || return source $__p9k_cfg_path } diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 0c9948f8..ab1db6f6 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3243,7 +3243,14 @@ _p9k_precmd() { if (( !__p9k_configured )); then __p9k_configured=1 if [[ "${parameters[(I)POWERLEVEL9K_*]}" == (POWERLEVEL9K_MODE|) ]] && _p9k_can_configure -q; then - if $__p9k_root_dir/internal/wizard.zsh -d $__p9k_root_dir; then + ( + local p=("${(@)parameters[(I)AWESOME_*|CODEPOINT_*]}") + if (( $#p )); then + typeset -x -- $p + fi + $__p9k_root_dir/internal/wizard.zsh -d $__p9k_root_dir -f $awesome + ) + if (( !$? )); then source $__p9k_cfg_path _p9k_must_init fi diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 5c5572d9..df5a7d50 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -292,7 +292,10 @@ function ask_narrow_icons() { text+="%3F${icons[DATE_ICON]// }%fX" text+="%4F${icons[TIME_ICON]// }%fX" text+="%5F${icons[RUBY_ICON]// }%fX" - text+="%6F${icons[AWS_EB_ICON]// }%fX" + text+="%6F${icons[HOME_ICON]// }%fX" + text+="%1F${icons[HOME_SUB_ICON]// }%fX" + text+="%2F${icons[FOLDER_ICON]// }%fX" + text+="%3F${icons[RAM_ICON]// }%fX" while true; do clear centered "%BDo all these icons %b%2Ffit between the crosses%f%B?%b" @@ -1080,7 +1083,7 @@ while true; do local -a options=() ask_diamond || continue - if [[ -n $AWESOME_GLYPHS_LOADED ]]; then + if [[ $AWESOME_GLYPHS_LOADED == 1 ]]; then POWERLEVEL9K_MODE=awesome-mapped-fontconfig else ask_lock '\uF023' || continue -- cgit v1.2.3 From 7d6400774f0a8dc8759044de4396bce7548310d0 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 26 Aug 2019 12:06:06 +0200 Subject: tune trailing whitespace for all icons when using typical non-monospace fonts --- internal/icons.zsh | 226 ++++++++++++++++++++++++++--------------------------- 1 file changed, 113 insertions(+), 113 deletions(-) diff --git a/internal/icons.zsh b/internal/icons.zsh index fd2ab1be..425e57c5 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -21,27 +21,27 @@ function _p9k_init_icons() { LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace LEFT_SUBSEGMENT_SEPARATOR '\uE0B1' #  RIGHT_SUBSEGMENT_SEPARATOR '\uE0B3' #  - CARRIAGE_RETURN_ICON '\u21B5' # ↵ + CARRIAGE_RETURN_ICON '\u21B5 ' # ↵ ROOT_ICON '\uE801' #  - SUDO_ICON '\uF09C' #  + SUDO_ICON '\uE0A2' #  RUBY_ICON '\uE847 ' #  - AWS_ICON '\uE895' #  - AWS_EB_ICON '\U1F331 ' # 🌱 + AWS_ICON '\uE895 ' #  + AWS_EB_ICON '\U1F331' # 🌱 BACKGROUND_JOBS_ICON '\uE82F ' #  - TEST_ICON '\uE891' #  + TEST_ICON '\uE891 ' #  TODO_ICON '\u2611' # ☑ - BATTERY_ICON '\uE894' #  + BATTERY_ICON '\uE894 ' #  DISK_ICON '\uE1AE ' #  OK_ICON '\u2714' # ✔ FAIL_ICON '\u2718' # ✘ SYMFONY_ICON 'SF' - NODE_ICON '\u2B22' # ⬢ + NODE_ICON '\u2B22 ' # ⬢ MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ APPLE_ICON '\uE26E ' #  WINDOWS_ICON '\uE26F ' #  - FREEBSD_ICON '\U1F608 ' # 😈 + FREEBSD_ICON '\U1F608' # 😈 ANDROID_ICON '\uE270 ' #  LINUX_ICON '\uE271 ' #  LINUX_ARCH_ICON '\uE271 ' #  @@ -63,19 +63,19 @@ function _p9k_init_icons() { LINUX_OPENSUSE_ICON '\uE271 ' #  LINUX_SABAYON_ICON '\uE271 ' #  LINUX_SLACKWARE_ICON '\uE271 ' #  - SUNOS_ICON '\U1F31E ' # 🌞 - HOME_ICON '\uE12C' #  - HOME_SUB_ICON '\uE18D' #  - FOLDER_ICON '\uE818' #  - NETWORK_ICON '\uE1AD' #  - ETC_ICON '\uE82F' #  + SUNOS_ICON '\U1F31E' # 🌞 + HOME_ICON '\uE12C ' #  + HOME_SUB_ICON '\uE18D ' #  + FOLDER_ICON '\uE818 ' #  + NETWORK_ICON '\uE1AD ' #  + ETC_ICON '\uE82F ' #  LOAD_ICON '\uE190 ' #  - SWAP_ICON '\uE87D' #  + SWAP_ICON '\uE87D ' #  RAM_ICON '\uE1E2 ' #  - SERVER_ICON '\uE895' #  - VCS_UNTRACKED_ICON '\uE16C' #  - VCS_UNSTAGED_ICON '\uE17C' #  - VCS_STAGED_ICON '\uE168' #  + SERVER_ICON '\uE895 ' #  + VCS_UNTRACKED_ICON '\uE16C ' #  + VCS_UNSTAGED_ICON '\uE17C ' #  + VCS_STAGED_ICON '\uE168 ' #  VCS_STASH_ICON '\uE133 ' #  #VCS_INCOMING_CHANGES_ICON '\uE1EB ' #  #VCS_INCOMING_CHANGES_ICON '\uE80D ' #  @@ -96,18 +96,18 @@ function _p9k_init_icons() { VCS_HG_ICON '\uE1C3 ' #  VCS_SVN_ICON 'svn' RUST_ICON 'R' - PYTHON_ICON '\ue63c' #  - SWIFT_ICON '' - GO_ICON '' - PUBLIC_IP_ICON '' + PYTHON_ICON '\uE63C ' #  (doesn't always work) + SWIFT_ICON 'Swift' + GO_ICON 'Go' + PUBLIC_IP_ICON 'IP' LOCK_ICON '\UE138' #  - EXECUTION_TIME_ICON '\UE89C' #  + EXECUTION_TIME_ICON '\UE89C ' #  SSH_ICON 'ssh' VPN_ICON 'vpn' - KUBERNETES_ICON '\U2388' # ⎈ - DROPBOX_ICON '\UF16B' #  - DATE_ICON '\uE184' #  - TIME_ICON '\uE12E' #  + KUBERNETES_ICON '\U2388 ' # ⎈ + DROPBOX_ICON '\UF16B ' #  (doesn't always work) + DATE_ICON '\uE184 ' #  + TIME_ICON '\uE12E ' #  JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ @@ -125,13 +125,13 @@ function _p9k_init_icons() { LEFT_SUBSEGMENT_SEPARATOR '\uE0B1' #  RIGHT_SUBSEGMENT_SEPARATOR '\uE0B3' #  CARRIAGE_RETURN_ICON '\u21B5' # ↵ - ROOT_ICON '\uF201' #  - SUDO_ICON '\uF09C' #  + ROOT_ICON '\uF201 ' #  + SUDO_ICON '\uF09C ' #  RUBY_ICON '\uF219 ' #  - AWS_ICON '\uF270' #  - AWS_EB_ICON '\U1F331 ' # 🌱 + AWS_ICON '\uF270 ' #  + AWS_EB_ICON '\U1F331' # 🌱 BACKGROUND_JOBS_ICON '\uF013 ' #  - TEST_ICON '\uF291' #  + TEST_ICON '\uF291 ' #  TODO_ICON '\u2611' # ☑ BATTERY_ICON '\U1F50B' # 🔋 DISK_ICON '\uF0A0 ' #  @@ -144,8 +144,8 @@ function _p9k_init_icons() { MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ APPLE_ICON '\uF179 ' #  WINDOWS_ICON '\uF17A ' #  - FREEBSD_ICON '\U1F608 ' # 😈 - ANDROID_ICON '\uE17B ' #  + FREEBSD_ICON '\U1F608' # 😈 + ANDROID_ICON '\uE17B ' #  (doesn't always work) LINUX_ICON '\uF17C ' #  LINUX_ARCH_ICON '\uF17C ' #  LINUX_DEBIAN_ICON '\uF17C ' #  @@ -167,23 +167,23 @@ function _p9k_init_icons() { LINUX_SABAYON_ICON '\uF17C ' #  LINUX_SLACKWARE_ICON '\uF17C ' #  SUNOS_ICON '\uF185 ' #  - HOME_ICON '\uF015' #  - HOME_SUB_ICON '\uF07C' #  - FOLDER_ICON '\uF115' #  + HOME_ICON '\uF015 ' #  + HOME_SUB_ICON '\uF07C ' #  + FOLDER_ICON '\uF115 ' #  ETC_ICON '\uF013 ' #  - NETWORK_ICON '\uF09E' #  + NETWORK_ICON '\uF09E ' #  LOAD_ICON '\uF080 ' #  - SWAP_ICON '\uF0E4' #  - RAM_ICON '\uF0E4' #  - SERVER_ICON '\uF233' #  - VCS_UNTRACKED_ICON '\uF059' #  - VCS_UNSTAGED_ICON '\uF06A' #  - VCS_STAGED_ICON '\uF055' #  + SWAP_ICON '\uF0E4 ' #  + RAM_ICON '\uF0E4 ' #  + SERVER_ICON '\uF233 ' #  + VCS_UNTRACKED_ICON '\uF059 ' #  + VCS_UNSTAGED_ICON '\uF06A ' #  + VCS_STAGED_ICON '\uF055 ' #  VCS_STASH_ICON '\uF01C ' #  VCS_INCOMING_CHANGES_ICON '\uF01A ' #  VCS_OUTGOING_CHANGES_ICON '\uF01B ' #  VCS_TAG_ICON '\uF217 ' #  - VCS_BOOKMARK_ICON '\uF27B' #  + VCS_BOOKMARK_ICON '\uF27B ' #  VCS_COMMIT_ICON '\uF221 ' #  VCS_BRANCH_ICON '\uF126 ' #  VCS_REMOTE_BRANCH_ICON '\u2192' # → @@ -194,17 +194,17 @@ function _p9k_init_icons() { VCS_GIT_GITLAB_ICON '\uF296 ' #  VCS_HG_ICON '\uF0C3 ' #  VCS_SVN_ICON 'svn' - RUST_ICON '\uE6A8' #  - PYTHON_ICON '\ue63c' #  - SWIFT_ICON '' - GO_ICON '' - PUBLIC_IP_ICON '' + RUST_ICON '\uE6A8' #  + PYTHON_ICON '\uE63C ' #  + SWIFT_ICON 'Swift' + GO_ICON 'Go' + PUBLIC_IP_ICON 'IP' LOCK_ICON '\UF023' #  - EXECUTION_TIME_ICON '\uF253' + EXECUTION_TIME_ICON '\uF253 ' #  SSH_ICON 'ssh' VPN_ICON '\uF023' KUBERNETES_ICON '\U2388' # ⎈ - DROPBOX_ICON '\UF16B' #  + DROPBOX_ICON '\UF16B ' #  DATE_ICON '\uF073 ' #  TIME_ICON '\uF017 ' #  JAVA_ICON '\U2615' # ☕︎ @@ -232,24 +232,24 @@ function _p9k_init_icons() { RIGHT_SUBSEGMENT_SEPARATOR '\uE0B3' #  CARRIAGE_RETURN_ICON '\u21B5' # ↵ ROOT_ICON '\u'$CODEPOINT_OF_OCTICONS_ZAP #  - SUDO_ICON '\u'$CODEPOINT_OF_AWESOME_UNLOCK #  + SUDO_ICON '\u'$CODEPOINT_OF_AWESOME_UNLOCK' ' #  RUBY_ICON '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' #  - AWS_ICON '\u'$CODEPOINT_OF_AWESOME_SERVER #  - AWS_EB_ICON '\U1F331 ' # 🌱 + AWS_ICON '\u'$CODEPOINT_OF_AWESOME_SERVER' ' #  + AWS_EB_ICON '\U1F331' # 🌱 BACKGROUND_JOBS_ICON '\u'$CODEPOINT_OF_AWESOME_COG' ' #  - TEST_ICON '\u'$CODEPOINT_OF_AWESOME_BUG #  - TODO_ICON '\u'$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O #  - BATTERY_ICON '\U'$CODEPOINT_OF_AWESOME_BATTERY_FULL #  + TEST_ICON '\u'$CODEPOINT_OF_AWESOME_BUG' ' #  + TODO_ICON '\u'$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O' ' #  + BATTERY_ICON '\U'$CODEPOINT_OF_AWESOME_BATTERY_FULL' ' #  DISK_ICON '\u'$CODEPOINT_OF_AWESOME_HDD_O' ' #  - OK_ICON '\u'$CODEPOINT_OF_AWESOME_CHECK #  - FAIL_ICON '\u'$CODEPOINT_OF_AWESOME_TIMES #  + OK_ICON '\u'$CODEPOINT_OF_AWESOME_CHECK' ' #  + FAIL_ICON '\u'$CODEPOINT_OF_AWESOME_TIMES #  SYMFONY_ICON 'SF' NODE_ICON '\u2B22' # ⬢ MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ APPLE_ICON '\u'$CODEPOINT_OF_AWESOME_APPLE' ' #  - FREEBSD_ICON '\U1F608 ' # 😈 + FREEBSD_ICON '\U1F608' # 😈 LINUX_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  LINUX_ARCH_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  LINUX_DEBIAN_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  @@ -271,18 +271,18 @@ function _p9k_init_icons() { LINUX_SABAYON_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  LINUX_SLACKWARE_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX' ' #  SUNOS_ICON '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' #  - HOME_ICON '\u'$CODEPOINT_OF_AWESOME_HOME #  - HOME_SUB_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN #  - FOLDER_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_O #  + HOME_ICON '\u'$CODEPOINT_OF_AWESOME_HOME' ' #  + HOME_SUB_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN' ' #  + FOLDER_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_O' ' #  ETC_ICON '\u'$CODEPOINT_OF_AWESOME_COG' ' #  - NETWORK_ICON '\u'$CODEPOINT_OF_AWESOME_RSS #  + NETWORK_ICON '\u'$CODEPOINT_OF_AWESOME_RSS' ' #  LOAD_ICON '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' #  - SWAP_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  - RAM_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD #  - SERVER_ICON '\u'$CODEPOINT_OF_AWESOME_SERVER #  - VCS_UNTRACKED_ICON '\u'$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE #  - VCS_UNSTAGED_ICON '\u'$CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE #  - VCS_STAGED_ICON '\u'$CODEPOINT_OF_AWESOME_PLUS_CIRCLE #  + SWAP_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD' ' #  + RAM_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD' ' #  + SERVER_ICON '\u'$CODEPOINT_OF_AWESOME_SERVER' ' #  + VCS_UNTRACKED_ICON '\u'$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE' ' #  + VCS_UNSTAGED_ICON '\u'$CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE' ' #  + VCS_STAGED_ICON '\u'$CODEPOINT_OF_AWESOME_PLUS_CIRCLE' ' #  VCS_STASH_ICON '\u'$CODEPOINT_OF_AWESOME_INBOX' ' #  VCS_INCOMING_CHANGES_ICON '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_DOWN' ' #  VCS_OUTGOING_CHANGES_ICON '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_UP' ' #  @@ -290,7 +290,7 @@ function _p9k_init_icons() { VCS_BOOKMARK_ICON '\u'$CODEPOINT_OF_OCTICONS_BOOKMARK #  VCS_COMMIT_ICON '\u'$CODEPOINT_OF_OCTICONS_GIT_COMMIT' ' #  VCS_BRANCH_ICON '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' #  - VCS_REMOTE_BRANCH_ICON '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH #  + VCS_REMOTE_BRANCH_ICON '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH' ' #  VCS_LOADING_ICON '' VCS_GIT_ICON '\u'$CODEPOINT_OF_AWESOME_GIT' ' #  VCS_GIT_GITHUB_ICON '\u'$CODEPOINT_OF_AWESOME_GITHUB_ALT' ' #  @@ -299,15 +299,15 @@ function _p9k_init_icons() { VCS_HG_ICON '\u'$CODEPOINT_OF_AWESOME_FLASK' ' #  VCS_SVN_ICON 'svn' RUST_ICON '\uE6A8' #  - PYTHON_ICON '🐍' - SWIFT_ICON '\uE655' #  - PUBLIC_IP_ICON '\u'$CODEPOINT_OF_AWESOME_GLOBE #  + PYTHON_ICON '\U1F40D' # 🐍 + SWIFT_ICON '\uE655 ' #  + PUBLIC_IP_ICON '\u'$CODEPOINT_OF_AWESOME_GLOBE' ' #  LOCK_ICON '\u'$CODEPOINT_OF_AWESOME_LOCK #  - EXECUTION_TIME_ICON '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END #  + EXECUTION_TIME_ICON '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END' ' #  SSH_ICON 'ssh' VPN_ICON '\u'$CODEPOINT_OF_AWESOME_LOCK KUBERNETES_ICON '\U2388' # ⎈ - DROPBOX_ICON '\u'$CODEPOINT_OF_AWESOME_DROPBOX #  + DROPBOX_ICON '\u'$CODEPOINT_OF_AWESOME_DROPBOX' ' #  DATE_ICON '\uF073 ' #  TIME_ICON '\uF017 ' #  JAVA_ICON '\U2615' # ☕︎ @@ -328,36 +328,36 @@ function _p9k_init_icons() { LEFT_SUBSEGMENT_SEPARATOR '\uE0B1' #  RIGHT_SUBSEGMENT_SEPARATOR '\uE0B3' #  CARRIAGE_RETURN_ICON '\u21B5' # ↵ - ROOT_ICON '\uE614 ' #  - SUDO_ICON '\uF09C' #  + ROOT_ICON '\uE614' #  + SUDO_ICON '\uF09C ' #  RUBY_ICON '\uF219 ' #  - AWS_ICON '\uF270' #  - AWS_EB_ICON '\UF1BD ' #  + AWS_ICON '\uF270 ' #  + AWS_EB_ICON '\UF1BD' #  BACKGROUND_JOBS_ICON '\uF013 ' #  - TEST_ICON '\uF188' #  - TODO_ICON '\uF133' #  + TEST_ICON '\uF188 ' #  + TODO_ICON '\uF133 ' #  BATTERY_ICON '\UF240 ' #  - DISK_ICON '\uF0A0' #  - OK_ICON '\uF00C' #  + DISK_ICON '\uF0A0 ' #  + OK_ICON '\uF00C ' #  FAIL_ICON '\uF00D' #  SYMFONY_ICON '\uE757' #  NODE_ICON '\uE617 ' #  MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ - APPLE_ICON '\uF179 ' #  + APPLE_ICON '\uF179' #  WINDOWS_ICON '\uF17A ' #  FREEBSD_ICON '\UF30C ' #  - ANDROID_ICON '\uF17B ' #  - LINUX_ARCH_ICON '\uF303 ' #  + ANDROID_ICON '\uF17B' #  + LINUX_ARCH_ICON '\uF303' #  LINUX_CENTOS_ICON '\uF304 ' #  LINUX_COREOS_ICON '\uF305 ' #  - LINUX_DEBIAN_ICON '\uF306 ' #  - LINUX_RASPBIAN_ICON '\uF315 ' #  + LINUX_DEBIAN_ICON '\uF306' #  + LINUX_RASPBIAN_ICON '\uF315' #  LINUX_ELEMENTARY_ICON '\uF309 ' #  LINUX_FEDORA_ICON '\uF30a ' #  LINUX_GENTOO_ICON '\uF30d ' #  - LINUX_MAGEIA_ICON '\uF310 ' #  + LINUX_MAGEIA_ICON '\uF310' #  LINUX_MINT_ICON '\uF30e ' #  LINUX_NIXOS_ICON '\uF313 ' #  LINUX_MANJARO_ICON '\uF312 ' #  @@ -368,20 +368,20 @@ function _p9k_init_icons() { LINUX_SABAYON_ICON '\uF317 ' #  LINUX_SLACKWARE_ICON '\uF319 ' #  LINUX_UBUNTU_ICON '\uF31b ' #  - LINUX_ICON '\uF17C ' #  + LINUX_ICON '\uF17C' #  SUNOS_ICON '\uF185 ' #  - HOME_ICON '\uF015' #  - HOME_SUB_ICON '\uF07C' #  - FOLDER_ICON '\uF115' #  - ETC_ICON '\uF013' #  - NETWORK_ICON '\uF1EB' #  + HOME_ICON '\uF015 ' #  + HOME_SUB_ICON '\uF07C ' #  + FOLDER_ICON '\uF115 ' #  + ETC_ICON '\uF013 ' #  + NETWORK_ICON '\uF1EB ' #  LOAD_ICON '\uF080 ' #  - SWAP_ICON '\uF464' #  - RAM_ICON '\uF0E4' #  - SERVER_ICON '\uF0AE' #  - VCS_UNTRACKED_ICON '\uF059' #  - VCS_UNSTAGED_ICON '\uF06A' #  - VCS_STAGED_ICON '\uF055' #  + SWAP_ICON '\uF464 ' #  + RAM_ICON '\uF0E4 ' #  + SERVER_ICON '\uF0AE ' #  + VCS_UNTRACKED_ICON '\uF059 ' #  + VCS_UNSTAGED_ICON '\uF06A ' #  + VCS_STAGED_ICON '\uF055 ' #  VCS_STASH_ICON '\uF01C ' #  VCS_INCOMING_CHANGES_ICON '\uF01A ' #  VCS_OUTGOING_CHANGES_ICON '\uF01B ' #  @@ -396,22 +396,22 @@ function _p9k_init_icons() { VCS_GIT_BITBUCKET_ICON '\uE703 ' #  VCS_GIT_GITLAB_ICON '\uF296 ' #  VCS_HG_ICON '\uF0C3 ' #  - VCS_SVN_ICON '\uE72D ' #  - RUST_ICON '\uE7A8 ' #  + VCS_SVN_ICON '\uE72D' #  + RUST_ICON '\uE7A8' #  PYTHON_ICON '\UE73C ' #  SWIFT_ICON '\uE755' #  GO_ICON '\uE626' #  - PUBLIC_IP_ICON '\UF0AC' #  + PUBLIC_IP_ICON '\UF0AC ' #  LOCK_ICON '\UF023' #  - EXECUTION_TIME_ICON '\uF252' #  - SSH_ICON '\uF489' #  + EXECUTION_TIME_ICON '\uF252 ' #  + SSH_ICON '\uF489 ' #  VPN_ICON 'vpn' KUBERNETES_ICON '\U2388' # ⎈ - DROPBOX_ICON '\UF16B' #  + DROPBOX_ICON '\UF16B ' #  DATE_ICON '\uF073 ' #  TIME_ICON '\uF017 ' #  JAVA_ICON '\U2615' # ☕︎ - LARAVEL_ICON '\ue73f ' #  + LARAVEL_ICON '\ue73f' #  RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ ) @@ -431,7 +431,7 @@ function _p9k_init_icons() { SUDO_ICON '\uE0A2' #  RUBY_ICON 'Ruby' AWS_ICON 'AWS' - AWS_EB_ICON '\U1F331 ' # 🌱 + AWS_EB_ICON '\U1F331' # 🌱 BACKGROUND_JOBS_ICON '\u2699' # ⚙ TEST_ICON '' TODO_ICON '\u2611' # ☑ @@ -500,7 +500,7 @@ function _p9k_init_icons() { PYTHON_ICON 'Py' SWIFT_ICON 'Swift' GO_ICON 'Go' - PUBLIC_IP_ICON '' + PUBLIC_IP_ICON 'IP' LOCK_ICON '\UE0A2' EXECUTION_TIME_ICON '' SSH_ICON 'ssh' -- cgit v1.2.3 From 613b1a646eae3deb964d7d69aa986c78a5986542 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 26 Aug 2019 17:40:12 +0200 Subject: don't unset P9K_SSH --- internal/p10k.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index ab1db6f6..afacf703 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -4306,7 +4306,7 @@ _p9k_init() { _p9k_deinit() { (( $+functions[gitstatus_stop] )) && gitstatus_stop POWERLEVEL9K _p9k_deinit_async_pump - unset -m '(_POWERLEVEL9K_|P9K_|_p9k_)*' + unset -m '(_POWERLEVEL9K_|P9K_|_p9k_)*~P9K_SSH' } typeset -gi __p9k_enabled=0 -- cgit v1.2.3 From e4d78d2a722c3d81a48d6eab4edc858c28fbf35f Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 27 Aug 2019 08:53:28 +0200 Subject: fix custom prompt when the command is just one word; fixes #189 --- internal/p10k.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index afacf703..cff575b0 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1142,7 +1142,7 @@ _p9k_custom_prompt() { local segment_name=${1:u} local command=POWERLEVEL9K_CUSTOM_${segment_name} command=${(P)command} - local cmd="${(Q)${(z)command}[1]}" + local cmd="${(Q)${(Az)command}[1]}" (( $+functions[$cmd] || $+commands[$cmd] )) || return local content="$(eval $command)" [[ -n $content ]] || return -- cgit v1.2.3 From 3f2f38a71eb71719edec5edb8f43a8684f81a2f7 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 27 Aug 2019 10:49:02 +0200 Subject: move time to the first prompt line --- config/p10k-classic.zsh | 2 +- config/p10k-lean.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 6be7c45c..aab768ef 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -61,11 +61,11 @@ fi context # user@host nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) + # time # current time # =========================[ Line #2 ]========================= newline # public_ip # public IP address # battery # internal battery - # time # current time # example # example user-defined segment (see prompt_example function below) ) diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 696d6a4e..fdc41f30 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -61,11 +61,11 @@ fi context # user@host nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) + # time # current time # =========================[ Line #2 ]========================= newline # public_ip # public IP address # battery # internal battery - # time # current time # example # example user-defined segment (see prompt_example function below) ) -- cgit v1.2.3 From 0c627eb31de1b816e98fa17a11ecf675c4e2b366 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 27 Aug 2019 10:57:54 +0200 Subject: add `proxy` prompt segment --- config/p10k-classic.zsh | 7 +++++++ config/p10k-lean.zsh | 7 +++++++ internal/icons.zsh | 5 +++++ internal/p10k.zsh | 10 ++++++++++ 4 files changed, 29 insertions(+) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index aab768ef..6864ba47 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -65,6 +65,7 @@ fi # =========================[ Line #2 ]========================= newline # public_ip # public IP address + # proxy # system-wide http/https/ftp proxy # battery # internal battery # example # example user-defined segment (see prompt_example function below) ) @@ -626,6 +627,12 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + #########################[ proxy: system-wide http/https/ftp proxy ]########################## + # Proxy color. + typeset -g POWERLEVEL9K_PROXY_FOREGROUND=68 + # Custom icon. + # typeset -g POWERLEVEL9K_PROXY_VISUAL_IDENTIFIER_EXPANSION='⭐' + ################################[ battery: internal battery ]################################# # Show battery in red when it's below this level and not connected to power supply. typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index fdc41f30..62ed0bad 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -65,6 +65,7 @@ fi # =========================[ Line #2 ]========================= newline # public_ip # public IP address + # proxy # system-wide http/https/ftp proxy # battery # internal battery # example # example user-defined segment (see prompt_example function below) ) @@ -609,6 +610,12 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + #########################[ proxy: system-wide http/https/ftp proxy ]########################## + # Proxy color. + typeset -g POWERLEVEL9K_PROXY_FOREGROUND=68 + # Custom icon. + # typeset -g POWERLEVEL9K_PROXY_VISUAL_IDENTIFIER_EXPANSION='⭐' + ################################[ battery: internal battery ]################################# # Show battery in red when it's below this level and not connected to power supply. typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 diff --git a/internal/icons.zsh b/internal/icons.zsh index 425e57c5..c74fe909 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -112,6 +112,7 @@ function _p9k_init_icons() { LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ + PROXY_ICON '\u21AF' # ↯ ) ;; 'awesome-fontconfig') @@ -211,6 +212,7 @@ function _p9k_init_icons() { LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ + PROXY_ICON '\u21AF' # ↯ ) ;; 'awesome-mapped-fontconfig') @@ -314,6 +316,7 @@ function _p9k_init_icons() { LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ + PROXY_ICON '\u21AF' # ↯ ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -414,6 +417,7 @@ function _p9k_init_icons() { LARAVEL_ICON '\ue73f' #  RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ + PROXY_ICON '\u21AF' # ↯ ) ;; *) @@ -513,6 +517,7 @@ function _p9k_init_icons() { LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ + PROXY_ICON '\u21AF' # ↯ ) ;; esac diff --git a/internal/p10k.zsh b/internal/p10k.zsh index cff575b0..5caaea15 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3052,6 +3052,16 @@ function prompt_terraform() { [[ $ws == default ]] || _p9k_prompt_segment $0 $_p9k_color1 blue TERRAFORM_ICON 0 '' $ws } +function prompt_proxy() { + local -U p=( + $all_proxy $http_proxy $https_proxy $ftp_proxy + $ALL_PROXY $HTTP_PROXY $HTTPS_PROXY $FTP_PROXY) + p=(${(@)${(@)${(@)p#*://}##*@}%%/*}) + (( $#p )) || return + (( $#p == 1 )) || p=("") + _p9k_prompt_segment $0 $_p9k_color1 blue PROXY_ICON 0 '' "$p[1]" +} + _p9k_preexec() { if (( $+_p9k_real_zle_rprompt_indent )); then if [[ -n $_p9k_real_zle_rprompt_indent ]]; then -- cgit v1.2.3 From 3a1ebea014690b8fd39531732ec8abbeabc2d1f0 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 28 Aug 2019 15:41:59 +0200 Subject: add more patterns to POWERLEVEL9K_SHORTEN_FOLDER_MARKER --- config/p10k-classic.zsh | 21 +++++++++++++++++++-- config/p10k-lean.zsh | 21 +++++++++++++++++++-- internal/p10k.zsh | 19 ++++++++++++++++++- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 6864ba47..0f960e3c 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -221,8 +221,25 @@ fi typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=39 # Display anchor directory segments in bold. typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true - # Don't shorten directories that contain files matching this pattern. They are anchors. - typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER='(.shorten_folder_marker|.bzr|CVS|.git|.hg|.svn|.terraform|.citc)' + # Don't shorten directories that contain any of these files. They are anchors. + local anchor_files=( + .bzr + .citc + .git + .hg + .node-version + .python-version + .ruby-version + .shorten_folder_marker + .svn + .terraform + CVS + Cargo.toml + composer.json + go.mod + package.json + ) + typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})" # Don't shorten this many last directory segments. They are anchors. typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 # Shorten directory if it's longer than this even if there is space for it. The value can diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 62ed0bad..34566ea6 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -203,8 +203,25 @@ fi typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=39 # Display anchor directory segments in bold. typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true - # Don't shorten directories that contain files matching this pattern. They are anchors. - typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER='(.shorten_folder_marker|.bzr|CVS|.git|.hg|.svn|.terraform|.citc)' + # Don't shorten directories that contain any of these files. They are anchors. + local anchor_files=( + .bzr + .citc + .git + .hg + .node-version + .python-version + .ruby-version + .shorten_folder_marker + .svn + .terraform + CVS + Cargo.toml + composer.json + go.mod + package.json + ) + typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})" # Don't shorten this many last directory segments. They are anchors. typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 # Shorten directory if it's longer than this even if there is space for it. The value can diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 5caaea15..fc262ade 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3619,7 +3619,24 @@ _p9k_init_params() { _p9k_declare -s POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND _p9k_declare -s POWERLEVEL9K_DIR_ANCHOR_FOREGROUND _p9k_declare -s POWERLEVEL9K_DIR_SHORTENED_FOREGROUND - _p9k_declare -s POWERLEVEL9K_SHORTEN_FOLDER_MARKER "(.shorten_folder_marker|.bzr|CVS|.git|.hg|.svn|.terraform|.citc)" + local markers=( + .bzr + .citc + .git + .hg + .node-version + .python-version + .ruby-version + .shorten_folder_marker + .svn + .terraform + CVS + Cargo.toml + composer.json + go.mod + package.json + ) + _p9k_declare -s POWERLEVEL9K_SHORTEN_FOLDER_MARKER "(${(j:|:)markers})" # Shorten directory if it's longer than this even if there is space for it. # The value can be either absolute (e.g., '80') or a percentage of terminal # width (e.g, '50%'). If empty, directory will be shortened only when prompt -- cgit v1.2.3 From 5f610a0af908137758992e2355c5ed6df2d71723 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 28 Aug 2019 18:55:33 +0200 Subject: fix network interface and ip parsing --- internal/p10k.zsh | 73 ++++++++++++++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index fc262ade..7c1f1945 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -212,44 +212,13 @@ _p9k_segment_in_use() { } function _p9k_parse_ip() { - local desiredInterface=${1:-'^[^ ]+'} - - if [[ $_p9k_os == OSX ]]; then - [[ -x /sbin/ifconfig ]] || return - local rawInterfaces && rawInterfaces="$(/sbin/ifconfig -l 2>/dev/null)" || return - local -a interfaces=(${(A)=rawInterfaces}) - local pattern="${desiredInterface}[^ ]?" - local -a relevantInterfaces - for rawInterface in $interfaces; do - [[ "$rawInterface" =~ $pattern ]] && relevantInterfaces+=$MATCH - done - local newline=$'\n' - local interfaceName interface - for interfaceName in $relevantInterfaces; do - interface="$(/sbin/ifconfig $interfaceName 2>/dev/null)" || continue - [[ "${interface}" =~ "lo[0-9]*" ]] && continue - if [[ "${interface//${newline}/}" =~ "<([^>]*)>(.*)inet[ ]+([^ ]*)" ]]; then - local ipFound="${match[3]}" - local -a interfaceStates=(${(s:,:)match[1]}) - if (( ${interfaceStates[(I)UP]} )); then - _p9k_ret=$ipFound - return - fi - fi - done - else - [[ -x /sbin/ip ]] || return - local -a interfaces=( "${(f)$(/sbin/ip -brief -4 a show 2>/dev/null)}" ) - local pattern="^${desiredInterface}[[:space:]]+UP[[:space:]]+([^/ ]+)" - local interface - for interface in "${(@)interfaces}"; do - if [[ "$interface" =~ $pattern ]]; then - _p9k_ret=$match[1] - return - fi - done - fi - + local iface_regex="^${1:-.*}\$" iface ip + for iface ip in "${(@kv)_p9k_iface}"; do + if [[ $iface =~ $iface_regex ]]; then + _p9k_ret=$ip + return 0 + fi + done return 1 } @@ -3075,6 +3044,23 @@ _p9k_preexec() { _p9k_timer_start=EPOCHREALTIME } +function _p9k_set_iface() { + if [[ ! -x /sbin/ifconfig ]]; then + _p9k_iface=() + return + fi + local line + local iface + for line in ${(f)"$(/sbin/ifconfig 2>/dev/null)"}; do + if [[ $line == (#b)([^[:space:]:]##):[[:space:]]##flags=(<->)'<'* ]]; then + [[ $match[2] == *[13579] ]] && iface=$match[1] || iface= + elif [[ -n $iface && $line == (#b)[[:space:]]##inet[[:space:]]##([0-9.]##)* ]]; then + _p9k_iface[$iface]=$match[1] + iface= + fi + done +} + function _p9k_build_segment() { _p9k_segment_name=${_p9k_segment_name%_joined} if [[ $_p9k_segment_name == custom_* ]]; then @@ -3093,6 +3079,8 @@ function _p9k_set_prompt() { PROMPT=$_p9k_prompt_prefix_left RPROMPT= + (( _p9k_fetch_iface )) && _p9k_set_iface + local -i left_idx=1 right_idx=1 num_lines=$#_p9k_line_segments_left i for i in {1..$num_lines}; do local right= @@ -3544,6 +3532,8 @@ _p9k_init_vars() { typeset -gi _p9k_num_cpus typeset -g _p9k_pwd typeset -g _p9k_pwd_a + typeset -gA _p9k_iface + typeset -gi _p9k_fetch_iface typeset -g P9K_VISUAL_IDENTIFIER typeset -g P9K_CONTENT @@ -3686,7 +3676,7 @@ _p9k_init_params() { _p9k_declare -i POWERLEVEL9K_SHORTEN_DELIMITER_LENGTH _p9k_declare -e POWERLEVEL9K_SHORTEN_DELIMITER _p9k_declare -i POWERLEVEL9K_SHORTEN_DIR_LENGTH - _p9k_declare -s POWERLEVEL9K_IP_INTERFACE "^[^ ]+" + _p9k_declare -s POWERLEVEL9K_IP_INTERFACE "" _p9k_declare -s POWERLEVEL9K_VPN_IP_INTERFACE "tun" _p9k_declare -i POWERLEVEL9K_LOAD_WHICH 5 _p9k_declare -b POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW 0 @@ -4328,6 +4318,11 @@ _p9k_init() { fi _p9k_wrap_zle_widget zle-keymap-select _p9k_zle_keymap_select + + if [[ -n $_POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]] && _p9k_segment_in_use public_ip || + _p9k_segment_in_use ip || _p9k_segment_in_use vpn_ip; then + _p9k_fetch_iface=1 + fi } _p9k_deinit() { -- cgit v1.2.3 From 9e505d3dc13ff01afe0fb3cdd16250826e370d12 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 28 Aug 2019 19:00:55 +0200 Subject: allow network interface to contain colon --- internal/p10k.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 7c1f1945..d48ab097 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3052,7 +3052,7 @@ function _p9k_set_iface() { local line local iface for line in ${(f)"$(/sbin/ifconfig 2>/dev/null)"}; do - if [[ $line == (#b)([^[:space:]:]##):[[:space:]]##flags=(<->)'<'* ]]; then + if [[ $line == (#b)([^[:space:]]##):[[:space:]]##flags=(<->)'<'* ]]; then [[ $match[2] == *[13579] ]] && iface=$match[1] || iface= elif [[ -n $iface && $line == (#b)[[:space:]]##inet[[:space:]]##([0-9.]##)* ]]; then _p9k_iface[$iface]=$match[1] -- cgit v1.2.3 From ce532fea3e6000608415e42305e3df46bf4cd1bc Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 28 Aug 2019 19:32:10 +0200 Subject: try POWERLEVEL9K_DIR_PACKAGE_FILES patterns in order and skip files without "name" in them; fixes #190 --- internal/p10k.zsh | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index d48ab097..966f8b5a 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1225,24 +1225,30 @@ prompt_dir() { () { [[ $_POWERLEVEL9K_SHORTEN_STRATEGY == truncate_with_package_name && $+commands[jq] == 1 && $#_POWERLEVEL9K_DIR_PACKAGE_FILES > 0 ]] || return - local pat="(${(j:|:)_POWERLEVEL9K_DIR_PACKAGE_FILES})" + local pats="(${(j:|:)_POWERLEVEL9K_DIR_PACKAGE_FILES})" local -i i=$#parts local dir=$_p9k_pwd for (( ; i > 0; --i )); do - local pkg_file='' - for pkg_file in $dir/${~pat}(N); do - local -H stat=() - zstat -H stat -- $pkg_file 2>/dev/null || return - if ! _p9k_cache_get $0_pkg $stat[inode] $stat[mtime] $stat[size]; then - local pkg_name='' - pkg_name="$(jq -j '.name' <$pkg_file 2>/dev/null)" || pkg_name='' - _p9k_cache_set "$pkg_name" - fi - [[ -n $_p9k_cache_val[1] ]] || return - parts[1,i]=($_p9k_cache_val[1]) - fake_first=1 - return - done + local markers=($dir/${~pats}(N)) + if (( $#markers )); then + local pat= pkg_file= + for pat in $_POWERLEVEL9K_DIR_PACKAGE_FILES; do + for pkg_file in $markers; do + [[ $pkg_file == $dir/${~pat} ]] || continue + local -H stat=() + zstat -H stat -- $pkg_file 2>/dev/null || continue + if ! _p9k_cache_get $0_pkg $stat[inode] $stat[mtime] $stat[size]; then + local pkg_name='' + pkg_name="$(jq -j '.name | select(. != null)' <$pkg_file 2>/dev/null)" || pkg_name='' + _p9k_cache_set "$pkg_name" + fi + [[ -n $_p9k_cache_val[1] ]] || continue + parts[1,i]=($_p9k_cache_val[1]) + fake_first=1 + return + done + done + fi dir=${dir:h} done } -- cgit v1.2.3 From 84a562eca6a6fe7af511b52fb3560172511a9849 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 28 Aug 2019 21:49:08 +0200 Subject: typo --- internal/p10k.zsh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 966f8b5a..98177c94 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3051,10 +3051,8 @@ _p9k_preexec() { } function _p9k_set_iface() { - if [[ ! -x /sbin/ifconfig ]]; then - _p9k_iface=() - return - fi + _p9k_iface=() + [[ -x /sbin/ifconfig ]] || return local line local iface for line in ${(f)"$(/sbin/ifconfig 2>/dev/null)"}; do -- cgit v1.2.3 From 9bf56e7d46d1ad1808d71cf3e8b15f73311dfdd3 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 29 Aug 2019 11:38:56 +0200 Subject: add an faq entry about auto_name_dirs --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 9cfbceb9..592be93c 100644 --- a/README.md +++ b/README.md @@ -238,6 +238,15 @@ some glyphs. To fix this problem, [install the recommended font](#recommended-meslo-nerd-font-patched-for-powerlevel10k) and run `p10k configure`. +### Why is my current directory displayed as `~_p9k_pwd`? + +This is the intended effect of `auto_name_dirs` option. You can disable this option with the +following command: + +```zsh +echo 'unsetopt auto_name_dirs' >>! ~/.zshrc +``` + ### Why does Powerlevel10k spawn extra processes? Powerlevel10k uses [gitstatus](https://github.com/romkatv/gitstatus) as the backend behind `vcs` -- cgit v1.2.3 From 9fbdebad90c577fd9489ded48f4e3bbd2bf707c7 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 29 Aug 2019 11:40:13 +0200 Subject: update toc --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 592be93c..3a3a5627 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ prompt. 1. [Why is my right prompt wrapping around in a weird way?](#why-is-my-right-prompt-wrapping-around-in-a-weird-way) 1. [I cannot install the recommended font. Help!](#i-cannot-install-the-recommended-font-help) 1. [Why do I have a question mark symbol in my prompt? Is my font broken?](#why-do-i-have-a-question-mark-symbol-in-my-prompt-is-my-font-broken) + 1. [Why is my current directory displayed as `~_p9k_pwd`?](#why-is-my-current-directory-displayed-as-_p9k_pwd) 1. [Why does Powerlevel10k spawn extra processes?](#why-does-powerlevel10k-spawn-extra-processes) 1. [Are there configuration options that make Powerlevel10k slow?](#are-there-configuration-options-that-make-powerlevel10k-slow) 1. [Is Powerlevel10k fast to load?](#is-powerlevel10k-fast-to-load) -- cgit v1.2.3 From 6582c7b25e8bdd5774657f07ccd7e584da167904 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 29 Aug 2019 11:42:14 +0200 Subject: include auto_name_dirs in the config signature --- internal/p10k.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 98177c94..e8003655 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -4098,6 +4098,7 @@ _p9k_must_init() { IFS=$'\1' param_sig="${(@)param_keys:/(#b)(*)/$match[1]=\$$match[1]}" IFS=$'\2' eval "param_sig=x\"$param_sig\"" [[ -o transient_rprompt ]] && param_sig+=t + [[ -o auto_name_dirs ]] && param_sig+=d [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit _p9k_param_sig=$param_sig -- cgit v1.2.3 From cb2ca16f514853bcb6009a861e6b50965f131a20 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 29 Aug 2019 12:25:55 +0200 Subject: add POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT --- config/p10k-classic.zsh | 6 ++++++ config/p10k-lean.zsh | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 0f960e3c..ad3b14f1 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -246,6 +246,12 @@ fi # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty, # directory will be shortened only when prompt doesn't fit. typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this + # many columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least + # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50 # If set to true, embed a hyperlink into the directory. Useful for quickly # opening a directory in the file manager simply by clicking the link. # Can also be handy when the directory is shortened, as it allows you to see diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 34566ea6..833cb6d3 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -228,6 +228,12 @@ fi # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty, # directory will be shortened only when prompt doesn't fit. typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this + # many columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least + # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50 # If set to true, embed a hyperlink into the directory. Useful for quickly # opening a directory in the file manager simply by clicking the link. # Can also be handy when the directory is shortened, as it allows you to see -- cgit v1.2.3 From eb58f0562108595e89cf8857582b34d955fcfd76 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 29 Aug 2019 18:28:04 +0200 Subject: fix load fg color --- internal/p10k.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index e8003655..07c05228 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1594,11 +1594,11 @@ prompt_load() { (( _p9k_num_cpus )) || return if (( load > 0.7 * _p9k_num_cpus )); then - local state=critical bg=red + local state=CRITICAL bg=red elif (( load > 0.5 * _p9k_num_cpus )); then - local state=warning bg=yellow + local state=WARNING bg=yellow else - local state=normal bg=green + local state=NORMAL bg=green fi _p9k_prompt_segment $0_$state $bg "$_p9k_color1" LOAD_ICON 0 '' $load -- cgit v1.2.3 From 71c6843cb47fec88baec15bdbd633b47368a4f7e Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 29 Aug 2019 18:36:36 +0200 Subject: add ram and load --- config/p10k-classic.zsh | 20 ++++++++++++++++++++ config/p10k-lean.zsh | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index ad3b14f1..325bcad3 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -61,6 +61,8 @@ fi context # user@host nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) + # ram # free RAM + # load # CPU load # time # current time # =========================[ Line #2 ]========================= newline @@ -453,6 +455,24 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' + ######################################[ ram: free RAM ]####################################### + # RAM color. + typeset -g POWERLEVEL9K_RAM_FOREGROUND=66 + # Custom icon. + # typeset -g POWERLEVEL9K_RAM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################################[ load: CPU load ]###################################### + # Show average CPU load over this many last minutes. Valid values are 1, 5 and 15. + typeset -g POWERLEVEL9K_LOAD_WHICH=5 + # Load color when load is under 50%. + typeset -g POWERLEVEL9K_LOAD_NORMAL_FOREGROUND=66 + # Load color when load is between 50% and 70%. + typeset -g POWERLEVEL9K_LOAD_WARNING_FOREGROUND=178 + # Load color when load is over 70%. + typeset -g POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND=166 + # Custom icon. + # typeset -g POWERLEVEL9K_LOAD_VISUAL_IDENTIFIER_EXPANSION='⭐' + ####################################[ context: user@host ]#################################### # Default context color. typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=180 diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 833cb6d3..627bc5f4 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -61,6 +61,8 @@ fi context # user@host nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) + # ram # free RAM + # load # CPU load # time # current time # =========================[ Line #2 ]========================= newline @@ -436,6 +438,24 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' + ######################################[ ram: free RAM ]####################################### + # RAM color. + typeset -g POWERLEVEL9K_RAM_FOREGROUND=66 + # Custom icon. + # typeset -g POWERLEVEL9K_RAM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################################[ load: CPU load ]###################################### + # Show average CPU load over this many last minutes. Valid values are 1, 5 and 15. + typeset -g POWERLEVEL9K_LOAD_WHICH=5 + # Load color when load is under 50%. + typeset -g POWERLEVEL9K_LOAD_NORMAL_FOREGROUND=66 + # Load color when load is between 50% and 70%. + typeset -g POWERLEVEL9K_LOAD_WARNING_FOREGROUND=178 + # Load color when load is over 70%. + typeset -g POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND=166 + # Custom icon. + # typeset -g POWERLEVEL9K_LOAD_VISUAL_IDENTIFIER_EXPANSION='⭐' + ####################################[ context: user@host ]#################################### # Default context color. typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=180 -- cgit v1.2.3 From 9a5abe8185870df5e41e5506253fc9575d541dc9 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 30 Aug 2019 08:38:56 +0200 Subject: add comments around git branch shortening --- config/p10k-classic.zsh | 6 ++++-- config/p10k-lean.zsh | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 325bcad3..2115be21 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -321,9 +321,11 @@ fi local vcs='' # If on a branch... vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON} - # If branch name is at most 32 characters long, show it in full. + # If local branch name is at most 32 characters long, show it in full. + # This is the equivalent of POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=32. vcs+='${${${$(($#VCS_STATUS_LOCAL_BRANCH<=32)):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' - # If branch name is over 32 characters long, show the first 12 … the last 12. + # If local branch name is over 32 characters long, show the first 12 … the last 12. The same as + # POWERLEVEL9K_VCS_SHORTEN_LENGTH=12 with POWERLEVEL9K_VCS_SHORTEN_STRATEGY=truncate_middle. vcs+=':-${VCS_STATUS_LOCAL_BRANCH[1,12]//\%/%%}%28F…%76F${VCS_STATUS_LOCAL_BRANCH[-12,-1]//\%/%%}}}' # '@72f5c8a' if not on a branch. vcs+=':-%248F@%76F${VCS_STATUS_COMMIT[1,8]}}' diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 627bc5f4..b90baa81 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -305,8 +305,10 @@ fi # If on a branch... vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON} # If local branch name is at most 32 characters long, show it in full. + # This is the equivalent of POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=32. vcs+='${${${$(($#VCS_STATUS_LOCAL_BRANCH<=32)):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' - # If local branch name is over 32 characters long, show the first 12 … the last 12. + # If local branch name is over 32 characters long, show the first 12 … the last 12. The same as + # POWERLEVEL9K_VCS_SHORTEN_LENGTH=12 with POWERLEVEL9K_VCS_SHORTEN_STRATEGY=truncate_middle. vcs+=':-${VCS_STATUS_LOCAL_BRANCH[1,12]//\%/%%}%28F…%76F${VCS_STATUS_LOCAL_BRANCH[-12,-1]//\%/%%}}}' # '@72f5c8a' if not on a branch. vcs+=':-%f@%76F${VCS_STATUS_COMMIT[1,8]}}' -- cgit v1.2.3 From fff03ea88804a75031c158b3627cd216ac457530 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 30 Aug 2019 12:01:35 +0200 Subject: change the default value of POWERLEVEL9K_VPN_IP_INTERFACE --- internal/p10k.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 07c05228..07408991 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3681,7 +3681,7 @@ _p9k_init_params() { _p9k_declare -e POWERLEVEL9K_SHORTEN_DELIMITER _p9k_declare -i POWERLEVEL9K_SHORTEN_DIR_LENGTH _p9k_declare -s POWERLEVEL9K_IP_INTERFACE "" - _p9k_declare -s POWERLEVEL9K_VPN_IP_INTERFACE "tun" + _p9k_declare -s POWERLEVEL9K_VPN_IP_INTERFACE ".*tun[0-9]*" _p9k_declare -i POWERLEVEL9K_LOAD_WHICH 5 _p9k_declare -b POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -b POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY 0 -- cgit v1.2.3 From 4bed2dc8c0aff2394d409606f931412df471f075 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sun, 1 Sep 2019 14:43:16 +0200 Subject: wizard: add an option to enable `time` segment --- internal/configure.zsh | 2 +- internal/p10k.zsh | 2 +- internal/wizard.zsh | 83 +++++++++++++++++++++++++++++++++++++------------- 3 files changed, 63 insertions(+), 24 deletions(-) diff --git a/internal/configure.zsh b/internal/configure.zsh index c04ad413..811bc28d 100644 --- a/internal/configure.zsh +++ b/internal/configure.zsh @@ -65,7 +65,7 @@ function p9k_configure() { if (( $#p )); then typeset -x -- $p fi - $__p9k_root_dir/internal/wizard.zsh -d $__p9k_root_dir -f $awesome + $__p9k_root_dir/internal/wizard.zsh -d $__p9k_root_dir -f ) || return source $__p9k_cfg_path } diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 07408991..e39abccb 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3250,7 +3250,7 @@ _p9k_precmd() { if (( $#p )); then typeset -x -- $p fi - $__p9k_root_dir/internal/wizard.zsh -d $__p9k_root_dir -f $awesome + $__p9k_root_dir/internal/wizard.zsh -d $__p9k_root_dir ) if (( !$? )); then source $__p9k_cfg_path diff --git a/internal/wizard.zsh b/internal/wizard.zsh index df5a7d50..f9475dac 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -54,22 +54,22 @@ typeset -r vertical_bar='|' typeset -r slanted_bar='\uE0BD' typeset -ra lean_left=( - '' '${extra_icons[1]:+$extra_icons[1] }%31F$extra_icons[2]%B%39F~%b%31F/%B%39Fpowerlevel10k%b%f $prefixes[1]%76F$extra_icons[3]master ⇡2%f ' + '' '${extra_icons[1]:+$extra_icons[1] }%31F$extra_icons[2]%B%39F~%b%31F/%B%39Fsrc%b%f $prefixes[1]%76F$extra_icons[3]master%f ' '' '%76F❯%f █' ) typeset -ra lean_right=( - ' $prefixes[2]%134F⎈ minikube%f' '' + ' $prefixes[2]%101F$extra_icons[4]3s%f${show_time:+ $prefixes[3]%66F$extra_icons[5]16:23:42%f}' '' '' '' ) typeset -ra classic_left=( - '%$frame_color[$color]F╭─' '%F{$bg_color[$color]}$left_tail%K{$bg_color[$color]} ${extra_icons[1]:+$extra_icons[1]%K{$bg_color[$color]\} %$sep_color[$color]F$left_subsep%f }%31F$extra_icons[2]%B%39F~%b%K{$bg_color[$color]}%31F/%B%39Fpowerlevel10k%b%K{$bg_color[$color]} %$sep_color[$color]F$left_subsep%f %$prefix_color[$color]F$prefixes[1]%76F$extra_icons[3]master ⇡2 %k%$bg_color[$color]F$left_head%f' + '%$frame_color[$color]F╭─' '%F{$bg_color[$color]}$left_tail%K{$bg_color[$color]} ${extra_icons[1]:+$extra_icons[1]%K{$bg_color[$color]\} %$sep_color[$color]F$left_subsep%f }%31F$extra_icons[2]%B%39F~%b%K{$bg_color[$color]}%31F/%B%39Fsrc%b%K{$bg_color[$color]} %$sep_color[$color]F$left_subsep%f %$prefix_color[$color]F$prefixes[1]%76F$extra_icons[3]master %k%$bg_color[$color]F$left_head%f' '%$frame_color[$color]F╰─' '%f █' ) typeset -ra classic_right=( - '%$bg_color[$color]F$right_head%K{$bg_color[$color]}%f %$prefix_color[$color]F$prefixes[2]%134Fminikube ⎈ %k%F{$bg_color[$color]}$right_tail%f' '%$frame_color[$color]F─╮%f' + '%$bg_color[$color]F$right_head%K{$bg_color[$color]}%f %$prefix_color[$color]F$prefixes[2]%101F3s $extra_icons[4]${show_time:+%$sep_color[$color]F$right_subsep %$prefix_color[$color]F$prefixes[3]%66F16:23:42 $extra_icons[5]}%k%F{$bg_color[$color]}$right_tail%f' '%$frame_color[$color]F─╮%f' '' '%$frame_color[$color]F─╯%f' ) @@ -169,12 +169,12 @@ function ask_diamond() { while true; do clear if (( force )); then - print -P "This is %4FPowerlevel10k configuration wizard%f. It will ask you a few" - print -P "questions and configure your prompt." + centered "This is %4FPowerlevel10k configuration wizard%f. It will ask you a few questions and" + centered "configure your prompt." else - print -P "This is %4FPowerlevel10k configuration wizard%f. You are seeing it because" - print -P "you haven't defined any Powerlevel10k configuration options. It will" - print -P "ask you a few questions and configure your prompt." + centered "This is %4FPowerlevel10k configuration wizard%f. You are seeing it because you" + centered "haven't defined any Powerlevel10k configuration options. It will ask you a few" + centered "questions and configure your prompt." fi print -P "" centered "%BDoes this look like a %b%2Fdiamond%f%B (square rotated 45 degrees)?%b" @@ -393,6 +393,34 @@ function ask_color() { done } +function ask_time() { + while true; do + clear + centered "%BShow current time?%b" + print -P "" + print -P "%B(y) Yes.%b" + print -P "" + show_time=1 print_prompt + print -P "" + print -P "%B(n) No.%b" + print -P "" + show_time= print_prompt + print -P "" + print -P "(r) Restart from the beginning." + print -P "(q) Quit and do nothing." + print -P "" + + local key= + read -k key${(%):-"?%BChoice [ynrq]: %b"} || quit + case $key in + q) quit;; + r) return 1;; + y) show_time=1; break;; + n) show_time=; break;; + esac + done +} + function os_icon_name() { local uname="$(uname)" if [[ $uname == Linux && "$(uname -o 2>/dev/null)" == Android ]]; then @@ -445,10 +473,14 @@ function ask_extra_icons() { local dir_icon=${(g::)icons[HOME_SUB_ICON]} local vcs_icon=${(g::)icons[VCS_GIT_GITHUB_ICON]} local branch_icon=${(g::)icons[VCS_BRANCH_ICON]} + local duration_icon=${(g::)icons[EXECUTION_TIME_ICON]} + local time_icon=${(g::)icons[TIME_ICON]} if (( cap_narrow_icons )); then os_icon=${os_icon// } dir_icon=${dir_icon// } vcs_icon=${vcs_icon// } + duration_icon=${duration_icon// } + time_icon=${time_icon// } fi branch_icon=${branch_icon// } if [[ $style == classic ]]; then @@ -457,14 +489,15 @@ function ask_extra_icons() { os_icon="%f$os_icon" fi os_icon="%B$os_icon%b" - local many=("$os_icon" "$dir_icon " "$vcs_icon $branch_icon ") + local few=('' '' '' '' '') + local many=("$os_icon" "$dir_icon " "$vcs_icon $branch_icon " "$duration_icon " "$time_icon ") while true; do clear centered "%BIcons%b" print -P "" print -P "%B(1) Few icons.%b" print -P "" - extra_icons=('' '' '') print_prompt + extra_icons=("$few[@]") print_prompt print -P "" print -P "%B(2) Many icons.%b" print -P "" @@ -479,21 +512,22 @@ function ask_extra_icons() { case $key in q) quit;; r) return 1;; - 1) extra_icons=('' '' ''); options+='few icons'; break;; + 1) extra_icons=("$few[@]"); options+='few icons'; break;; 2) extra_icons=("$many[@]"); options+='many icons'; break;; esac done } function ask_prefixes() { - local fluent=('on ' 'at ') + local concise=('' '' '') + local fluent=('on ' 'took ' 'at ') while true; do clear centered "%BPrompt Flow%b" print -P "" print -P "%B(1) Concise.%b" print -P "" - prefixes=('' '') print_prompt + prefixes=("$concise[@]") print_prompt print -P "" print -P "%B(2) Fluent.%b" print -P "" @@ -508,7 +542,7 @@ function ask_prefixes() { case $key in q) quit;; r) return 1;; - 1) prefixes=('' ''); options+=concise; break;; + 1) prefixes=("$concise[@]"); options+=concise; break;; 2) prefixes=("$fluent[@]"); options+=fluent; break;; esac done @@ -522,9 +556,9 @@ function ask_separators() { local extra= clear centered "%BPrompt Separators%b" - print -P " separator" - print -P "%B(1) Angled.%b |" - print -P " v" + print -P " separator" + print -P "%B(1) Angled.%b /" + print -P " /" left_sep=$right_triangle right_sep=$left_triangle left_subsep=$right_angle right_subsep=$left_angle print_prompt print -P "" print -P "%B(2) Vertical.%b" @@ -585,9 +619,9 @@ function ask_heads() { local extra= clear centered "%BPrompt Heads%b" - print -P "" - print -P "%B(1) Sharp.%b" - print -P "" + print -P " head" + print -P "%B(1) Sharp.%b |" + print -P " v" left_head=$right_triangle right_head=$left_triangle print_prompt print -P "" print -P "%B(2) Blurred.%b" @@ -950,6 +984,10 @@ function generate_config() { rep '%248F' "%$prefix_color[$color]F" fi + if [[ -n $show_time ]]; then + uncomment time + fi + if [[ -n ${(j::)extra_icons} ]]; then local branch_icon=${icons[VCS_BRANCH_ICON]// } sub VCS_BRANCH_ICON "'$branch_icon '" @@ -1075,7 +1113,7 @@ source $__p9k_root_dir/internal/icons.zsh || return while true; do local POWERLEVEL9K_MODE= style= config_backup= config_backup_u= gap_char=' ' - local left_subsep= right_subsep= left_tail= right_tail= left_head= right_head= + local left_subsep= right_subsep= left_tail= right_tail= left_head= right_head= show_time= local -i num_lines=0 write_config=0 empty_line=0 color=2 left_frame=1 right_frame=1 local -i cap_diamond=0 cap_python=0 cap_debian=0 cap_narrow_icons=0 cap_lock=0 local -a extra_icons=('' '' '') @@ -1134,6 +1172,7 @@ while true; do ask_narrow_icons || continue ask_style || continue ask_color || continue + ask_time || continue ask_separators || continue ask_heads || continue ask_tails || continue -- cgit v1.2.3 From 61f5552c98aca6b0f41172a16391a842e1593594 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sun, 1 Sep 2019 21:35:40 +0200 Subject: stupid typo --- internal/wizard.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index f9475dac..7a5954ac 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -1156,7 +1156,7 @@ while true; do else options+="$POWERLEVEL9K_MODE" fi - (( cap_python )) && options[-1] += ' + python' + (( cap_python )) && options[-1]+=' + python' if (( cap_diamond )); then left_subsep=$right_angle right_subsep=$left_angle -- cgit v1.2.3 From 8ace14beb068b662088f38ccba33b78f8e79bffd Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 2 Sep 2019 13:19:38 +0200 Subject: don't set prompt_sp Some users prefer to hide the last line of command output if it doesn't end in \n. Powerlevel10k should respect their choice. See #197. --- internal/p10k.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index e39abccb..7ff2e7ee 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3262,8 +3262,9 @@ _p9k_precmd() { fi unsetopt localoptions - prompt_opts=(cr percent sp subst) - setopt nopromptbang prompt{cr,percent,sp,subst} + prompt_opts=(cr percent subst) + [[ ! -o prompt_sp ]] || prompt_opts+=sp + setopt nopromptbang prompt{cr,percent,subst} _p9k_timer_end=EPOCHREALTIME if (( _p9k_timer_start )); then -- cgit v1.2.3 From 1547336bb6012189632f43ccb6730b02e7425ad0 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 2 Sep 2019 13:52:17 +0200 Subject: don't set prompt_cr Some users prefer to have broken prompt if the last line of command output doesn't end in \n. Powerlevel10k should respect their choice. See #197. --- internal/p10k.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 7ff2e7ee..aaea53ec 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3262,9 +3262,10 @@ _p9k_precmd() { fi unsetopt localoptions - prompt_opts=(cr percent subst) + prompt_opts=(percent subst) [[ ! -o prompt_sp ]] || prompt_opts+=sp - setopt nopromptbang prompt{cr,percent,subst} + [[ ! -o prompt_cr ]] || prompt_opts+=cr + setopt nopromptbang prompt{percent,subst} _p9k_timer_end=EPOCHREALTIME if (( _p9k_timer_start )); then -- cgit v1.2.3 From db6d36e09fbbe82ea9c9338e74d22b9faf723f3e Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 2 Sep 2019 17:32:45 +0200 Subject: wizard: reduce the minimum required terminal width from 80 to 51 --- internal/configure.zsh | 2 +- internal/wizard.zsh | 29 +++++++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/internal/configure.zsh b/internal/configure.zsh index 811bc28d..2ed0cdb0 100644 --- a/internal/configure.zsh +++ b/internal/configure.zsh @@ -1,4 +1,4 @@ -typeset -gr __p9k_wizard_columns=80 +typeset -gr __p9k_wizard_columns=51 typeset -gr __p9k_wizard_lines=21 typeset -gr __p9k_zd=${${ZDOTDIR:-$HOME}:A} typeset -gr __p9k_zd_u=${${${(q-)__p9k_zd}/#(#b)$HOME(|\/*)/'~'$match[1]}//\%/%%} diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 7a5954ac..c9dc9e89 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -35,6 +35,8 @@ typeset -gri force source $__p9k_root_dir/internal/configure.zsh || return +typeset -ri wizard_columns=$((COLUMNS < 80 ? COLUMNS : 80)) + typeset -ri prompt_indent=2 typeset -ra bg_color=(240 238 236 234) @@ -106,14 +108,14 @@ function print_prompt() { fi local -i right_indent=prompt_indent local -i width=$(prompt_length ${(g::):-$left[1]$left[2]$right[1]$right[2]}) - while (( __p9k_wizard_columns - width <= prompt_indent + right_indent )); do + while (( wizard_columns - width <= prompt_indent + right_indent )); do (( --right_indent )) done local -i i for ((i = 1; i < $#left; i+=2)); do local l=${(g::):-$left[i]$left[i+1]} local r=${(g::):-$right[i]$right[i+1]} - local -i gap=$((__p9k_wizard_columns - prompt_indent - right_indent - $(prompt_length $l$r))) + local -i gap=$((wizard_columns - prompt_indent - right_indent - $(prompt_length $l$r))) (( num_lines == 2 && i == 1 )) && local fill=$gap_char || local fill=' ' print -n -- ${(pl:$prompt_indent:: :)} print -nP -- $l @@ -128,7 +130,7 @@ function href() { function centered() { local n=$(prompt_length ${(g::)1}) - print -n -- ${(pl:$(((__p9k_wizard_columns - n) / 2)):: :)} + (( n < wizard_columns )) && print -n -- ${(pl:$(((wizard_columns - n) / 2)):: :)} print -P -- $1 } @@ -168,14 +170,7 @@ function quit() { function ask_diamond() { while true; do clear - if (( force )); then - centered "This is %4FPowerlevel10k configuration wizard%f. It will ask you a few questions and" - centered "configure your prompt." - else - centered "This is %4FPowerlevel10k configuration wizard%f. You are seeing it because you" - centered "haven't defined any Powerlevel10k configuration options. It will ask you a few" - centered "questions and configure your prompt." - fi + centered "%4FPowerlevel10k configuration wizard%f." print -P "" centered "%BDoes this look like a %b%2Fdiamond%f%B (square rotated 45 degrees)?%b" centered "reference: $(href https://graphemica.com/%E2%97%86)" @@ -394,6 +389,11 @@ function ask_color() { } function ask_time() { + if (( wizard_columns < 80 )); then + show_time= + return + fi + while true; do clear centered "%BShow current time?%b" @@ -415,7 +415,7 @@ function ask_time() { case $key in q) quit;; r) return 1;; - y) show_time=1; break;; + y) show_time=1; options+=time; break;; n) show_time=; break;; esac done @@ -521,6 +521,11 @@ function ask_extra_icons() { function ask_prefixes() { local concise=('' '' '') local fluent=('on ' 'took ' 'at ') + if (( wizard_columns < 80 )); then + prefixes=("$concise[@]") + options+=concise + return + fi while true; do clear centered "%BPrompt Flow%b" -- cgit v1.2.3 From 5eb555e9a436a632585cbcbd51cb4767d44e73d1 Mon Sep 17 00:00:00 2001 From: George Schizas Date: Tue, 3 Sep 2019 10:40:45 +0300 Subject: Fix name of old windows terminal emulator Command prompt is the shell, Console Host is the (equivalent) of xterm. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3a3a5627..3b926b55 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ applications on your system. Configure your terminal to use this font: `MesloLGS NF` under `module.exports.config`. - **Visual Studio Code**: Open *File → Preferences → Settings*, enter `terminal.integrated.fontFamily` in the search box and set value to `MesloLGS NF`. -- **Windows Command Prompt** (the old thing): Click the icon in the top left corner, then +- **Windows Console Host** (the old thing): Click the icon in the top left corner, then *Properties → Font* and set *Font* to `MesloLGS NF`. - **Windows Terminal** (the new thing): Open *Settings* (`Ctrl+,`), search for `fontFace` and set value to `MesloLGS NF` for every profile. -- cgit v1.2.3 From d6041f53aa17402298fd05ac4309dafb34dd75e7 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 3 Sep 2019 10:18:19 +0200 Subject: wizard: make it look better on narrow screens --- internal/configure.zsh | 2 +- internal/wizard.zsh | 33 +++++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/internal/configure.zsh b/internal/configure.zsh index 2ed0cdb0..fd9e8593 100644 --- a/internal/configure.zsh +++ b/internal/configure.zsh @@ -1,4 +1,4 @@ -typeset -gr __p9k_wizard_columns=51 +typeset -gr __p9k_wizard_columns=55 typeset -gr __p9k_wizard_lines=21 typeset -gr __p9k_zd=${${ZDOTDIR:-$HOME}:A} typeset -gr __p9k_zd_u=${${${(q-)__p9k_zd}/#(#b)$HOME(|\/*)/'~'$match[1]}//\%/%%} diff --git a/internal/wizard.zsh b/internal/wizard.zsh index c9dc9e89..87d20823 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -129,9 +129,22 @@ function href() { } function centered() { - local n=$(prompt_length ${(g::)1}) - (( n < wizard_columns )) && print -n -- ${(pl:$(((wizard_columns - n) / 2)):: :)} - print -P -- $1 + local line word lines=() + for word in "$@"; do + local n=$(prompt_length ${(g::):-"$line $word"}) + if (( n > wizard_columns )); then + [[ -z $line ]] || lines+=$line + line= + fi + [[ -z $line ]] || line+=' ' + line+=$word + done + [[ -z $line ]] || lines+=$line + for line in $lines; do + local n=$(prompt_length ${(g::)line}) + (( n < wizard_columns )) && print -n -- ${(pl:$(((wizard_columns - n) / 2)):: :)} + print -P -- $line + done } function clear() { @@ -170,9 +183,17 @@ function quit() { function ask_diamond() { while true; do clear - centered "%4FPowerlevel10k configuration wizard%f." + if (( force )); then + centered This is %4FPowerlevel10k configuration wizard%f. \ + It will ask you a few questions and configure your prompt. + else + centered This is %4FPowerlevel10k configuration wizard%f. \ + You are seeing it because you haven\'t defined any \ + Powerlevel10k configuration options. It will ask \ + you a few questions and configure your prompt. + fi print -P "" - centered "%BDoes this look like a %b%2Fdiamond%f%B (square rotated 45 degrees)?%b" + centered "%BDoes this look like a %b%2Fdiamond%f%B (rotated square)?%b" centered "reference: $(href https://graphemica.com/%E2%97%86)" print -P "" centered "---> \uE0B2\uE0B0 <---" @@ -253,7 +274,7 @@ function ask_debian() { while true; do clear centered "%BDoes this look like a %b%2FDebian logo%f%B (swirl/spiral)?%b" - centered "reference: $(href https://www.debian.org/logos/openlogo-nd-100.jpg)" + centered "reference: $(href https://debian.org/logos/openlogo-nd.svg)" print -P "" centered "---> \uF306 <---" print -P "" -- cgit v1.2.3 From 37dc2ba5e25bfe79071420adda0186ea3ce07e37 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 3 Sep 2019 10:38:47 +0200 Subject: wizard: better text overflow --- internal/wizard.zsh | 95 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 40 deletions(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 87d20823..153f02fb 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -128,7 +128,18 @@ function href() { print -r -- $'%{\e]8;;'${1//\%/%%}$'\a%}'${1//\%/%%}$'%{\e]8;;\a%}' } -function centered() { +function flowing() { + local opt + local -i centered indentation + while getopts 'ci:' opt; do + case $opt in + i) indentation=$OPTARG;; + c) centered=1;; + +c) centered=0;; + \?) exit 1;; + esac + done + shift $((OPTIND-1)) local line word lines=() for word in "$@"; do local n=$(prompt_length ${(g::):-"$line $word"}) @@ -136,13 +147,17 @@ function centered() { [[ -z $line ]] || lines+=$line line= fi - [[ -z $line ]] || line+=' ' + if [[ -n $line ]]; then + line+=' ' + elif (( $#lines )); then + line=${(pl:$indentation:: :)} + fi line+=$word done [[ -z $line ]] || lines+=$line for line in $lines; do local n=$(prompt_length ${(g::)line}) - (( n < wizard_columns )) && print -n -- ${(pl:$(((wizard_columns - n) / 2)):: :)} + (( centered && n < wizard_columns )) && print -n -- ${(pl:$(((wizard_columns - n) / 2)):: :)} print -P -- $line done } @@ -184,19 +199,19 @@ function ask_diamond() { while true; do clear if (( force )); then - centered This is %4FPowerlevel10k configuration wizard%f. \ - It will ask you a few questions and configure your prompt. + flowing -c This is %4FPowerlevel10k configuration wizard%f. \ + It will ask you a few questions and configure your prompt. else - centered This is %4FPowerlevel10k configuration wizard%f. \ - You are seeing it because you haven\'t defined any \ - Powerlevel10k configuration options. It will ask \ - you a few questions and configure your prompt. + flowing -c This is %4FPowerlevel10k configuration wizard%f. \ + You are seeing it because you haven\'t defined any \ + Powerlevel10k configuration options. It will ask \ + you a few questions and configure your prompt. fi print -P "" - centered "%BDoes this look like a %b%2Fdiamond%f%B (rotated square)?%b" - centered "reference: $(href https://graphemica.com/%E2%97%86)" + flowing -c "%BDoes this look like a %b%2Fdiamond%f%B (rotated square)?%b" + flowing -c "reference: $(href https://graphemica.com/%E2%97%86)" print -P "" - centered "---> \uE0B2\uE0B0 <---" + flowing -c -- "---> \uE0B2\uE0B0 <---" print -P "" print -P "%B(y) Yes.%b" print -P "" @@ -218,11 +233,11 @@ function ask_diamond() { function ask_lock() { while true; do clear - [[ -n $2 ]] && centered "$2" - centered "%BDoes this look like a %b%2Flock%f%B?%b" - centered "reference: $(href https://fontawesome.com/icons/lock)" + [[ -n $2 ]] && flowing -c "$2" + flowing -c "%BDoes this look like a %b%2Flock%f%B?%b" + flowing -c "reference: $(href https://fontawesome.com/icons/lock)" print -P "" - centered "---> $1 <---" + flowing -c -- "---> $1 <---" print -P "" print -P "%B(y) Yes.%b" print -P "" @@ -246,10 +261,10 @@ function ask_lock() { function ask_python() { while true; do clear - centered "%BDoes this look like a %b%2FPython logo%f%B?%b" - centered "reference: $(href https://fontawesome.com/icons/python)" + flowing -c "%BDoes this look like a %b%2FPython logo%f%B?%b" + flowing -c "reference: $(href https://fontawesome.com/icons/python)" print -P "" - centered "---> \uE63C <---" + flowing -c -- "---> \uE63C <---" print -P "" print -P "%B(y) Yes.%b" print -P "" @@ -273,10 +288,10 @@ function ask_python() { function ask_debian() { while true; do clear - centered "%BDoes this look like a %b%2FDebian logo%f%B (swirl/spiral)?%b" - centered "reference: $(href https://debian.org/logos/openlogo-nd.svg)" + flowing -c "%BDoes this look like a %b%2FDebian logo%f%B (swirl/spiral)?%b" + flowing -c "reference: $(href https://debian.org/logos/openlogo-nd.svg)" print -P "" - centered "---> \uF306 <---" + flowing -c -- "---> \uF306 <---" print -P "" print -P "%B(y) Yes.%b" print -P "" @@ -314,11 +329,11 @@ function ask_narrow_icons() { text+="%3F${icons[RAM_ICON]// }%fX" while true; do clear - centered "%BDo all these icons %b%2Ffit between the crosses%f%B?%b" + flowing -c "%BDo all these icons %b%2Ffit between the crosses%f%B?%b" print -P "" - centered "---> $text <---" + flowing -c -- "---> $text <---" print -P "" - print -P "%B(y) Yes. Icons are very close to the crosses but there is %b%2Fno overlap%f%B.%b" + flowing +c -i 5 "%B(y) Yes." Icons are very close to the crosses but there is "%b%2Fno overlap%f%B.%b" print -P "" print -P "%B(n) No. Some icons %b%2Foverlap%f%B neighbouring crosses.%b" print -P "" @@ -340,7 +355,7 @@ function ask_narrow_icons() { function ask_style() { while true; do clear - centered "%BPrompt Style%b" + flowing -c "%BPrompt Style%b" print -P "" print -P "%B(1) Lean.%b" print -P "" @@ -374,7 +389,7 @@ function ask_color() { fi while true; do clear - centered "%BPrompt Color%b" + flowing -c "%BPrompt Color%b" print -n $nl print -P "%B(1) Lightest.%b" print -n $nl @@ -417,7 +432,7 @@ function ask_time() { while true; do clear - centered "%BShow current time?%b" + flowing -c "%BShow current time?%b" print -P "" print -P "%B(y) Yes.%b" print -P "" @@ -514,7 +529,7 @@ function ask_extra_icons() { local many=("$os_icon" "$dir_icon " "$vcs_icon $branch_icon " "$duration_icon " "$time_icon ") while true; do clear - centered "%BIcons%b" + flowing -c "%BIcons%b" print -P "" print -P "%B(1) Few icons.%b" print -P "" @@ -549,7 +564,7 @@ function ask_prefixes() { fi while true; do clear - centered "%BPrompt Flow%b" + flowing -c "%BPrompt Flow%b" print -P "" print -P "%B(1) Concise.%b" print -P "" @@ -581,7 +596,7 @@ function ask_separators() { while true; do local extra= clear - centered "%BPrompt Separators%b" + flowing -c "%BPrompt Separators%b" print -P " separator" print -P "%B(1) Angled.%b /" print -P " /" @@ -644,7 +659,7 @@ function ask_heads() { while true; do local extra= clear - centered "%BPrompt Heads%b" + flowing -c "%BPrompt Heads%b" print -P " head" print -P "%B(1) Sharp.%b |" print -P " v" @@ -697,7 +712,7 @@ function ask_tails() { while true; do local extra= clear - centered "%BPrompt Tails%b" + flowing -c "%BPrompt Tails%b" print -n $nl print -P "%B(1) Flat.%b" print -n $nl @@ -755,7 +770,7 @@ function ask_tails() { function ask_num_lines() { while true; do clear - centered "%BPrompt Height%b" + flowing -c "%BPrompt Height%b" print -P "" print -P "%B(1) One line.%b" print -P "" @@ -786,7 +801,7 @@ function ask_gap_char() { fi while true; do clear - centered "%BPrompt Connection%b" + flowing -c "%BPrompt Connection%b" print -P "" print -P "%B(1) Disconnected.%b" print -P "" @@ -824,7 +839,7 @@ function ask_frame() { (( LINES >= 26 )) && local nl=$'\n' || local nl='' while true; do clear - centered "%BPrompt Frame%b" + flowing -c "%BPrompt Frame%b" print -n $nl print -P "%B(1) No frame.%b" print -n $nl @@ -862,7 +877,7 @@ function ask_frame() { function ask_empty_line() { while true; do clear - centered "%BPrompt Spacing%b" + flowing -c "%BPrompt Spacing%b" print -P "" print -P "%B(1) Compact.%b" print -P "" @@ -893,7 +908,7 @@ function ask_empty_line() { function ask_confirm() { while true; do clear - centered "%BLooks good?%b" + flowing -c "%BLooks good?%b" print -P "" print_prompt (( empty_line )) && print -P "" @@ -923,8 +938,8 @@ function ask_config_overwrite() { fi while true; do clear - centered "Powerlevel10k config file already exists." - centered "%BOverwrite %b%2F${__p9k_cfg_path_u//\\/\\\\}%f%B?%b" + flowing -c "Powerlevel10k config file already exists." + flowing -c "%BOverwrite" "%b%2F${__p9k_cfg_path_u//\\/\\\\}%f%B?%b" print -P "" print -P "%B(y) Yes.%b" print -P "" -- cgit v1.2.3 From f59997f4720722e6263967e7e1c8ce3c16090de5 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 3 Sep 2019 11:57:13 +0200 Subject: wizard: add round separators, heads and tails --- internal/wizard.zsh | 90 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 77 insertions(+), 13 deletions(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 153f02fb..476690dd 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -44,6 +44,10 @@ typeset -ra frame_color=(244 242 240 238) typeset -ra sep_color=(248 246 244 242) typeset -ra prefix_color=(250 248 246 244) +typeset -r left_circle='\uE0B6' +typeset -r right_circle='\uE0B4' +typeset -r left_arc='\uE0B7' +typeset -r right_arc='\uE0B5' typeset -r left_triangle='\uE0B2' typeset -r right_triangle='\uE0B0' typeset -r left_angle='\uE0B3' @@ -593,25 +597,39 @@ function ask_separators() { if [[ $style != classic || $cap_diamond != 1 ]]; then return fi + if [[ $POWERLEVEL9K_MODE == nerdfont-complete && $LINES -lt 26 ]]; then + local nl='' + else + local nl=$'\n' + fi while true; do local extra= clear flowing -c "%BPrompt Separators%b" - print -P " separator" - print -P "%B(1) Angled.%b /" - print -P " /" + if [[ -n $nl ]]; then + print -P " separator" + print -P "%B(1) Angled.%b /" + print -P " /" + else + print -P "%B(1) Angled.%b" + fi left_sep=$right_triangle right_sep=$left_triangle left_subsep=$right_angle right_subsep=$left_angle print_prompt print -P "" print -P "%B(2) Vertical.%b" - print -P "" + print -n $nl left_sep='' right_sep='' left_subsep=$vertical_bar right_subsep=$vertical_bar print_prompt print -P "" if [[ $POWERLEVEL9K_MODE == nerdfont-complete ]]; then extra+=3 print -P "%B(3) Slanted.%b" - print -P "" + print -n $nl left_sep=$down_triangle right_sep=$up_triangle left_subsep=$slanted_bar right_subsep=$slanted_bar print_prompt print -P "" + extra+=4 + print -P "%B(4) Round.%b" + print -n $nl + left_sep=$right_circle right_sep=$left_circle left_subsep=$right_arc right_subsep=$left_arc print_prompt + print -P "" fi print -P "(r) Restart from the beginning." print -P "(q) Quit and do nothing." @@ -648,6 +666,16 @@ function ask_separators() { break fi ;; + 4) + if [[ $extra == *4* ]]; then + left_sep=$right_circle + right_sep=$left_circle + left_subsep=$right_arc + right_subsep=$left_arc + options+='round separators' + break + fi + ;; esac done } @@ -656,32 +684,46 @@ function ask_heads() { if [[ $style != classic || $cap_diamond != 1 ]]; then return fi + if [[ $POWERLEVEL9K_MODE == nerdfont-complete && $LINES -lt 26 ]]; then + local nl='' + else + local nl=$'\n' + fi while true; do local extra= clear flowing -c "%BPrompt Heads%b" - print -P " head" - print -P "%B(1) Sharp.%b |" - print -P " v" + if [[ -n $nl ]]; then + print -P " head" + print -P "%B(1) Sharp.%b |" + print -P " v" + else + print -P "%B(1) Sharp.%b" + fi left_head=$right_triangle right_head=$left_triangle print_prompt print -P "" print -P "%B(2) Blurred.%b" - print -P "" + print -n $nl left_head=$fade_out right_head=$fade_in print_prompt print -P "" if [[ $POWERLEVEL9K_MODE == nerdfont-complete ]]; then extra+=3 print -P "%B(3) Slanted.%b" - print -P "" + print -n $nl left_head=$down_triangle right_head=$up_triangle print_prompt print -P "" + extra+=4 + print -P "%B(4) Round.%b" + print -n $nl + left_head=$right_circle right_head=$left_circle print_prompt + print -P "" fi print -P "(r) Restart from the beginning." print -P "(q) Quit and do nothing." print -P "" local key= - read -k key${(%):-"?%BChoice [12rq]: %b"} || quit + read -k key${(%):-"?%BChoice [12${extra}rq]: %b"} || quit case $key in q) quit;; r) return 1;; @@ -695,6 +737,14 @@ function ask_heads() { break fi ;; + 4) + if [[ $extra == *4* ]]; then + left_head=$right_circle + right_head=$left_circle + options+='round heads' + break + fi + ;; esac done } @@ -703,8 +753,7 @@ function ask_tails() { if [[ $style != classic ]]; then return fi - - if [[ $POWERLEVEL9K_MODE == nerdfont-complete && $LINES -lt 26 ]]; then + if [[ $POWERLEVEL9K_MODE == nerdfont-complete && $LINES -lt 31 ]]; then local nl='' else local nl=$'\n' @@ -734,6 +783,13 @@ function ask_tails() { print -n $nl left_tail=$up_triangle right_tail=$down_triangle print_prompt print -P "" + if (( LINES >= 25 )); then + extra+=5 + print -P "%B(5) Round.%b" + print -n $nl + left_tail=$left_circle right_tail=$right_circle print_prompt + print -P "" + fi fi fi print -P "(r) Restart from the beginning." @@ -763,6 +819,14 @@ function ask_tails() { break fi ;; + 5) + if [[ $extra == *5* ]]; then + left_tail=$left_circle + right_tail=$right_circle + options+='round tails' + break + fi + ;; esac done } -- cgit v1.2.3 From a30b5963a89967e0496936f5d7f53c3d1f16b523 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 3 Sep 2019 12:05:56 +0200 Subject: wizard: better text overflow --- internal/wizard.zsh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 476690dd..04518555 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -1192,7 +1192,7 @@ function write_zshrc() { local f6="\"$f1\"" local f7="\"$f3\"" if [[ -n ${(@M)lines:#(#b)[^#]#([^[:IDENT:]]|)source[[:space:]]##($f1|$f2|$f3|$f4|$f5|$f6|$f7)*} ]]; then - print -rP "No changes have been made to %4F$__p9k_zshrc_u%f because it already sources %2F$__p9k_cfg_path_u%f." + flowing +c No changes have been made to %4F$__p9k_zshrc_u%f because it already sources %2F$__p9k_cfg_path_u%f. return fi fi @@ -1203,7 +1203,7 @@ function write_zshrc() { print -lrP -- "" $comments "[[ -f $__p9k_cfg_path_u ]] && source $__p9k_cfg_path_u" >>$__p9k_zshrc print -rP "" - print -rP "The following lines have been appended to %4F$__p9k_zshrc_u%f:" + flowing +c The following lines have been appended to %4F$__p9k_zshrc_u%f: print -rP "" print -lrP -- ' '${^comments} " %3F[[%f %B-f $__p9k_cfg_path_u%b %3F]]%f && %2Fsource%f %B$__p9k_cfg_path_u%b" } @@ -1294,9 +1294,9 @@ done clear -print -rP "Powerlevel10k configuration has been written to %2F$__p9k_cfg_path_u%f." +flowing +c Powerlevel10k configuration has been written to %2F$__p9k_cfg_path_u%f. if [[ -n $config_backup ]]; then - print -rP "The backup of the previuos version is at %3F$config_backup_u%f." + flowing +c The backup of the previuos version is at %3F$config_backup_u%f. fi if (( write_config )); then @@ -1306,8 +1306,7 @@ fi write_zshrc || return print -rP "" -print -rP "File feature requests and bug reports at $(href https://github.com/romkatv/powerlevel10k/issues)." -print -rP "Send praise and complaints to $(href https://www.reddit.com/r/zsh)." +flowing +c File feature requests and bug reports at "$(href https://github.com/romkatv/powerlevel10k/issues)." print -rP "" } "$@" -- cgit v1.2.3 From 684203221fc73ea836d486a68a55e6e475bae7e9 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 3 Sep 2019 13:55:41 +0200 Subject: wizard: offer to install Meslo NF on Termux --- internal/wizard.zsh | 110 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 98 insertions(+), 12 deletions(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 04518555..afef036d 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -35,6 +35,7 @@ typeset -gri force source $__p9k_root_dir/internal/configure.zsh || return +typeset -r font_base_url='https://github.com/romkatv/dotfiles-public/raw/master/.local/share/fonts/NerdFonts' typeset -ri wizard_columns=$((COLUMNS < 80 ? COLUMNS : 80)) typeset -ri prompt_indent=2 @@ -177,7 +178,11 @@ function clear() { } function quit() { - clear + if [[ $1 == '-c' ]]; then + print -P "" + else + clear + fi if (( force )); then print -P "Powerlevel10k configuration wizard has been aborted. To run it again, type:" print -P "" @@ -199,19 +204,93 @@ function quit() { exit 1 } -function ask_diamond() { - while true; do - clear - if (( force )); then - flowing -c This is %4FPowerlevel10k configuration wizard%f. \ - It will ask you a few questions and configure your prompt. +local -i greeting_printed=0 + +function print_greeting() { + (( greeting_printed )) && return + if (( force )); then + flowing -c This is %4FPowerlevel10k configuration wizard%f. \ + It will ask you a few questions and configure your prompt. + else + flowing -c This is %4FPowerlevel10k configuration wizard%f. \ + You are seeing it because you haven\'t defined any \ + Powerlevel10k configuration options. It will ask \ + you a few questions and configure your prompt. + fi + print -P "" +} + +function can_install_font() { + [[ $P9K_SSH == 0 ]] || return + if [[ "$(uname)" == Linux && "$(uname -o)" == Android ]]; then + (( $+commands[termux-reload-settings] )) || return + (( $+commands[curl] )) || return + [[ ! -f ~/.termux/font.ttf ]] || return + if [[ -f ~/.termux ]]; then + [[ -d ~/.termux && -w ~/.termux ]] || return else - flowing -c This is %4FPowerlevel10k configuration wizard%f. \ - You are seeing it because you haven\'t defined any \ - Powerlevel10k configuration options. It will ask \ - you a few questions and configure your prompt. + [[ -w ~ ]] || return + fi + return + fi + return 1 +} + +function run_command() { + print -nP -- "$1 ..." + shift + local err && err="$("$@" 2>&1)" || { + print -P " %1FERROR%f" + print -P "" + print -P "%BCommand:%b" "${(@q)*}" + if [[ -n $err ]]; then + print -P "" + print -r -- $err fi + quit -c + } + print -P " %2FOK%f" +} + +function install_font() { + clear + mkdir -p ~/.termux || quit -c + run_command "Downloading %2FMesloLGS NF Regular.ttf%f" \ + curl -fsSL -o ~/.termux/font.ttf "$font_base_url/MesloLGS%20NF%20Regular.ttf" + run_command "Reloading Termux settings" termux-reload-settings +} + +function ask_font() { + can_install_font || return 0 + while true; do + clear + print_greeting + flowing -c "%BInstall %b%2FMeslo Nerd Font%f%B?%b" + print -P "" + print -P "" + print -P "%B(y) Yes (recommended).%b" print -P "" + print -P "%B(n) No. Use the current font.%b" + print -P "" + print -P "(q) Quit and do nothing." + print -P "" + + local key= + read -k key${(%):-"?%BChoice [ynq]: %b"} || quit + case $key in + q) quit;; + y) install_font; break;; + n) break;; + esac + done + greeting_printed=1 +} + +function ask_diamond() { + while true; do + local extra= + clear + print_greeting flowing -c "%BDoes this look like a %b%2Fdiamond%f%B (rotated square)?%b" flowing -c "reference: $(href https://graphemica.com/%E2%97%86)" print -P "" @@ -221,17 +300,23 @@ function ask_diamond() { print -P "" print -P "%B(n) No.%b" print -P "" + if can_install_font; then + extra+=r + print -P "(r) Restart from the beginning." + fi print -P "(q) Quit and do nothing." print -P "" local key= - read -k key${(%):-"?%BChoice [ynq]: %b"} || quit + read -k key${(%):-"?%BChoice [yn${extra}q]: %b"} || quit case $key in q) quit;; + r) [[ $extra == *r* ]] && { greeting_printed=1; return 1 };; y) cap_diamond=1; break;; n) cap_diamond=0; break;; esac done + greeting_printed=1 } function ask_lock() { @@ -1225,6 +1310,7 @@ while true; do local -a prefixes=('' '') local -a options=() + ask_font || continue ask_diamond || continue if [[ $AWESOME_GLYPHS_LOADED == 1 ]]; then POWERLEVEL9K_MODE=awesome-mapped-fontconfig -- cgit v1.2.3 From ebcb8cd307bfe1564b250f0b0b951e05439de496 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 3 Sep 2019 20:01:10 +0200 Subject: wizard: offer to install Meslo NF on iTerm2 --- internal/wizard.zsh | 130 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 101 insertions(+), 29 deletions(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index afef036d..67ef170a 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -4,7 +4,7 @@ emulate -L zsh setopt noaliases () { -setopt extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} +setopt extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} typeset_silent zmodload zsh/langinfo if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} @@ -19,7 +19,7 @@ while getopts 'd:f' opt; do d) __p9k_root_dir=$OPTARG;; f) force=1;; +f) force=0;; - '?') return 1;; + \?) return 1;; esac done @@ -220,6 +220,12 @@ function print_greeting() { print -P "" } +function iterm_get() { + /usr/libexec/PlistBuddy -c "Print :$1" ~/Library/Preferences/com.googlecode.iterm2.plist +} + +local terminal iterm2_font_size + function can_install_font() { [[ $P9K_SSH == 0 ]] || return if [[ "$(uname)" == Linux && "$(uname -o)" == Android ]]; then @@ -231,33 +237,99 @@ function can_install_font() { else [[ -w ~ ]] || return fi + terminal=Termux + return + fi + if [[ "$(uname)" == Darwin && $TERM_PROGRAM == iTerm.app ]]; then + [[ $TERM_PROGRAM_VERSION == (2|3)* ]] || return + if [[ -f ~/Library/Fonts ]]; then + [[ -d ~/Library/Fonts && -w ~/Library/Fonts ]] || return + else + [[ -d ~/Library && -w ~/Library ]] || return + fi + [[ -x /usr/libexec/PlistBuddy ]] || return + [[ -x /usr/bin/plutil ]] || return + [[ -x /usr/bin/defaults ]] || return + [[ -f ~/Library/Preferences/com.googlecode.iterm2.plist ]] || return + [[ -r ~/Library/Preferences/com.googlecode.iterm2.plist ]] || return + [[ -w ~/Library/Preferences/com.googlecode.iterm2.plist ]] || return + local guid1 && guid1="$(iterm_get '"Default Bookmark Guid"' 2>/dev/null)" || return + local guid2 && guid2="$(iterm_get '"New Bookmarks":0:"Guid"' 2>/dev/null)" || return + local font && font="$(iterm_get '"New Bookmarks":0:"Normal Font"' 2>/dev/null)" || return + [[ $guid1 == $guid2 ]] || return + [[ $font != 'MesloLGSNer-Regular '<-> ]] || return + [[ $font == (#b)*' '(<->) ]] || return + iterm2_font_size=$match[1] + terminal=iTerm2 return fi return 1 } function run_command() { - print -nP -- "$1 ..." + local msg=$1 shift + [[ -n $msg ]] && print -nP -- "$msg ..." local err && err="$("$@" 2>&1)" || { print -P " %1FERROR%f" print -P "" - print -P "%BCommand:%b" "${(@q)*}" + print -nP "%BCommand:%b " + print -r -- "${(@q)*}" if [[ -n $err ]]; then print -P "" print -r -- $err fi quit -c } - print -P " %2FOK%f" + [[ -n $msg ]] && print -P " %2FOK%f" } function install_font() { clear - mkdir -p ~/.termux || quit -c - run_command "Downloading %2FMesloLGS NF Regular.ttf%f" \ - curl -fsSL -o ~/.termux/font.ttf "$font_base_url/MesloLGS%20NF%20Regular.ttf" - run_command "Reloading Termux settings" termux-reload-settings + case $terminal in + Termux) + mkdir -p ~/.termux || quit -c + run_command "Downloading %BMesloLGS NF Regular.ttf%b" \ + curl -fsSL -o ~/.termux/font.ttf "$font_base_url/MesloLGS%20NF%20Regular.ttf" + run_command "Reloading %BTermux%b settings" termux-reload-settings + ;; + iTerm2) + mkdir -p ~/Library/Fonts || quit -c + local style + for style in Regular Bold Italic 'Bold Italic'; do + local file="MesloLGS NF ${style}.ttf" + run_command "Downloading %B$file%b" \ + curl -fsSL -o ~/Library/Fonts/$file "$font_base_url/${file// /%20}" + done + print -nP -- "Changing %BiTerm2%b settings ..." + local k v settings=( + '"Normal Font"' '"MesloLGSNer-Regular '$iterm2_font_size'"' + '"Horizontal Spacing"' 1 + '"Vertical Spacing"' 1 + '"Use Bold Font"' 1 + '"Use Bright Bold"' 1 + '"Use Italic Font"' 1 + '"Use Non-ASCII Font"' 0 + '"Ambiguous Double Width"' 0 + '"Terminal Type"' '"xterm-256color"' + ) + for k v in $settings; do + run_command "" /usr/libexec/PlistBuddy -c \ + "Set :\"New Bookmarks\":0:$k $v" ~/Library/Preferences/com.googlecode.iterm2.plist + done + print -P " %2FOK%f" + run_command "Updating %BiTerm2%b settings cache" defaults read com.googlecode.iterm2 + clear + print -P "%2FMeslo Nerd Font%f successfully installed." + print -P "" + print -P "Please %Brestart iTerm2%b for the changes to take effect." + print -P "" + flowing +c -i 5 " 1. Click" "%BiTerm2 → Quit iTerm2%b" or press "%B⌘ Q%b." + flowing +c -i 5 " 2. Open %BiTerm2%b." + print -P "" + exit 0 + ;; + esac } function ask_font() { @@ -276,7 +348,7 @@ function ask_font() { print -P "" local key= - read -k key${(%):-"?%BChoice [ynq]: %b"} || quit + read -k key${(%):-"?%BChoice [ynq]: %b"} || quit -c case $key in q) quit;; y) install_font; break;; @@ -308,7 +380,7 @@ function ask_diamond() { print -P "" local key= - read -k key${(%):-"?%BChoice [yn${extra}q]: %b"} || quit + read -k key${(%):-"?%BChoice [yn${extra}q]: %b"} || quit -c case $key in q) quit;; r) [[ $extra == *r* ]] && { greeting_printed=1; return 1 };; @@ -337,7 +409,7 @@ function ask_lock() { print -P "" local key= - read -k key${(%):-"?%BChoice [ynrq]: %b"} || quit + read -k key${(%):-"?%BChoice [ynrq]: %b"} || quit -c case $key in q) quit;; r) return 1;; @@ -364,7 +436,7 @@ function ask_python() { print -P "" local key= - read -k key${(%):-"?%BChoice [ynrq]: %b"} || quit + read -k key${(%):-"?%BChoice [ynrq]: %b"} || quit -c case $key in q) quit;; r) return 1;; @@ -391,7 +463,7 @@ function ask_debian() { print -P "" local key= - read -k key${(%):-"?%BChoice [ynrq]: %b"} || quit + read -k key${(%):-"?%BChoice [ynrq]: %b"} || quit -c case $key in q) quit;; r) return 1;; @@ -431,7 +503,7 @@ function ask_narrow_icons() { print -P "" local key= - read -k key${(%):-"?%BChoice [ynrq]: %b"} || quit + read -k key${(%):-"?%BChoice [ynrq]: %b"} || quit -c case $key in q) quit;; r) return 1;; @@ -459,7 +531,7 @@ function ask_style() { print -P "" local key= - read -k key${(%):-"?%BChoice [12rq]: %b"} || quit + read -k key${(%):-"?%BChoice [12rq]: %b"} || quit -c case $key in q) quit;; r) return 1;; @@ -501,7 +573,7 @@ function ask_color() { print -P "" local key= - read -k key${(%):-"?%BChoice [1234rq]: %b"} || quit + read -k key${(%):-"?%BChoice [1234rq]: %b"} || quit -c case $key in q) quit;; r) return 1;; @@ -536,7 +608,7 @@ function ask_time() { print -P "" local key= - read -k key${(%):-"?%BChoice [ynrq]: %b"} || quit + read -k key${(%):-"?%BChoice [ynrq]: %b"} || quit -c case $key in q) quit;; r) return 1;; @@ -633,7 +705,7 @@ function ask_extra_icons() { print -P "" local key= - read -k key${(%):-"?%BChoice [12rq]: %b"} || quit + read -k key${(%):-"?%BChoice [12rq]: %b"} || quit -c case $key in q) quit;; r) return 1;; @@ -668,7 +740,7 @@ function ask_prefixes() { print -P "" local key= - read -k key${(%):-"?%BChoice [12rq]: %b"} || quit + read -k key${(%):-"?%BChoice [12rq]: %b"} || quit -c case $key in q) quit;; r) return 1;; @@ -721,7 +793,7 @@ function ask_separators() { print -P "" local key= - read -k key${(%):-"?%BChoice [12${extra}rq]: %b"} || quit + read -k key${(%):-"?%BChoice [12${extra}rq]: %b"} || quit -c case $key in q) quit;; r) return 1;; @@ -808,7 +880,7 @@ function ask_heads() { print -P "" local key= - read -k key${(%):-"?%BChoice [12${extra}rq]: %b"} || quit + read -k key${(%):-"?%BChoice [12${extra}rq]: %b"} || quit -c case $key in q) quit;; r) return 1;; @@ -882,7 +954,7 @@ function ask_tails() { print -P "" local key= - read -k key${(%):-"?%BChoice [12${extra}rq]: %b"} || quit + read -k key${(%):-"?%BChoice [12${extra}rq]: %b"} || quit -c case $key in q) quit;; r) return 1;; @@ -934,7 +1006,7 @@ function ask_num_lines() { print -P "" local key= - read -k key${(%):-"?%BChoice [12rq]: %b"} || quit + read -k key${(%):-"?%BChoice [12rq]: %b"} || quit -c case $key in q) quit;; r) return 1;; @@ -969,7 +1041,7 @@ function ask_gap_char() { print -P "" local key= - read -k key${(%):-"?%BChoice [123rq]: %b"} || quit + read -k key${(%):-"?%BChoice [123rq]: %b"} || quit -c case $key in q) quit;; r) return 1;; @@ -1011,7 +1083,7 @@ function ask_frame() { print -P "" local key= - read -k key${(%):-"?%BChoice [1234rq]: %b"} || quit + read -k key${(%):-"?%BChoice [1234rq]: %b"} || quit -c case $key in q) quit;; r) return 1;; @@ -1044,7 +1116,7 @@ function ask_empty_line() { print -P "" local key= - read -k key${(%):-"?%BChoice [12rq]: %b"} || quit + read -k key${(%):-"?%BChoice [12rq]: %b"} || quit -c case $key in q) quit;; r) return 1;; @@ -1070,7 +1142,7 @@ function ask_confirm() { print -P "" local key= - read -k key${(%):-"?%BChoice [yrq]: %b"} || quit + read -k key${(%):-"?%BChoice [yrq]: %b"} || quit -c case $key in q) quit;; r) return 1;; @@ -1097,7 +1169,7 @@ function ask_config_overwrite() { print -P "" local key= - read -k key${(%):-"?%BChoice [yrq]: %b"} || quit + read -k key${(%):-"?%BChoice [yrq]: %b"} || quit -c case $key in q) quit;; r) return 1;; -- cgit v1.2.3 From 7f90c103d1b13fae1fac2e75562d9eaca9d0a0f8 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 3 Sep 2019 20:07:55 +0200 Subject: wizard: offer to override font on Termux if it is not MesloLGS NF --- internal/wizard.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 67ef170a..e72cd92e 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -231,7 +231,11 @@ function can_install_font() { if [[ "$(uname)" == Linux && "$(uname -o)" == Android ]]; then (( $+commands[termux-reload-settings] )) || return (( $+commands[curl] )) || return - [[ ! -f ~/.termux/font.ttf ]] || return + if [[ -f ~/.termux/font.ttf ]]; then + [[ -r ~/.termux/font.ttf ]] || return + [[ -w ~/.termux/font.ttf ]] || return + ! grep -q 'MesloLGS NF' ~/.termux/font.ttf 2>/dev/null || return + fi if [[ -f ~/.termux ]]; then [[ -d ~/.termux && -w ~/.termux ]] || return else -- cgit v1.2.3 From 7c513a1e7964ec46354d24b735ea4ab42c5ff5d9 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 3 Sep 2019 23:07:46 +0200 Subject: minor fixes --- internal/wizard.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index e72cd92e..f32cfd2a 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -322,9 +322,9 @@ function install_font() { "Set :\"New Bookmarks\":0:$k $v" ~/Library/Preferences/com.googlecode.iterm2.plist done print -P " %2FOK%f" - run_command "Updating %BiTerm2%b settings cache" defaults read com.googlecode.iterm2 + run_command "Updating %BiTerm2%b settings cache" /usr/bin/defaults read com.googlecode.iterm2 clear - print -P "%2FMeslo Nerd Font%f successfully installed." + print -P "%2FMeslo Nerd Font%f successfully installed." print -P "" print -P "Please %Brestart iTerm2%b for the changes to take effect." print -P "" -- cgit v1.2.3 From 298fa2f325c50b250a9bc9fe664ee96107886813 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 4 Sep 2019 08:13:16 +0200 Subject: bug fix: don't attempt to source .p10k.zsh when wizard exits to restart iTerm2 --- internal/configure.zsh | 9 +++++++-- internal/wizard.zsh | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/configure.zsh b/internal/configure.zsh index fd9e8593..f8483d75 100644 --- a/internal/configure.zsh +++ b/internal/configure.zsh @@ -66,6 +66,11 @@ function p9k_configure() { typeset -x -- $p fi $__p9k_root_dir/internal/wizard.zsh -d $__p9k_root_dir -f - ) || return - source $__p9k_cfg_path + ) + local ret=$? + case $ret in + 0) source $__p9k_cfg_path;; + 69) return 0;; + *) return $ret;; + esac } diff --git a/internal/wizard.zsh b/internal/wizard.zsh index f32cfd2a..b3138632 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -331,7 +331,7 @@ function install_font() { flowing +c -i 5 " 1. Click" "%BiTerm2 → Quit iTerm2%b" or press "%B⌘ Q%b." flowing +c -i 5 " 2. Open %BiTerm2%b." print -P "" - exit 0 + exit 69 ;; esac } -- cgit v1.2.3 From 200b02b242f291ee988e19dad7196f2150c0a5d5 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 4 Sep 2019 08:16:02 +0200 Subject: better iTerm version filter --- internal/wizard.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index b3138632..a386d5b5 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -245,7 +245,7 @@ function can_install_font() { return fi if [[ "$(uname)" == Darwin && $TERM_PROGRAM == iTerm.app ]]; then - [[ $TERM_PROGRAM_VERSION == (2|3)* ]] || return + [[ $TERM_PROGRAM_VERSION == [2-9]* ]] || return if [[ -f ~/Library/Fonts ]]; then [[ -d ~/Library/Fonts && -w ~/Library/Fonts ]] || return else -- cgit v1.2.3 From 4d63712093f33eb3224f560f6bc9dcb9c9909eb5 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 4 Sep 2019 08:22:41 +0200 Subject: don't offer to install font if there is no curl --- internal/wizard.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index a386d5b5..56733098 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -245,6 +245,7 @@ function can_install_font() { return fi if [[ "$(uname)" == Darwin && $TERM_PROGRAM == iTerm.app ]]; then + (( $+commands[curl] )) || return [[ $TERM_PROGRAM_VERSION == [2-9]* ]] || return if [[ -f ~/Library/Fonts ]]; then [[ -d ~/Library/Fonts && -w ~/Library/Fonts ]] || return -- cgit v1.2.3 From b394a601a0cb5fcf364dc86445225764f4ba149a Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 4 Sep 2019 08:40:24 +0200 Subject: if auto_name_dirs is set, show directory without named directory support --- internal/p10k.zsh | 52 +++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index aaea53ec..e28bf616 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1169,30 +1169,37 @@ function _p9k_shorten_delim_len() { ################################################################ # Dir: current working directory prompt_dir() { - (( _POWERLEVEL9K_DIR_PATH_ABSOLUTE )) && local p=$_p9k_pwd || local p=${(%):-%~} - - if [[ $p == '~['* ]]; then - # If "${(%):-%~}" expands to "~[a]/]/b", is the first component "~[a]" or "~[a]/]"? - # One would expect "${(%):-%-1~}" to give the right answer but alas it always simply - # gives the segment before the first slash, which would be "~[a]" in this case. Worse, - # for "~[a/b]" it'll give the nonsensical "~[a". To solve this problem we have to - # repeat what "${(%):-%~}" does and hope that it produces the same result. - local func='' - local -a parts=() - for func in zsh_directory_name $zsh_directory_name_functions; do - if (( $+functions[$func] )) && $func d $_p9k_pwd && [[ $p == '~['$reply[1]']'* ]]; then - parts+='~['$reply[1]']' - break + if (( _POWERLEVEL9K_DIR_PATH_ABSOLUTE )); then + local p=$_p9k_pwd + local -a parts=("${(s:/:)p}") + elif [[ -o auto_name_dirs ]]; then + local p=${_p9k_pwd/#(#b)$HOME(|\/*)/'~'$match[1]} + local -a parts=("${(s:/:)p}") + else + local p=${(%):-%~} + if [[ $p == '~['* ]]; then + # If "${(%):-%~}" expands to "~[a]/]/b", is the first component "~[a]" or "~[a]/]"? + # One would expect "${(%):-%-1~}" to give the right answer but alas it always simply + # gives the segment before the first slash, which would be "~[a]" in this case. Worse, + # for "~[a/b]" it'll give the nonsensical "~[a". To solve this problem we have to + # repeat what "${(%):-%~}" does and hope that it produces the same result. + local func='' + local -a parts=() + for func in zsh_directory_name $zsh_directory_name_functions; do + if (( $+functions[$func] )) && $func d $_p9k_pwd && [[ $p == '~['$reply[1]']'* ]]; then + parts+='~['$reply[1]']' + break + fi + done + if (( $#parts )); then + parts+=(${(s:/:)${p#$parts[1]}}) + else + p=$_p9k_pwd + parts=("${(s:/:)p}") fi - done - if (( $#parts )); then - parts+=(${(s:/:)${p#$parts[1]}}) else - p=$_p9k_pwd - parts=("${(s:/:)p}") + local -a parts=("${(s:/:)p}") fi - else - local -a parts=("${(s:/:)p}") fi local -i fake_first=0 expand=0 @@ -1363,7 +1370,7 @@ prompt_dir() { [[ $_POWERLEVEL9K_DIR_SHOW_WRITABLE == 1 && ! -w $_p9k_pwd ]] local w=$? - if ! _p9k_cache_get $0 $_p9k_pwd $w $fake_first "${parts[@]}"; then + if ! _p9k_cache_get $0 $_p9k_pwd $p $w $fake_first "${parts[@]}"; then local state=$0 local icon='' if (( ! w )); then @@ -4100,7 +4107,6 @@ _p9k_must_init() { IFS=$'\1' param_sig="${(@)param_keys:/(#b)(*)/$match[1]=\$$match[1]}" IFS=$'\2' eval "param_sig=x\"$param_sig\"" [[ -o transient_rprompt ]] && param_sig+=t - [[ -o auto_name_dirs ]] && param_sig+=d [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit _p9k_param_sig=$param_sig -- cgit v1.2.3 From 072f7be8ff2e3210484956877f066ccd7b157c8c Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 5 Sep 2019 22:38:36 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index 6cd39479..8b7e85f2 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -319,7 +319,7 @@ function gitstatus_start() { local arch && arch=$(uname -m) && [[ -n $arch ]] local daemon=${GITSTATUS_DAEMON:-$dir/bin/gitstatusd-${os:l}-${arch:l}} - [[ -f $daemon ]] + [[ -x $daemon ]] lock_file=$(mktemp "${TMPDIR:-/tmp}"/gitstatus.$$.lock.XXXXXXXXXX) zsystem flock -f lock_fd $lock_file @@ -367,7 +367,7 @@ function gitstatus_start() { fi echo -nE $'bye\x1f0\x1e'" local setsid=${commands[setsid]:-/usr/local/opt/util-linux/bin/setsid} - [[ -f $setsid ]] && setsid=${(q)setsid} || setsid= + [[ -x $setsid ]] && setsid=${(q)setsid} || setsid= cmd="cd /; $setsid zsh -dfxc ${(q)cmd} &!" # We use `zsh -c` instead of plain {} or () to work around bugs in zplug. It hangs on startup. # Double fork is to daemonize. Some macOS users had issues when gitstatusd was a child process -- cgit v1.2.3 From ef6f90f598dcce54b9a96f2aae317a20cab541e9 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 6 Sep 2019 11:30:11 +0200 Subject: wizard: fix handling for $ZDOTDIR and $HOME with special symbols ("%", "$", etc.) --- internal/configure.zsh | 6 +++--- internal/wizard.zsh | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/configure.zsh b/internal/configure.zsh index f8483d75..ae24be34 100644 --- a/internal/configure.zsh +++ b/internal/configure.zsh @@ -1,13 +1,13 @@ typeset -gr __p9k_wizard_columns=55 typeset -gr __p9k_wizard_lines=21 -typeset -gr __p9k_zd=${${ZDOTDIR:-$HOME}:A} -typeset -gr __p9k_zd_u=${${${(q-)__p9k_zd}/#(#b)$HOME(|\/*)/'~'$match[1]}//\%/%%} +typeset -gr __p9k_zd=${ZDOTDIR:-$HOME} +typeset -gr __p9k_zd_u=${${${(q)__p9k_zd}/#(#b)${(q)HOME}(|\/*)/'~'$match[1]}//\%/%%} typeset -gr __p9k_cfg_basename=.p10k.zsh typeset -gr __p9k_cfg_path=$__p9k_zd/$__p9k_cfg_basename typeset -gr __p9k_cfg_path_u=$__p9k_zd_u/$__p9k_cfg_basename typeset -gr __p9k_zshrc=$__p9k_zd/.zshrc typeset -gr __p9k_zshrc_u=$__p9k_zd_u/.zshrc -typeset -gr __p9k_root_dir_u=${${${(q-)__p9k_root_dir}/#(#b)$HOME(|\/*)/'~'$match[1]}//\%/%%} +typeset -gr __p9k_root_dir_u=${${${(q)__p9k_root_dir}/#(#b)${(q)HOME}(|\/*)/'~'$match[1]}//\%/%%} function _p9k_can_configure() { emulate -L zsh diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 56733098..893fa243 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -1346,14 +1346,14 @@ function generate_config() { function write_zshrc() { if [[ -e $__p9k_zshrc ]]; then local lines=(${(f)"$(<$__p9k_zshrc)"}) - local f1=$__p9k_cfg_path - local f2=$__p9k_cfg_path_u - local f3=${__p9k_cfg_path_u/#\~\//\$HOME\/} - local f4=${__p9k_cfg_path_u/#\~\//\"\$HOME\"\/} - local f5="'$f1'" - local f6="\"$f1\"" - local f7="\"$f3\"" - if [[ -n ${(@M)lines:#(#b)[^#]#([^[:IDENT:]]|)source[[:space:]]##($f1|$f2|$f3|$f4|$f5|$f6|$f7)*} ]]; then + local f0=$__p9k_cfg_path + local f1=${(q)f0} + local f2=${(q-)f0} + local f3=${(q+)f0} + local f4=${(qq)f0} + local f5=${(qqq)f0} + local g1=${${(q)__p9k_cfg_path}/#(#b)${(q)HOME}\//'~/'} + if [[ -n ${(@M)lines:#(#b)[^#]#([^[:IDENT:]]|)source[[:space:]]##($f1|$f2|$f3|$f4|$f5|$g1)(|[[:space:]]*|'#'*)} ]]; then flowing +c No changes have been made to %4F$__p9k_zshrc_u%f because it already sources %2F$__p9k_cfg_path_u%f. return fi -- cgit v1.2.3 From 5886154bb14965f59d26f349b97e2c5e9104bf93 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 6 Sep 2019 11:46:30 +0200 Subject: drop q+ as it it's not supported by old shells --- internal/wizard.zsh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 893fa243..9e5d4b8f 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -1349,11 +1349,10 @@ function write_zshrc() { local f0=$__p9k_cfg_path local f1=${(q)f0} local f2=${(q-)f0} - local f3=${(q+)f0} - local f4=${(qq)f0} - local f5=${(qqq)f0} + local f3=${(qq)f0} + local f4=${(qqq)f0} local g1=${${(q)__p9k_cfg_path}/#(#b)${(q)HOME}\//'~/'} - if [[ -n ${(@M)lines:#(#b)[^#]#([^[:IDENT:]]|)source[[:space:]]##($f1|$f2|$f3|$f4|$f5|$g1)(|[[:space:]]*|'#'*)} ]]; then + if [[ -n ${(@M)lines:#(#b)[^#]#([^[:IDENT:]]|)source[[:space:]]##($f1|$f2|$f3|$f4|$g1)(|[[:space:]]*|'#'*)} ]]; then flowing +c No changes have been made to %4F$__p9k_zshrc_u%f because it already sources %2F$__p9k_cfg_path_u%f. return fi -- cgit v1.2.3 From 8e653efd018f4b9605a59925fbc10e0495eddc17 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 6 Sep 2019 12:10:27 +0200 Subject: remove obsolete faq entry about auto_name_dirs (there is a workaround in the code now) --- README.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/README.md b/README.md index 3b926b55..7d3818fc 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,6 @@ prompt. 1. [Why is my right prompt wrapping around in a weird way?](#why-is-my-right-prompt-wrapping-around-in-a-weird-way) 1. [I cannot install the recommended font. Help!](#i-cannot-install-the-recommended-font-help) 1. [Why do I have a question mark symbol in my prompt? Is my font broken?](#why-do-i-have-a-question-mark-symbol-in-my-prompt-is-my-font-broken) - 1. [Why is my current directory displayed as `~_p9k_pwd`?](#why-is-my-current-directory-displayed-as-_p9k_pwd) 1. [Why does Powerlevel10k spawn extra processes?](#why-does-powerlevel10k-spawn-extra-processes) 1. [Are there configuration options that make Powerlevel10k slow?](#are-there-configuration-options-that-make-powerlevel10k-slow) 1. [Is Powerlevel10k fast to load?](#is-powerlevel10k-fast-to-load) @@ -239,15 +238,6 @@ some glyphs. To fix this problem, [install the recommended font](#recommended-meslo-nerd-font-patched-for-powerlevel10k) and run `p10k configure`. -### Why is my current directory displayed as `~_p9k_pwd`? - -This is the intended effect of `auto_name_dirs` option. You can disable this option with the -following command: - -```zsh -echo 'unsetopt auto_name_dirs' >>! ~/.zshrc -``` - ### Why does Powerlevel10k spawn extra processes? Powerlevel10k uses [gitstatus](https://github.com/romkatv/gitstatus) as the backend behind `vcs` -- cgit v1.2.3 From e8a38dc404d58bd281993fa19cb3358a9c91e7fa Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 6 Sep 2019 12:24:36 +0200 Subject: font comments --- config/p10k-classic.zsh | 9 +++++---- config/p10k-lean.zsh | 7 +++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 2115be21..921c5166 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -111,11 +111,12 @@ fi # Awesome-Terminal Fonts (regular) | awesome-fontconfig # Awesome-Terminal Fonts (patched) | awesome-patched # Nerd Fonts | nerdfont-complete + # Other | compatible # - # If this looks overwhelming, install a font from https://github.com/ryanoasis/nerd-fonts - # and set POWERLEVEL9K_MODE=nerdfont-complete. "Meslo LG S Regular Nerd Font Complete Mono" from - # https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/Meslo/S/Regular/complete is - # very good. + # If this looks overwhelming, either stick with a preinstalled system font and set + # POWERLEVEL9K_MODE=compatible, or install the recommended Powerlevel10k font from + # https://github.com/romkatv/powerlevel10k/#recommended-meslo-nerd-font-patched-for-powerlevel10k + # and set POWERLEVEL9K_MODE=nerdfont-complete. typeset -g POWERLEVEL9K_MODE=nerdfont-complete # When set to true, icons appear before content on both sides of the prompt. When set diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index b90baa81..6f21e5e8 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -122,10 +122,9 @@ fi # Other | compatible # # If this looks overwhelming, either stick with a preinstalled system font and set - # POWERLEVEL9K_MODE=compatible, or install a font from https://github.com/ryanoasis/nerd-fonts - # and set POWERLEVEL9K_MODE=nerdfont-complete. "Meslo LG S Regular Nerd Font Complete Mono" from - # https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/Meslo/S/Regular/complete is - # very good. + # POWERLEVEL9K_MODE=compatible, or install the recommended Powerlevel10k font from + # https://github.com/romkatv/powerlevel10k/#recommended-meslo-nerd-font-patched-for-powerlevel10k + # and set POWERLEVEL9K_MODE=nerdfont-complete. typeset -g POWERLEVEL9K_MODE=nerdfont-complete # When set to true, icons appear before content on both sides of the prompt. When set -- cgit v1.2.3 From 1ec035ead3d72c0767c1c532abfe93ef75087d4b Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 6 Sep 2019 12:24:42 +0200 Subject: font docs --- README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 7d3818fc..d918e69b 100644 --- a/README.md +++ b/README.md @@ -122,19 +122,17 @@ Double-click on each file and press "Install". This will make `MesloLGS NF` font applications on your system. Configure your terminal to use this font: - **iTerm2**: Open *iTerm2 → Preferences → Profiles → Text* and set *Font* to `MesloLGS NF`. -- **Hyper**: Open *Hyper → Edit → Preferences* and change the value for `fontFamily` to - `MesloLGS NF` under `module.exports.config`. +- **Hyper**: Open *Hyper → Edit → Preferences* and change the value of `fontFamily` under + `module.exports.config` to `MesloLGS NF`. - **Visual Studio Code**: Open *File → Preferences → Settings*, enter - `terminal.integrated.fontFamily` in the search box and set value to `MesloLGS NF`. + `terminal.integrated.fontFamily` in the search box and set the value to `MesloLGS NF`. +- **GNOME Terminal** (the default Ubuntu terminal): Run: + `sudo apt install libglib2.0-bin && gsettings set org.gnome.desktop.interface monospace-font-name 'MesloLGS NF 11'`. - **Windows Console Host** (the old thing): Click the icon in the top left corner, then *Properties → Font* and set *Font* to `MesloLGS NF`. - **Windows Terminal** (the new thing): Open *Settings* (`Ctrl+,`), search for `fontFace` and set value to `MesloLGS NF` for every profile. -- **Linux/GNOME** (all terminals): Type this command: -```zsh -sudo apt install libglib2.0-bin -gsettings set org.gnome.desktop.interface monospace-font-name 'MesloLGS NF 11' -``` +- **Termux**: Type `p10k configure` and answer `Yes` when asked whether to install *Meslo Nerd Font*. Run `p10k configure` to pick the best style for your new font. -- cgit v1.2.3 From 4405297b13e15b0775181e37492403cfa64d281f Mon Sep 17 00:00:00 2001 From: Cameron Boulton Date: Fri, 6 Sep 2019 14:55:49 -0700 Subject: Default Kubernetes content expansion to include namespace. --- config/p10k-classic.zsh | 2 +- config/p10k-lean.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 921c5166..4b6ce418 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -662,7 +662,7 @@ fi # The expansion below will show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back # to P9K_KUBECONTEXT_NAME. Parameter expansions are very flexible and fast, too. See reference: # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. - typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}' + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}/${P9K_KUBECONTEXT_NAMESPACE}' # Custom prefix. # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%248Fat ' diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 6f21e5e8..fa7ed9df 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -637,7 +637,7 @@ fi # The expansion below will show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back # to P9K_KUBECONTEXT_NAME. Parameter expansions are very flexible and fast, too. See reference: # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. - typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}' + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}/${P9K_KUBECONTEXT_NAMESPACE}' # Custom prefix. # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%fat ' -- cgit v1.2.3 From 91b715f18f7f9e9b9bcd921a3387f04e5a3dc7d3 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 7 Sep 2019 09:28:45 +0200 Subject: disable or substitute "compatible" icons that cannot be displayed by the stock Menlo on macOS --- config/p10k-classic.zsh | 3 ++- config/p10k-lean.zsh | 2 +- internal/icons.zsh | 2 +- internal/wizard.zsh | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 921c5166..6bcb8645 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -263,7 +263,8 @@ fi # Enable special styling for non-writable directories. typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=true - # Show this icon when the current directory is not writable. Empty for no icon. + # Show this icon when the current directory is not writable. POWERLEVEL9K_DIR_SHOW_WRITABLE + # above must be set to true for this parameter to have effect. # typeset -g POWERLEVEL9K_DIR_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' # Custom prefix. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 6f21e5e8..09263d0d 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -245,7 +245,7 @@ fi typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=true # Show this icon when the current directory is not writable. POWERLEVEL9K_DIR_SHOW_WRITABLE # above must be set to true for this parameter to have effect. - # POWERLEVEL9K_DIR_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_DIR_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' # Custom prefix. # typeset -g POWERLEVEL9K_DIR_PREFIX='%fin ' diff --git a/internal/icons.zsh b/internal/icons.zsh index c74fe909..cacbb535 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -432,7 +432,7 @@ function _p9k_init_icons() { RIGHT_SUBSEGMENT_SEPARATOR '\uE0B3' #  CARRIAGE_RETURN_ICON '\u21B5' # ↵ ROOT_ICON '\u26A1' # ⚡ - SUDO_ICON '\uE0A2' #  + SUDO_ICON '' RUBY_ICON 'Ruby' AWS_ICON 'AWS' AWS_EB_ICON '\U1F331' # 🌱 diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 9e5d4b8f..d8e251ce 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -1217,8 +1217,10 @@ function generate_config() { fi if [[ $POWERLEVEL9K_MODE == compatible ]]; then - # Many fonts don't have the gear icon. + # Many fonts don't have the gear or the lock icon. sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'⇶'" + uncomment 'typeset -g POWERLEVEL9K_DIR_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION' + sub DIR_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION "'∅'" fi if [[ $POWERLEVEL9K_MODE == (awesome-patched|awesome-fontconfig) && $cap_python == 0 ]]; then -- cgit v1.2.3 From 9a8a6ca836fa5cca5cd1f8d181a0281edc2712a5 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 7 Sep 2019 10:05:56 +0200 Subject: allow prompt segments to be disabled through configuration options Prompt segment `foo` doesn't get evaluated or shown on the left if `${POWERLEVEL9K_FOO_LEFT_DISABLED-$POWERLEVEL9K_FOO_DISABLED}` is equal to `true`. Example: POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(dir) - By default `dir` is shown on the left and on the right. - `POWERLEVEL9K_DIR_LEFT_DISABLED=true` disables `dir` on the left. - `POWERLEVEL9K_DIR_RIGHT_DISABLED=true` disables `dir` on the right. - `POWERLEVEL9K_DIR_DISABLED=true` disables `dir` everywhere. Note that it's possible to hide segments without disabling their evaluation through expansions. For example: POWERLEVEL9K_DIR_CONTENT_EXPANSION='${HIDE_DIR-$P9K_CONTENT}' POWERLEVEL9K_DIR_VISUAL_IDENTIFIER_EXPANSION='${HIDE_DIR-$P9K_VISUAL_IDENTIFIER}' With these settings, `HIDE_DIR=''` hides `dir` while `unset HIDE_DIR` restores it. fixes #205 --- internal/p10k.zsh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index e28bf616..e409c36c 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3785,6 +3785,30 @@ _p9k_init_params() { # # These correspond to `java -fullversion` and `java -version` respectively. _p9k_declare -b POWERLEVEL9K_JAVA_VERSION_FULL 1 + + local -i i=1 + while (( i <= $#_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS )); do + local segment=${(U)_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[i]} + local var=POWERLEVEL9K_${segment}_LEFT_DISABLED + (( $+parameters[$var] )) || var=POWERLEVEL9K_${segment}_DISABLED + if [[ ${(P)var} == true ]]; then + _POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[i,i]=() + else + (( ++i )) + fi + done + + local -i i=1 + while (( i <= $#_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS )); do + local segment=${(U)_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[i]} + local var=POWERLEVEL9K_${segment}_RIGHT_DISABLED + (( $+parameters[$var] )) || var=POWERLEVEL9K_${segment}_DISABLED + if [[ ${(P)var} == true ]]; then + _POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[i,i]=() + else + (( ++i )) + fi + done } typeset -ga __p9k_wrapped_zle_widgets -- cgit v1.2.3 From 2dbd37598101bf1e398a71b4668f6ce0cc2ffaa6 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 7 Sep 2019 10:30:37 +0200 Subject: comments --- config/p10k-classic.zsh | 12 ++++++++++-- config/p10k-lean.zsh | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 6bcb8645..16c8a1ee 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -608,7 +608,14 @@ fi # POWERLEVEL9K_KUBECONTEXT_CLASSES defines the context class. Patterns are tried in order. The # first match wins. # - # For example, if your current kubernetes context is "deathray-testing/default", its class is TEST + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' DEFAULT) + # + # If your current kubernetes context is "deathray-testing/default", its class is TEST # because "deathray-testing/default" doesn't match the pattern '*prod*' but does match '*test*'. # # You can define different colors, icons and content expansions for different classes: @@ -638,7 +645,8 @@ fi # in the output of `kubectl config get-contexts`. If there is no # namespace, the parameter is set to "default". # - # If the context points to GKE or EKS, the following extra parameters are available: + # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS), + # the following extra parameters are available: # # - P9K_KUBECONTEXT_CLOUD_NAME Either "gke" or "eks". # - P9K_KUBECONTEXT_CLOUD_ACCOUNT Account/project ID. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 09263d0d..acf33730 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -582,7 +582,14 @@ fi # POWERLEVEL9K_KUBECONTEXT_CLASSES defines the context class. Patterns are tried in order. The # first match wins. # - # For example, if your current kubernetes context is "deathray-testing/default", its class is TEST + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' DEFAULT) + # + # If your current kubernetes context is "deathray-testing/default", its class is TEST # because "deathray-testing/default" doesn't match the pattern '*prod*' but does match '*test*'. # # You can define different colors, icons and content expansions for different classes: @@ -612,7 +619,8 @@ fi # in the output of `kubectl config get-contexts`. If there is no # namespace, the parameter is set to "default". # - # If the context points to GKE or EKS, the following extra parameters are available: + # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS), + # the following extra parameters are available: # # - P9K_KUBECONTEXT_CLOUD_NAME Either "gke" or "eks". # - P9K_KUBECONTEXT_CLOUD_ACCOUNT Account/project ID. -- cgit v1.2.3 From eabdc9dc2e753599c34f4aadeefff4c68d7f5175 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 7 Sep 2019 12:51:53 +0200 Subject: fix battery color --- config/p10k-classic.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 16c8a1ee..606c2fe0 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -693,7 +693,7 @@ fi typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=160 # Show battery in green when it's charging. - typeset -g POWERLEVEL9K_BATTERY_CHARGING_FOREGROUND=2 + typeset -g POWERLEVEL9K_BATTERY_CHARGING_FOREGROUND=70 # Show battery in yellow when not connected to power supply. typeset -g POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND=178 # Battery pictograms going from low to high level of charge. -- cgit v1.2.3 From 9ce277d17999448af21afcf3f4695892692351c6 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sun, 8 Sep 2019 20:00:18 +0200 Subject: strip hexadecimal colors from vcs when loading; see #207 --- config/p10k-classic.zsh | 4 ++-- config/p10k-lean.zsh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 606c2fe0..7c68d679 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -15,7 +15,7 @@ fi () { emulate -L zsh - setopt no_unset + setopt no_unset extended_glob zmodload zsh/langinfo if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} @@ -362,7 +362,7 @@ fi # Install our own Git status formatter. typeset -g POWERLEVEL9K_VCS_{CLEAN,UNTRACKED,MODIFIED}_CONTENT_EXPANSION=$vcs # When Git status is being refreshed asynchronously, display the last known repo status in grey. - typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION=${${vcs//\%f}//\%<->F} + typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION=${${${vcs//\%f}//\%<->F}//\%F\{(\#|)[[:xdigit:]]#(\\|)\}} # Enable counters for staged, unstaged, etc. typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index acf33730..1fb94c63 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -15,7 +15,7 @@ fi () { emulate -L zsh - setopt no_unset + setopt no_unset extended_glob zmodload zsh/langinfo if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} @@ -342,7 +342,7 @@ fi # Install our own Git status formatter. typeset -g POWERLEVEL9K_VCS_{CLEAN,UNTRACKED,MODIFIED}_CONTENT_EXPANSION=$vcs # When Git status is being refreshed asynchronously, display the last known repo status in grey. - typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION=${${vcs//\%f}//\%<->F} + typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION=${${${vcs//\%f}//\%<->F}//\%F\{(\#|)[[:xdigit:]]#(\\|)\}} # Enable counters for staged, unstaged, etc. typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 -- cgit v1.2.3 From daedc56b3df578808d33a5f349b0d9b7756d68e3 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 9 Sep 2019 14:19:51 +0200 Subject: typo in comments --- config/p10k-lean.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 1fb94c63..db57a11a 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -1,4 +1,4 @@ -# Config for Powerlevel10k with classic powerline prompt style. Type `p10k configure` to generate +# Config for Powerlevel10k with lean prompt style. Type `p10k configure` to generate # your own config based on it. # # Tip: Looking for a nice color? Here's a one-liner to print colormap. -- cgit v1.2.3 From fd96e92df678da67fc35038c612fbdf95a0e9010 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 9 Sep 2019 14:48:32 +0200 Subject: show battery as CHARGED on macos if it is at 100% and connected to power supply --- internal/p10k.zsh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index e409c36c..96bee0bf 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -922,7 +922,12 @@ prompt_battery() { case "${${(s:; :)raw_data}[2]}" in 'charging'|'finishing charge'|'AC attached') - state=CHARGING + if (( bat_percent == 100 )); then + state=CHARGED + remain='' + else + state=CHARGING + fi ;; 'discharging') (( bat_percent < _POWERLEVEL9K_BATTERY_LOW_THRESHOLD )) && state=LOW || state=DISCONNECTED -- cgit v1.2.3 From 1ad0e713a45f1f710202395b17a19e485b67d6d9 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 9 Sep 2019 15:15:31 +0200 Subject: use fancier battery icons with nerd fonts --- config/p10k-classic.zsh | 12 ++++-------- config/p10k-lean.zsh | 12 ++++-------- internal/wizard.zsh | 10 +++++++--- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 7c68d679..624db57d 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -692,16 +692,12 @@ fi # Show battery in red when it's below this level and not connected to power supply. typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=160 - # Show battery in green when it's charging. - typeset -g POWERLEVEL9K_BATTERY_CHARGING_FOREGROUND=70 - # Show battery in yellow when not connected to power supply. + # Show battery in green when it's charging or fully charged. + typeset -g POWERLEVEL9K_BATTERY_{CHARGING,CHARGED}_FOREGROUND=70 + # Show battery in yellow when it's discharging. typeset -g POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND=178 # Battery pictograms going from low to high level of charge. - typeset -g POWERLEVEL9K_BATTERY_STAGES='▁▂▃▄▅▆▇' - # Display battery pictogram without background. - typeset -g POWERLEVEL9K_BATTERY_VISUAL_IDENTIFIER_EXPANSION='%k${P9K_VISUAL_IDENTIFIER}' - # Don't show battery when it's fully charged and connected to power supply. - typeset -g POWERLEVEL9K_BATTERY_CHARGED_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= + typeset -g POWERLEVEL9K_BATTERY_STAGES=('%K{232}▁' '%K{232}▂' '%K{232}▃' '%K{232}▄' '%K{232}▅' '%K{232}▆' '%K{232}▇' '%K{232}█') # Don't show the remaining time to charge/discharge. typeset -g POWERLEVEL9K_BATTERY_VERBOSE=false diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index db57a11a..0d30ef42 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -672,16 +672,12 @@ fi # Show battery in red when it's below this level and not connected to power supply. typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=160 - # Show battery in green when it's charging. - typeset -g POWERLEVEL9K_BATTERY_CHARGING_FOREGROUND=70 - # Show battery in yellow when not connected to power supply. + # Show battery in green when it's charging or fully charged. + typeset -g POWERLEVEL9K_BATTERY_{CHARGING,CHARGED}_FOREGROUND=70 + # Show battery in yellow when it's discharging. typeset -g POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND=178 # Battery pictograms going from low to high level of charge. - typeset -g POWERLEVEL9K_BATTERY_STAGES='▁▂▃▄▅▆▇' - # Display battery pictogram on black background. - typeset -g POWERLEVEL9K_BATTERY_VISUAL_IDENTIFIER_EXPANSION='%K{232}${P9K_VISUAL_IDENTIFIER}%k' - # Don't show battery when it's fully charged and connected to power supply. - typeset -g POWERLEVEL9K_BATTERY_CHARGED_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= + typeset -g POWERLEVEL9K_BATTERY_STAGES=('%K{232}▁' '%K{232}▂' '%K{232}▃' '%K{232}▄' '%K{232}▅' '%K{232}▆' '%K{232}▇' '%K{232}█') # Don't show the remaining time to charge/discharge. typeset -g POWERLEVEL9K_BATTERY_VERBOSE=false diff --git a/internal/wizard.zsh b/internal/wizard.zsh index d8e251ce..7210a318 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -1227,9 +1227,13 @@ function generate_config() { uncomment 'typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION' uncomment 'typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION' uncomment 'typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION' - sub VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION '🐍' - sub ANACONDA_VISUAL_IDENTIFIER_EXPANSION '🐍' - sub PYENV_VISUAL_IDENTIFIER_EXPANSION '🐍' + sub VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION "'🐍'" + sub ANACONDA_VISUAL_IDENTIFIER_EXPANSION "'🐍'" + sub PYENV_VISUAL_IDENTIFIER_EXPANSION "'🐍'" + fi + + if [[ $POWERLEVEL9K_MODE == nerdfont-complete ]]; then + sub BATTERY_STAGES "\$'\uf58d\uf579\uf57a\uf57b\uf57c\uf57d\uf57e\uf57f\uf580\uf581\uf578'" fi if [[ $style == classic ]]; then -- cgit v1.2.3 From ca49498cb6f138249058d096e65f612990637e04 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 9 Sep 2019 15:29:31 +0200 Subject: don't display kubecontext namespace if it's literally 'default' --- config/p10k-classic.zsh | 13 +++++++------ config/p10k-lean.zsh | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index c51d9575..c1acfe82 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -631,7 +631,8 @@ fi # typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' # Use POWERLEVEL9K_KUBECONTEXT_CONTENT_EXPANSION to specify the content displayed by kubecontext - # segment. + # segment. Parameter expansions are very flexible and fast, too. See reference: + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. # # Within the expansion the following parameters are always available: # @@ -667,11 +668,11 @@ fi # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=123456789012 # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east-1 # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 - # - # The expansion below will show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back - # to P9K_KUBECONTEXT_NAME. Parameter expansions are very flexible and fast, too. See reference: - # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. - typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}/${P9K_KUBECONTEXT_NAMESPACE}' + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION= + # Show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back to P9K_KUBECONTEXT_NAME. + POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}' + # Append the current context's namespace if it's not "default". + POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${${:-/$P9K_KUBECONTEXT_NAMESPACE}:#/default}' # Custom prefix. # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%248Fat ' diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 405e968d..ec03c9c7 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -605,7 +605,8 @@ fi # typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' # Use POWERLEVEL9K_KUBECONTEXT_CONTENT_EXPANSION to specify the content displayed by kubecontext - # segment. + # segment. Parameter expansions are very flexible and fast, too. See reference: + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. # # Within the expansion the following parameters are always available: # @@ -641,11 +642,11 @@ fi # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=123456789012 # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east-1 # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 - # - # The expansion below will show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back - # to P9K_KUBECONTEXT_NAME. Parameter expansions are very flexible and fast, too. See reference: - # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. - typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}/${P9K_KUBECONTEXT_NAMESPACE}' + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION= + # Show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back to P9K_KUBECONTEXT_NAME. + POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}' + # Append the current context's namespace if it's not "default". + POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${${:-/$P9K_KUBECONTEXT_NAMESPACE}:#/default}' # Custom prefix. # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%fat ' -- cgit v1.2.3 From 4de7eaa95ed3a116506f1bd122b2c14562c83d2a Mon Sep 17 00:00:00 2001 From: Roman Perepelitsa Date: Tue, 10 Sep 2019 11:29:08 +0200 Subject: comments --- config/p10k-pure.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/config/p10k-pure.zsh b/config/p10k-pure.zsh index aa6e5b7f..a49653a0 100644 --- a/config/p10k-pure.zsh +++ b/config/p10k-pure.zsh @@ -9,6 +9,7 @@ # The replication of Pure prompt achieved with this config is almost exact. Apart from the # differences listed above, prompt is identical to Pure. This includes even the bad parts. # For example, just like in Pure, prompt will provide no indication of Git status being stale. +# When prompt doesn't fit on one line, it'll wrap around with no attempt to shorten anything. # This is likely to make user experience worse than with any other Powerlevel10k config. If # you like the general style of Pure but not particularly attached to all its quirks, type # `p10k configure` while having Powerlevel10k theme active and pick lean style. -- cgit v1.2.3 From e32ea9cdbdfb96b62fcf176ba07657a6e371b742 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 10 Sep 2019 12:32:17 +0200 Subject: comments --- config/p10k-classic.zsh | 2 +- config/p10k-lean.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index c1acfe82..cc099ead 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -351,7 +351,7 @@ fi # !42 if have unstaged changes. vcs+='${${VCS_STATUS_NUM_UNSTAGED:#0}:+ %178F!${VCS_STATUS_NUM_UNSTAGED}}' # ?42 if have untracked files. It's really a question mark, your font isn't broken. - # See POWERLEVEL9K_VCS_UNTRACKED_ICON below if you want to use a different icon. + # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. # Remove the next line if you don't want to see untracked files at all. vcs+='${${VCS_STATUS_NUM_UNTRACKED:#0}:+ %39F'${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}'${VCS_STATUS_NUM_UNTRACKED}}' # If P9K_CONTENT is not empty, leave it unchanged. It's either "loading" or from vcs_info. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index ec03c9c7..ecb76648 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -331,7 +331,7 @@ fi # !42 if have unstaged changes. vcs+='${${VCS_STATUS_NUM_UNSTAGED:#0}:+ %178F!${VCS_STATUS_NUM_UNSTAGED}}' # ?42 if have untracked files. It's really a question mark, your font isn't broken. - # See POWERLEVEL9K_VCS_UNTRACKED_ICON below if you want to use a different icon. + # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. # Remove the next line if you don't want to see untracked files at all. vcs+='${${VCS_STATUS_NUM_UNTRACKED:#0}:+ %39F'${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}'${VCS_STATUS_NUM_UNTRACKED}}' # If P9K_CONTENT is not empty, leave it unchanged. It's either "loading" or from vcs_info. -- cgit v1.2.3 From f5f5fba08f97298d6f3faa7d745f2bb0a4cab473 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 12 Sep 2019 10:55:34 +0200 Subject: doc cleanup --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d918e69b..34470c8e 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,7 @@ Powerlevel10k is a theme for ZSH. It's fast, flexible and easy to install and co Powerlevel10k can be used as a [fast](#is-it-really-fast) drop-in replacement for [Powerlevel9k](https://github.com/bhilburn/powerlevel9k). When given the same configuration options -it will generate -[the same](#does-powerlevel10k-always-render-exactly-the-same-prompt-as-powerlevel9k-given-the-same-config) -prompt. +it will generate the same prompt. ![Powerlevel10k](https://raw.githubusercontent.com/romkatv/powerlevel10k/master/powerlevel10k.png) @@ -96,7 +94,7 @@ your prompt. If it doesn't trigger automatically, type `p10k configure`. If you've been using Powerlevel9k before, **do not remove the configuration options**. Powerlevel10k will pick them up and provide you with the same prompt UI you are used to. Powerlevel10k recognized all configuration options used by Powerlevel9k. See Powerlevel9k -[configuration guide](https://github.com/bhilburn/powerlevel9k#prompt-customization). +[configuration guide](https://github.com/Powerlevel9k/powerlevel9k/blob/master/README.md#prompt-customization). To go beyond the functionality of Powerlevel9k, type `p10k configure` and explore the unique styles and features Powerlevel10k has to offer. -- cgit v1.2.3 From 040be70d926d07c3bbf80b19c3ac4a431475f61f Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 12 Sep 2019 10:55:56 +0200 Subject: change the default value of POWERLEVEL9K_VPN_IP_INTERFACE to recognize wireguard --- internal/p10k.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 96bee0bf..d2f17f08 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3695,7 +3695,7 @@ _p9k_init_params() { _p9k_declare -e POWERLEVEL9K_SHORTEN_DELIMITER _p9k_declare -i POWERLEVEL9K_SHORTEN_DIR_LENGTH _p9k_declare -s POWERLEVEL9K_IP_INTERFACE "" - _p9k_declare -s POWERLEVEL9K_VPN_IP_INTERFACE ".*tun[0-9]*" + _p9k_declare -s POWERLEVEL9K_VPN_IP_INTERFACE "(wg|(.*tun))[0-9]*" _p9k_declare -i POWERLEVEL9K_LOAD_WHICH 5 _p9k_declare -b POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -b POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY 0 -- cgit v1.2.3 From 3674e69b4329fba47945e0fd2beb065ea4cd1cd9 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 12 Sep 2019 10:58:37 +0200 Subject: stop setting prompt_cr and prompt_sp --- internal/icons.zsh | 4 ++-- internal/p10k.zsh | 38 +++++++++++++++++++------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/internal/icons.zsh b/internal/icons.zsh index cacbb535..e0102fed 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -540,7 +540,7 @@ function _p9k_init_icons() { # Sadly, this is a part of public API. Its use is emphatically discouraged. function print_icon() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} _p9k_init_icons [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale local icon_name=$1 @@ -558,7 +558,7 @@ function print_icon() { # otherwise "print_icon" is used, which takes the users # overrides into account. function get_icon_names() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} _p9k_init_icons [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale # Iterate over a ordered list of keys of the icons array diff --git a/internal/p10k.zsh b/internal/p10k.zsh index d2f17f08..6a080586 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -89,7 +89,7 @@ typeset -grA __p9k_colors=( # # Type `getColorCode background` or `getColorCode foreground` to see the list of predefined colors. function getColorCode() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} if (( ARGC == 1 )); then case $1 in foreground) @@ -170,7 +170,7 @@ function _p9k_declare() { # _p9k_prompt_length '%F{red}abc' => 3 # _p9k_prompt_length $'%{a\b%Gb%}' => 1 function _p9k_prompt_length() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} local COLUMNS=1024 local -i x y=$#1 m if (( y )); then @@ -2599,7 +2599,7 @@ function _p9k_vcs_render() { } function _p9k_vcs_resume() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} if [[ $VCS_STATUS_RESULT == ok-async ]]; then local latency=$((EPOCHREALTIME - _p9k_gitstatus_start_time)) @@ -3183,7 +3183,7 @@ function _p9k_update_prompt() { } powerlevel9k_refresh_prompt_inplace() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} (( __p9k_enabled )) || return _p9k_refresh_reason=precmd _p9k_set_prompt @@ -3196,7 +3196,7 @@ typeset -gi __p9k_new_status typeset -ga __p9k_new_pipestatus _p9k_save_status() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} local -i pipe if (( !$+_p9k_line_finished )); then : # SIGINT @@ -3296,7 +3296,7 @@ _p9k_precmd() { } function _p9k_zle_keymap_select() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} zle && zle .reset-prompt && zle -R } @@ -3328,7 +3328,7 @@ _p9k_deinit_async_pump() { } function _p9k_on_async_message() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} (( ARGC == 1 )) || return local msg='' IFS='' while read -r -t -u $1 msg; do @@ -3341,11 +3341,11 @@ function _p9k_on_async_message() { } function _p9k_async_pump() { - emulate -L zsh || return - setopt no_aliases no_hist_expand extended_glob || return - setopt no_prompt_bang prompt_{cr,percent,subst,sp} || return - zmodload zsh/system zsh/datetime || return - echo $$ || return + emulate -L zsh || return + setopt no_aliases no_hist_expand extended_glob || return + setopt no_prompt_bang prompt_{percent,subst} || return + zmodload zsh/system zsh/datetime || return + echo $$ || return local ip last_ip local -F next_ip_time @@ -3404,7 +3404,7 @@ function _p9k_async_pump() { } function _p9k_kill_async_pump() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} if [[ $ZSH_SUBSHELL == $_p9k_async_pump_subshell && $$ == $_p9k_async_pump_shell_pid ]]; then _p9k_deinit_async_pump fi @@ -3848,7 +3848,7 @@ function _p9k_zle_line_finish() { (( __p9k_enabled )) || return _p9k_line_finished= if (( _p9k_reset_on_line_finish )); then - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} zle && zle .reset-prompt && zle -R fi } @@ -3858,7 +3858,7 @@ function _p9k_zle_line_pre_redraw() { [[ ${KEYMAP:-} == vicmd ]] || return 0 local region=${${REGION_ACTIVE:-0}/2/1} [[ $region != $_p9k_region_active ]] || return 0 - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} _p9k_region_active=$region zle && zle .reset-prompt && zle -R } @@ -4129,7 +4129,7 @@ _p9k_init_ssh() { } _p9k_must_init() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} local -a param_keys=( ${(o)parameters[(I)(POWERLEVEL9K_*|GITSTATUS_LOG_LEVEL|GITSTATUS_ENABLE_LOGGING|GITSTATUS_DAEMON|GITSTATUS_NUM_THREADS|DEFAULT_USER|ZLE_RPROMPT_INDENT)]}) local IFS param_sig @@ -4148,7 +4148,7 @@ function _p9k_set_os() { } _p9k_init() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} _p9k_init_icons _p9k_init_vars @@ -4377,7 +4377,7 @@ typeset -gi __p9k_enabled=0 typeset -gi __p9k_configured=0 prompt_powerlevel9k_setup() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} prompt_powerlevel9k_teardown __p9k_enabled=1 add-zsh-hook preexec _p9k_preexec @@ -4385,7 +4385,7 @@ prompt_powerlevel9k_setup() { } prompt_powerlevel9k_teardown() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{cr,percent,subst,sp} + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} add-zsh-hook -D precmd '(_p9k_|powerlevel9k_)*' add-zsh-hook -D preexec '(_p9k_|powerlevel9k_)*' PROMPT='%m%# ' -- cgit v1.2.3 From 9c9039253c2da76e553c1cd2f4e822142bf708a9 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 12 Sep 2019 11:35:24 +0200 Subject: put most of precmd code under !zle --- internal/p10k.zsh | 71 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 6a080586..c60619f2 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3244,33 +3244,49 @@ _p9k_precmd() { __p9k_new_status=$? __p9k_new_pipestatus=($pipestatus) - if (( $+_p9k_real_zle_rprompt_indent )); then - if [[ -n $_p9k_real_zle_rprompt_indent ]]; then - ZLE_RPROMPT_INDENT=$_p9k_real_zle_rprompt_indent - else - unset ZLE_RPROMPT_INDENT + if ! zle; then + if (( $+_p9k_real_zle_rprompt_indent )); then + if [[ -n $_p9k_real_zle_rprompt_indent ]]; then + ZLE_RPROMPT_INDENT=$_p9k_real_zle_rprompt_indent + else + unset ZLE_RPROMPT_INDENT + fi + unset _p9k_real_zle_rprompt_indent fi - unset _p9k_real_zle_rprompt_indent - fi - if _p9k_must_init; then - if (( !__p9k_configured )); then - __p9k_configured=1 - if [[ "${parameters[(I)POWERLEVEL9K_*]}" == (POWERLEVEL9K_MODE|) ]] && _p9k_can_configure -q; then - ( - local p=("${(@)parameters[(I)AWESOME_*|CODEPOINT_*]}") - if (( $#p )); then - typeset -x -- $p + if _p9k_must_init; then + if (( !__p9k_configured )); then + __p9k_configured=1 + if [[ "${parameters[(I)POWERLEVEL9K_*]}" == (POWERLEVEL9K_MODE|) ]] && _p9k_can_configure -q; then + ( + local p=("${(@)parameters[(I)AWESOME_*|CODEPOINT_*]}") + if (( $#p )); then + typeset -x -- $p + fi + $__p9k_root_dir/internal/wizard.zsh -d $__p9k_root_dir + ) + if (( !$? )); then + source $__p9k_cfg_path + _p9k_must_init fi - $__p9k_root_dir/internal/wizard.zsh -d $__p9k_root_dir - ) - if (( !$? )); then - source $__p9k_cfg_path - _p9k_must_init fi fi + _p9k_init fi - _p9k_init + + _p9k_timer_end=EPOCHREALTIME + if (( _p9k_timer_start )); then + typeset -gF P9K_COMMAND_DURATION_SECONDS=$((_p9k_timer_end - _p9k_timer_start)) + else + unset P9K_COMMAND_DURATION_SECONDS + fi + _p9k_save_status + + _p9k_timer_start=0 + _p9k_region_active=0 + + unset _p9k_line_finished + unset _p9k_preexec_cmd fi unsetopt localoptions @@ -3279,20 +3295,7 @@ _p9k_precmd() { [[ ! -o prompt_cr ]] || prompt_opts+=cr setopt nopromptbang prompt{percent,subst} - _p9k_timer_end=EPOCHREALTIME - if (( _p9k_timer_start )); then - typeset -gF P9K_COMMAND_DURATION_SECONDS=$((_p9k_timer_end - _p9k_timer_start)) - else - unset P9K_COMMAND_DURATION_SECONDS - fi - _p9k_save_status - powerlevel9k_refresh_prompt_inplace - - unset _p9k_line_finished - unset _p9k_preexec_cmd - _p9k_timer_start=0 - _p9k_region_active=0 } function _p9k_zle_keymap_select() { -- cgit v1.2.3 From 8554c755bd2b1c5c171c2ce963835d99b59814ed Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 12 Sep 2019 11:45:17 +0200 Subject: print new line(s) in precmd instead of embedding them in PROMPT --- internal/p10k.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index c60619f2..a77c7ebb 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3245,6 +3245,8 @@ _p9k_precmd() { __p9k_new_pipestatus=($pipestatus) if ! zle; then + print -rn ${_p9k_prompt_newline:-} + if (( $+_p9k_real_zle_rprompt_indent )); then if [[ -n $_p9k_real_zle_rprompt_indent ]]; then ZLE_RPROMPT_INDENT=$_p9k_real_zle_rprompt_indent @@ -3532,6 +3534,7 @@ _p9k_init_vars() { typeset -gi _p9k_g typeset -gi _p9k_ind typeset -g _p9k_gap_pre + typeset -g _p9k_prompt_newline typeset -g _p9k_prompt_prefix_left typeset -g _p9k_prompt_prefix_right typeset -g _p9k_prompt_suffix_left @@ -4061,7 +4064,7 @@ _p9k_init_prompt() { fi if (( _POWERLEVEL9K_PROMPT_ADD_NEWLINE )); then - repeat $_POWERLEVEL9K_PROMPT_ADD_NEWLINE_COUNT _p9k_prompt_prefix_left+=$'\n' + repeat $_POWERLEVEL9K_PROMPT_ADD_NEWLINE_COUNT _p9k_prompt_newline+=$'\n' fi _p9k_t=($'\n' '') -- cgit v1.2.3 From 71329b12f2c07432f1657ea6c9677235e571c66c Mon Sep 17 00:00:00 2001 From: Frankie Wittevrongel Date: Sun, 15 Sep 2019 19:50:08 +0100 Subject: Fix typo in declare POWERLEVEL9K_DIR_ANCHOR_BOLD --- internal/p10k.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index a77c7ebb..3ef5e7c1 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3623,7 +3623,7 @@ _p9k_init_params() { _p9k_declare -e POWERLEVEL9K_DIR_PATH_SEPARATOR "/" _p9k_declare -e POWERLEVEL9K_HOME_FOLDER_ABBREVIATION "~" _p9k_declare -b POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD 0 - _p9k_declare -b POWERLEVEL9K_DIR_ANCHORS_BOLD 0 + _p9k_declare -b POWERLEVEL9K_DIR_ANCHOR_BOLD 0 _p9k_declare -b POWERLEVEL9K_DIR_PATH_ABSOLUTE 0 _p9k_declare -b POWERLEVEL9K_DIR_SHOW_WRITABLE 0 _p9k_declare -b POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER 0 -- cgit v1.2.3 From 2218060b2d8b4ca7edf1299c65871cdf700898e3 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 16 Sep 2019 13:45:06 +0200 Subject: don't assume that KEYMAP is valid everywhere within zle --- internal/p10k.zsh | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 3ef5e7c1..8c3b2cee 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -2031,13 +2031,13 @@ prompt_status() { prompt_prompt_char() { if (( _p9k_status )); then - _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${KEYMAP:-0}:#(vicmd|vivis|vivli)}' '❯' - _p9k_prompt_segment $0_ERROR_VICMD "$_p9k_color1" 196 '' 0 '${(M)${:-$KEYMAP$_p9k_region_active}:#vicmd0}' '❮' - _p9k_prompt_segment $0_ERROR_VIVIS "$_p9k_color1" 196 '' 0 '${(M)${:-$KEYMAP$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' + _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${${KEYMAP:-$_p9k_keymap}:-0}:#(vicmd|vivis|vivli)}' '❯' + _p9k_prompt_segment $0_ERROR_VICMD "$_p9k_color1" 196 '' 0 '${(M)${:-${KEYMAP:-$_p9k_keymap}$_p9k_region_active}:#vicmd0}' '❮' + _p9k_prompt_segment $0_ERROR_VIVIS "$_p9k_color1" 196 '' 0 '${(M)${:-${KEYMAP:-$_p9k_keymap}$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' else - _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${KEYMAP:-0}:#(vicmd|vivis|vivli)}' '❯' - _p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${(M)${:-$KEYMAP$_p9k_region_active}:#vicmd0}' '❮' - _p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${(M)${:-$KEYMAP$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' + _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${${KEYMAP:-$_p9k_keymap}:-0}:#(vicmd|vivis|vivli)}' '❯' + _p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${(M)${:-${KEYMAP:-$_p9k_keymap}$_p9k_region_active}:#vicmd0}' '❮' + _p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${(M)${:-${KEYMAP:-$_p9k_keymap}$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' fi } @@ -2711,13 +2711,13 @@ prompt_vcs() { # Vi Mode: show editing mode (NORMAL|INSERT|VISUAL) prompt_vi_mode() { if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then - _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${${KEYMAP:-0}:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" + _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${${${KEYMAP:-$_p9k_keymap}:-0}:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" fi if (( $+_POWERLEVEL9K_VI_VISUAL_MODE_STRING )); then - _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)${:-$KEYMAP$_p9k_region_active}:#vicmd0}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" - _p9k_prompt_segment $0_VISUAL "$_p9k_color1" white '' 0 '${(M)${:-$KEYMAP$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' "$_POWERLEVEL9K_VI_VISUAL_MODE_STRING" + _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)${:-${KEYMAP:-$_p9k_keymap}$_p9k_region_active}:#vicmd0}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" + _p9k_prompt_segment $0_VISUAL "$_p9k_color1" white '' 0 '${(M)${:-${KEYMAP:-$_p9k_keymap}$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' "$_POWERLEVEL9K_VI_VISUAL_MODE_STRING" else - _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)KEYMAP:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" + _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)${KEYMAP:-$_p9k_keymap}:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" fi } @@ -3289,6 +3289,7 @@ _p9k_precmd() { unset _p9k_line_finished unset _p9k_preexec_cmd + _p9k_keymap=main fi unsetopt localoptions @@ -3302,6 +3303,7 @@ _p9k_precmd() { function _p9k_zle_keymap_select() { emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + _p9k_keymap=$KEYMAP zle && zle .reset-prompt && zle -R } @@ -3558,6 +3560,7 @@ _p9k_init_vars() { typeset -g _p9k_pwd_a typeset -gA _p9k_iface typeset -gi _p9k_fetch_iface + typeset -g _p9k_keymap typeset -g P9K_VISUAL_IDENTIFIER typeset -g P9K_CONTENT -- cgit v1.2.3 From f79ad6524376dcf9e7d4d9b396c5746c1ff24c28 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 17 Sep 2019 09:59:39 +0200 Subject: more robust KEYMAP handling --- internal/p10k.zsh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 8c3b2cee..90460f49 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -2031,13 +2031,13 @@ prompt_status() { prompt_prompt_char() { if (( _p9k_status )); then - _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${${KEYMAP:-$_p9k_keymap}:-0}:#(vicmd|vivis|vivli)}' '❯' - _p9k_prompt_segment $0_ERROR_VICMD "$_p9k_color1" 196 '' 0 '${(M)${:-${KEYMAP:-$_p9k_keymap}$_p9k_region_active}:#vicmd0}' '❮' - _p9k_prompt_segment $0_ERROR_VIVIS "$_p9k_color1" 196 '' 0 '${(M)${:-${KEYMAP:-$_p9k_keymap}$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' + _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' '❯' + _p9k_prompt_segment $0_ERROR_VICMD "$_p9k_color1" 196 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' '❮' + _p9k_prompt_segment $0_ERROR_VIVIS "$_p9k_color1" 196 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' else - _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${${KEYMAP:-$_p9k_keymap}:-0}:#(vicmd|vivis|vivli)}' '❯' - _p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${(M)${:-${KEYMAP:-$_p9k_keymap}$_p9k_region_active}:#vicmd0}' '❮' - _p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${(M)${:-${KEYMAP:-$_p9k_keymap}$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' + _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' '❯' + _p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' '❮' + _p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' fi } @@ -2711,13 +2711,13 @@ prompt_vcs() { # Vi Mode: show editing mode (NORMAL|INSERT|VISUAL) prompt_vi_mode() { if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then - _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${${${KEYMAP:-$_p9k_keymap}:-0}:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" + _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" fi if (( $+_POWERLEVEL9K_VI_VISUAL_MODE_STRING )); then - _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)${:-${KEYMAP:-$_p9k_keymap}$_p9k_region_active}:#vicmd0}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" - _p9k_prompt_segment $0_VISUAL "$_p9k_color1" white '' 0 '${(M)${:-${KEYMAP:-$_p9k_keymap}$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' "$_POWERLEVEL9K_VI_VISUAL_MODE_STRING" + _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" + _p9k_prompt_segment $0_VISUAL "$_p9k_color1" white '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' "$_POWERLEVEL9K_VI_VISUAL_MODE_STRING" else - _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)${KEYMAP:-$_p9k_keymap}:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" + _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)_p9k_keymap:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" fi } @@ -4047,6 +4047,7 @@ _p9k_init_prompt() { _p9k_prompt_suffix_left='${${COLUMNS::=$_p9k_clm}+}' _p9k_prompt_suffix_right='${${COLUMNS::=$_p9k_clm}+}' + _p9k_prompt_prefix_left+='${${_p9k_keymap::=${KEYMAP:-$_p9k_keymap}}+}' _p9k_prompt_prefix_left+='%b%k%f' # Bug fixed in: https://github.com/zsh-users/zsh/commit/3eea35d0853bddae13fa6f122669935a01618bf9. -- cgit v1.2.3 From 5b293c13a261f514b31dd1a54c8da9bebcc8363c Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 17 Sep 2019 10:12:48 +0200 Subject: add font instructions for konsole and tilix; change instructions for gnome terminal The previous instructions for GNOME Terminal were simpler but they had a hidden risk. Namely, if users skip the first step (install Meslo) and go directly for the second (set Meslo as the default monospace font), their terminal gets fucked up. See #218. --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 34470c8e..0487b951 100644 --- a/README.md +++ b/README.md @@ -124,8 +124,13 @@ applications on your system. Configure your terminal to use this font: `module.exports.config` to `MesloLGS NF`. - **Visual Studio Code**: Open *File → Preferences → Settings*, enter `terminal.integrated.fontFamily` in the search box and set the value to `MesloLGS NF`. -- **GNOME Terminal** (the default Ubuntu terminal): Run: - `sudo apt install libglib2.0-bin && gsettings set org.gnome.desktop.interface monospace-font-name 'MesloLGS NF 11'`. +- **GNOME Terminal** (the default Ubuntu terminal): Open *Terminal → Preferences* and click on the + selected profile under *Profiles*. Check *Custom font* under *Text Appearance* and select + `MesloLGS NF Regular`. +- **Konsole**: Open *Settings → Edit Current Profile → Appearance*, click *Select Font* and select + `MesloLGS NF Regular`. +- **Tilix**: Open *Tilix → Preferences* and click on the selected profile under *Profiles*. Check + *Custom font* under *Text Appearance* and select `MesloLGS NF Regular`. - **Windows Console Host** (the old thing): Click the icon in the top left corner, then *Properties → Font* and set *Font* to `MesloLGS NF`. - **Windows Terminal** (the new thing): Open *Settings* (`Ctrl+,`), search for `fontFace` and set -- cgit v1.2.3 From ebe6a5198d8bbbb5fbe1b3acef4acf118c8a3c12 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 17 Sep 2019 21:41:07 +0200 Subject: survive SH_WORD_SPLIT; fixes #220 --- internal/p10k.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 90460f49..f9dd4b02 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3245,7 +3245,7 @@ _p9k_precmd() { __p9k_new_pipestatus=($pipestatus) if ! zle; then - print -rn ${_p9k_prompt_newline:-} + print -rn "${_p9k_prompt_newline:-}" if (( $+_p9k_real_zle_rprompt_indent )); then if [[ -n $_p9k_real_zle_rprompt_indent ]]; then @@ -3263,12 +3263,12 @@ _p9k_precmd() { ( local p=("${(@)parameters[(I)AWESOME_*|CODEPOINT_*]}") if (( $#p )); then - typeset -x -- $p + typeset -x -- "$p" fi - $__p9k_root_dir/internal/wizard.zsh -d $__p9k_root_dir + "$__p9k_root_dir"/internal/wizard.zsh -d "$__p9k_root_dir" ) - if (( !$? )); then - source $__p9k_cfg_path + if (( ! $? )); then + source "$__p9k_cfg_path" _p9k_must_init fi fi -- cgit v1.2.3 From f3e96b17c82ccf3f7bcbebd2fb4aff3218daa638 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 18 Sep 2019 10:27:31 +0200 Subject: comments --- config/p10k-lean.zsh | 1 - 1 file changed, 1 deletion(-) diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index ecb76648..49704302 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -366,7 +366,6 @@ fi typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=178 ##########################[ status: exit code of the last command ]########################### - # Status on success. No content, just an icon. # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and # style them independently from the regular OK and ERROR state. typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true -- cgit v1.2.3 From 263f915a49da3881880c6826d36db6d38c7f43d2 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 18 Sep 2019 10:45:18 +0200 Subject: cleanup --- config/p10k-classic.zsh | 2 +- config/p10k-lean.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index cc099ead..3964dac7 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -360,7 +360,7 @@ fi # Disable the default Git status formatting. typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true # Install our own Git status formatter. - typeset -g POWERLEVEL9K_VCS_{CLEAN,UNTRACKED,MODIFIED}_CONTENT_EXPANSION=$vcs + typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION=$vcs # When Git status is being refreshed asynchronously, display the last known repo status in grey. typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION=${${${vcs//\%f}//\%<->F}//\%F\{(\#|)[[:xdigit:]]#(\\|)\}} # Enable counters for staged, unstaged, etc. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 49704302..74b4e3f6 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -340,7 +340,7 @@ fi # Disable the default Git status formatting. typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true # Install our own Git status formatter. - typeset -g POWERLEVEL9K_VCS_{CLEAN,UNTRACKED,MODIFIED}_CONTENT_EXPANSION=$vcs + typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION=$vcs # When Git status is being refreshed asynchronously, display the last known repo status in grey. typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION=${${${vcs//\%f}//\%<->F}//\%F\{(\#|)[[:xdigit:]]#(\\|)\}} # Enable counters for staged, unstaged, etc. -- cgit v1.2.3 From 80d9df711707c827e50a7f6f85924f3ddf2407b8 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 18 Sep 2019 10:45:30 +0200 Subject: add CONFLICTING state to vcs The new state is used whenever there is at least one conflicting change. It is disabled by default. It can be enabled by defining POWERLEVEL9K_VCS_CONFLICTING_STATE=true. POWERLEVEL9K_VCS_CONFLICTING_STATE=true POWERLEVEL9K_VCS_CONFLICTING_BACKGROUND=magenta Fixes #221. --- internal/p10k.zsh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index f9dd4b02..be634d40 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -2160,6 +2160,7 @@ typeset -gA __p9k_vcs_states=( 'MODIFIED' '3' 'UNTRACKED' '2' 'LOADING' '8' + 'CONFLICTING' '3' ) function +vi-git-untracked() { @@ -2441,7 +2442,9 @@ function _p9k_vcs_render() { if (( _POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING )); then if [[ -z $state ]]; then - if [[ $VCS_STATUS_HAS_STAGED != 0 || $VCS_STATUS_HAS_UNSTAGED != 0 ]]; then + if [[ $VCS_STATUS_HAS_CONFLICTED == 1 && $_POWERLEVEL9K_VCS_CONFLICTING_STATE == 1 ]]; then + state=CONFLICTING + elif [[ $VCS_STATUS_HAS_STAGED != 0 || $VCS_STATUS_HAS_UNSTAGED != 0 ]]; then state=MODIFIED elif [[ $VCS_STATUS_HAS_UNTRACKED != 0 ]]; then state=UNTRACKED @@ -2474,6 +2477,7 @@ function _p9k_vcs_render() { "$VCS_STATUS_NUM_STAGED" "$VCS_STATUS_NUM_UNSTAGED" "$VCS_STATUS_NUM_UNTRACKED" + "$VCS_STATUS_HAS_CONFLICTED" "$VCS_STATUS_HAS_STAGED" "$VCS_STATUS_HAS_UNSTAGED" "$VCS_STATUS_HAS_UNTRACKED" @@ -2491,7 +2495,9 @@ function _p9k_vcs_render() { local content if (( ${_POWERLEVEL9K_VCS_GIT_HOOKS[(I)vcs-detect-changes]} )); then - if [[ $VCS_STATUS_HAS_STAGED != 0 || $VCS_STATUS_HAS_UNSTAGED != 0 ]]; then + if [[ $VCS_STATUS_HAS_CONFLICTED == 1 && $_POWERLEVEL9K_VCS_CONFLICTING_STATE == 1 ]]; then + : ${state:=CONFLICTING} + elif [[ $VCS_STATUS_HAS_STAGED != 0 || $VCS_STATUS_HAS_UNSTAGED != 0 ]]; then : ${state:=MODIFIED} elif [[ $VCS_STATUS_HAS_UNTRACKED != 0 ]]; then : ${state:=UNTRACKED} @@ -3583,6 +3589,7 @@ _p9k_init_params() { _p9k_declare -i POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH _p9k_declare -s POWERLEVEL9K_VCS_SHORTEN_STRATEGY _p9k_declare -e POWERLEVEL9K_VCS_SHORTEN_DELIMITER '\u2026' + _p9k_declare -b POWERLEVEL9K_VCS_CONFLICTING_STATE 0 _p9k_declare -b POWERLEVEL9K_HIDE_BRANCH_ICON 0 _p9k_declare -b POWERLEVEL9K_VCS_HIDE_TAGS 0 _p9k_declare -i POWERLEVEL9K_CHANGESET_HASH_LENGTH 8 -- cgit v1.2.3 From e470bbfe11f1e3c311edf5be06d99419b8194f52 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 18 Sep 2019 10:50:35 +0200 Subject: remove EXTENDED_CONFIGURATION.md; it fell behind the times too much for my comfort --- EXTENDED_CONFIGURATION.md | 82 ----------------------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 EXTENDED_CONFIGURATION.md diff --git a/EXTENDED_CONFIGURATION.md b/EXTENDED_CONFIGURATION.md deleted file mode 100644 index 048f3bf2..00000000 --- a/EXTENDED_CONFIGURATION.md +++ /dev/null @@ -1,82 +0,0 @@ -# Powerlevel10k Extended Configuration - -Powerlevel10k has configuration options that Powerlevel9k doesn't. These options have `POWERLEVEL9K` -prefix just like the rest. - -`POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS (FLOAT) [default=0.05]` - -If it takes longer than this to fetch git repo status, display the prompt with a greyed out -vcs segment and fix it asynchronously when the results come it. - -`POWERLEVEL9K_VCS_BACKENDS (ARRAY) [default=(git)]` - -The list of VCS backends to use. Supported values are `git`, `svn` and `hg`. Note that adding -anything other than git will make prompt slower even when your current directory isn't a repo. - -`POWERLEVEL9K_GITSTATUS_DIR (STRING) [default=$POWERLEVEL9K_INSTALLATION_DIR/gitstatus]` - -Directory with gitstatus plugin. By default uses a copy bundled with Powerlevel10k. - -`POWERLEVEL9K_DISABLE_GITSTATUS (STRING) [default="false"]` - -If set to `"true"`, Powerlevel10k won't use its fast git backend and will fall back to -`vcs_info` like Powerlevel9k. - -`POWERLEVEL9K_MAX_CACHE_SIZE (INT) [default=10000]` - -The maximum number of elements that can be stored in the cache. When the cache grows over this -limit, it gets cleared. - -`POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY (INT) [default=-1]` - -Don't scan for dirty files in git repos with more files in the index than this. Instead, show -them with the "dirty" color (yellow by default) whether they are dirty or not. This makes git -prompt much faster on huge repositories. - -`POWERLEVEL9K_EXPERIMENTAL_TIME_REALTIME (STRING) [default="false"]` - -If set to `"true"`, `time` segment will update every second, turning into a realtime clock. -This option triggers a -[bug in completion menu](https://www.zsh.org/mla/workers//2019/msg00161.html) in zsh, and -another -[bug in history](https://github.com/bhilburn/powerlevel9k/commit/fb1ef540228ec7b4394cf2f6860137074c5838a6#commitcomment-32779672). -You can pick up a fix for the latter from -[a fork of zsh](https://github.com/romkatv/zsh/tree/gentle-reset-prompt). - -When using gitstatus, there is an extra state called `LOADING` that is used by `vcs` prompt -segment when it's waiting for git status in the background. You can define styling for this -state the same way as for the other states -- `CLEAN`, `UNTRACKED` and `MODIFIED`. You can -also define the icon and the text that will be used when `LOADING` state is triggered for a -git repository for which no prior status is known. If both `POWERLEVEL9K_VCS_LOADING_ICON` -and `POWERLEVEL9K_VCS_LOADING_TEXT` are empty, `vcs` segment in such cases won't be shown. - - * `POWERLEVEL9K_VCS_LOADING_ICON (STRING) [default=""]` - - Icon shown while waiting for git status for a repo for the first time. - * `POWERLEVEL9K_VCS_LOADING_TEXT (STRING) [default="loading"]` - - Text shown while waiting for git status for a repo for the first time. - * `POWERLEVEL9K_VCS_LOADING_BACKGROUND (STRING) [default="grey"]` - - Background color for `LOADING` state. - * `POWERLEVEL9K_VCS_LOADING_FOREGROUND (STRING) [default="$DEFAULT_COLOR"]` - - Foreground color for `LOADING` state. - * `POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR (STRING) [default=$POWERLEVEL9K_VCS_LOADING_FOREGROUND]` - - Foreground color for `POWERLEVEL9K_VCS_LOADING_ICON`. - -When using gitstatus, components of `vcs` segment can be colored individually by setting -`POWERLEVEL9K_VCS_${STATE}_${COMPONENT}FORMAT_FOREGROUND`. `${STATE}` should be one of `CLEAN`, -`UNTRACKED`, `MODIFIED` or `LOADING`. `${COMPONENT}` should be one of `REMOTE_URL`, `COMMIT`, -`BRANCH`, `TAG`, `REMOTE_BRANCH`, `STAGED`, `UNSTAGED`, `UNTRACKED`, `OUTGOING_CHANGES`, -`INCOMING_CHANGES`, `STASH` or `ACTION`. If -`POWERLEVEL9K_VCS_${STATE}_${COMPONENT}FORMAT_FOREGROUND` isn't set for some combination of -`${STATE}` and `${COMPONENT}`, the component is colored with -`POWERLEVEL9K_VCS_${COMPONENT}FORMAT_FOREGROUND`. If that one isn't set either, the component is -colored with `POWERLEVEL9K_VCS_${STATE}_FOREGROUND`. The fallback logic is consistent with -Powerlevel9k, meaning that your `vcs` prompt will look the same in Powerlevel10k and -Powerlevel9k if you don't define any `POWERLEVEL9K_VCS_${STATE}_${COMPONENT}_FOREGROUND` -parameters. Note that both the icon and the text in each component always have the same color. -There is currently no `POWERLEVEL9K_VCS_${STATE}_${COMPONENT}FORMAT_VISUAL_IDENTIFIER_COLOR`, -although it's easy to implement if desired. -- cgit v1.2.3 From 79e0190ba1f42207b1fc59885713c8b3cbaa0cc8 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 18 Sep 2019 13:20:33 +0200 Subject: s/CONFLICTING/CONFLICTED/ for consistency; see #221 --- internal/p10k.zsh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index be634d40..159dacb3 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -2160,7 +2160,7 @@ typeset -gA __p9k_vcs_states=( 'MODIFIED' '3' 'UNTRACKED' '2' 'LOADING' '8' - 'CONFLICTING' '3' + 'CONFLICTED' '3' ) function +vi-git-untracked() { @@ -2442,8 +2442,8 @@ function _p9k_vcs_render() { if (( _POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING )); then if [[ -z $state ]]; then - if [[ $VCS_STATUS_HAS_CONFLICTED == 1 && $_POWERLEVEL9K_VCS_CONFLICTING_STATE == 1 ]]; then - state=CONFLICTING + if [[ $VCS_STATUS_HAS_CONFLICTED == 1 && $_POWERLEVEL9K_VCS_CONFLICTED_STATE == 1 ]]; then + state=CONFLICTED elif [[ $VCS_STATUS_HAS_STAGED != 0 || $VCS_STATUS_HAS_UNSTAGED != 0 ]]; then state=MODIFIED elif [[ $VCS_STATUS_HAS_UNTRACKED != 0 ]]; then @@ -2495,8 +2495,8 @@ function _p9k_vcs_render() { local content if (( ${_POWERLEVEL9K_VCS_GIT_HOOKS[(I)vcs-detect-changes]} )); then - if [[ $VCS_STATUS_HAS_CONFLICTED == 1 && $_POWERLEVEL9K_VCS_CONFLICTING_STATE == 1 ]]; then - : ${state:=CONFLICTING} + if [[ $VCS_STATUS_HAS_CONFLICTED == 1 && $_POWERLEVEL9K_VCS_CONFLICTED_STATE == 1 ]]; then + : ${state:=CONFLICTED} elif [[ $VCS_STATUS_HAS_STAGED != 0 || $VCS_STATUS_HAS_UNSTAGED != 0 ]]; then : ${state:=MODIFIED} elif [[ $VCS_STATUS_HAS_UNTRACKED != 0 ]]; then @@ -3589,7 +3589,7 @@ _p9k_init_params() { _p9k_declare -i POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH _p9k_declare -s POWERLEVEL9K_VCS_SHORTEN_STRATEGY _p9k_declare -e POWERLEVEL9K_VCS_SHORTEN_DELIMITER '\u2026' - _p9k_declare -b POWERLEVEL9K_VCS_CONFLICTING_STATE 0 + _p9k_declare -b POWERLEVEL9K_VCS_CONFLICTED_STATE 0 _p9k_declare -b POWERLEVEL9K_HIDE_BRANCH_ICON 0 _p9k_declare -b POWERLEVEL9K_VCS_HIDE_TAGS 0 _p9k_declare -i POWERLEVEL9K_CHANGESET_HASH_LENGTH 8 -- cgit v1.2.3 From 6b234b789d0884e47acec1c7de3d92fe1ac49f95 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 18 Sep 2019 13:38:31 +0200 Subject: add OVERWRITE vi mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using vi_mode segment, the new mode can be enabled by defining POWERLEVEL9K_VI_OVERWRITE_MODE_STRING. POWERLEVEL9K_VI_OVERWRITE_MODE_STRING=OVERWRITE When using prompt_char, the new mode can be enabled by defining POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true. The prompt symbol in OVERWRITE state defaults to '▶'. It can be customized by defining POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION. POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true POWERLEVEL9K_PROMPT_CHAR_OK_VIOWR_CONTENT_EXPANSION=R POWERLEVEL9K_PROMPT_CHAR_ERROR_VIOWR_CONTENT_EXPANSION=R Fixes #219. --- config/p10k-classic.zsh | 3 +++ config/p10k-lean.zsh | 3 +++ internal/p10k.zsh | 51 +++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 3964dac7..a72a90a6 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -202,6 +202,9 @@ fi typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮' # Prompt symbol in visual vi mode. typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='Ⅴ' + # Prompt symbol in overwrite vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶' + typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true # No line terminator if prompt_char is the last segment. typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL= # No line introducer if prompt_char is the first segment. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 74b4e3f6..4df9958a 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -187,6 +187,9 @@ fi typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮' # Prompt symbol in visual vi mode. typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='Ⅴ' + # Prompt symbol in overwrite vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶' + typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='' ##################################[ dir: current directory ]################################## diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 159dacb3..839f3cf5 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -2031,11 +2031,21 @@ prompt_status() { prompt_prompt_char() { if (( _p9k_status )); then - _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' '❯' + if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then + _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' '❯' + _p9k_prompt_segment $0_ERROR_VIOWR "$_p9k_color1" 196 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}' '▶' + else + _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' '❯' + fi _p9k_prompt_segment $0_ERROR_VICMD "$_p9k_color1" 196 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' '❮' _p9k_prompt_segment $0_ERROR_VIVIS "$_p9k_color1" 196 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' else - _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' '❯' + if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then + _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' '❯' + _p9k_prompt_segment $0_OK_VIOWR "$_p9k_color1" 76 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}' '▶' + else + _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' '❯' + fi _p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' '❮' _p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' fi @@ -2716,9 +2726,17 @@ prompt_vcs() { ################################################################ # Vi Mode: show editing mode (NORMAL|INSERT|VISUAL) prompt_vi_mode() { - if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then - _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" + if (( $+_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING )); then + if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then + _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" + fi + _p9k_prompt_segment $0_OVERWRITE "$_p9k_color1" blue '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}' "$_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING" + else + if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then + _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" + fi fi + if (( $+_POWERLEVEL9K_VI_VISUAL_MODE_STRING )); then _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" _p9k_prompt_segment $0_VISUAL "$_p9k_color1" white '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' "$_POWERLEVEL9K_VI_VISUAL_MODE_STRING" @@ -3296,6 +3314,7 @@ _p9k_precmd() { unset _p9k_line_finished unset _p9k_preexec_cmd _p9k_keymap=main + _p9k_zle_state=insert fi unsetopt localoptions @@ -3309,7 +3328,11 @@ _p9k_precmd() { function _p9k_zle_keymap_select() { emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} - _p9k_keymap=$KEYMAP + zle && zle .reset-prompt && zle -R +} + +function _p9k_zle_state_changed() { + emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} zle && zle .reset-prompt && zle -R } @@ -3567,6 +3590,7 @@ _p9k_init_vars() { typeset -gA _p9k_iface typeset -gi _p9k_fetch_iface typeset -g _p9k_keymap + typeset -g _p9k_zle_state typeset -g P9K_VISUAL_IDENTIFIER typeset -g P9K_CONTENT @@ -3766,6 +3790,8 @@ _p9k_init_params() { _p9k_declare -e POWERLEVEL9K_VI_COMMAND_MODE_STRING "NORMAL" # VISUAL mode is shown as NORMAL unless POWERLEVEL9K_VI_VISUAL_MODE_STRING is explicitly set. _p9k_declare -e POWERLEVEL9K_VI_VISUAL_MODE_STRING + # OVERWRITE mode is shown as INSERT unless POWERLEVEL9K_VI_OVERWRITE_MODE_STRING is explicitly set. + _p9k_declare -e POWERLEVEL9K_VI_OVERWRITE_MODE_STRING _p9k_declare -b POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION 1 _p9k_declare -e POWERLEVEL9K_VIRTUALENV_LEFT_DELIMITER "(" _p9k_declare -e POWERLEVEL9K_VIRTUALENV_RIGHT_DELIMITER ")" @@ -3806,6 +3832,7 @@ _p9k_init_params() { # # These correspond to `java -fullversion` and `java -version` respectively. _p9k_declare -b POWERLEVEL9K_JAVA_VERSION_FULL 1 + _p9k_declare -b POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE 0 local -i i=1 while (( i <= $#_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS )); do @@ -4054,7 +4081,13 @@ _p9k_init_prompt() { _p9k_prompt_suffix_left='${${COLUMNS::=$_p9k_clm}+}' _p9k_prompt_suffix_right='${${COLUMNS::=$_p9k_clm}+}' - _p9k_prompt_prefix_left+='${${_p9k_keymap::=${KEYMAP:-$_p9k_keymap}}+}' + if _p9k_segment_in_use vi_mode && (( $+_POWERLEVEL9K_VI_VISUAL_MODE_STRING )) || _p9k_segment_in_use prompt_char; then + _p9k_prompt_prefix_left+='${${_p9k_keymap::=${KEYMAP:-$_p9k_keymap}}+}' + fi + if { _p9k_segment_in_use vi_mode && (( $+_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING )) } || + { _p9k_segment_in_use prompt_char && (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )) }; then + _p9k_prompt_prefix_left+='${${_p9k_zle_state::=${ZLE_STATE:-$_p9k_zle_state}}+}' + fi _p9k_prompt_prefix_left+='%b%k%f' # Bug fixed in: https://github.com/zsh-users/zsh/commit/3eea35d0853bddae13fa6f122669935a01618bf9. @@ -4358,6 +4391,12 @@ _p9k_init() { _p9k_wrap_zle_widget zle-line-pre-redraw _p9k_zle_line_pre_redraw fi + if { _p9k_segment_in_use vi_mode && (( $+_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING )) } || + { _p9k_segment_in_use prompt_char && (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )) }; then + _p9k_wrap_zle_widget overwrite-mode _p9k_zle_state_changed + _p9k_wrap_zle_widget vi-replace _p9k_zle_state_changed + fi + if _p9k_segment_in_use dir && [[ $_POWERLEVEL9K_SHORTEN_STRATEGY == truncate_with_package_name && $+commands[jq] == 0 ]]; then print -rP -- '%F{yellow}WARNING!%f %BPOWERLEVEL9K_SHORTEN_STRATEGY=truncate_with_package_name%b requires %F{green}jq%f.' -- cgit v1.2.3 From a7e3a70069b138cbfdd58cca1f97409897e0a726 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 19 Sep 2019 14:11:44 +0200 Subject: better PROXY_ICON --- internal/icons.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/icons.zsh b/internal/icons.zsh index e0102fed..fd94b456 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -112,7 +112,7 @@ function _p9k_init_icons() { LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ - PROXY_ICON '\u21AF' # ↯ + PROXY_ICON '\u2B82' # ⮂ ) ;; 'awesome-fontconfig') @@ -212,7 +212,7 @@ function _p9k_init_icons() { LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ - PROXY_ICON '\u21AF' # ↯ + PROXY_ICON '\u2B82' # ⮂ ) ;; 'awesome-mapped-fontconfig') @@ -316,7 +316,7 @@ function _p9k_init_icons() { LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ - PROXY_ICON '\u21AF' # ↯ + PROXY_ICON '\u2B82' # ⮂ ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -417,7 +417,7 @@ function _p9k_init_icons() { LARAVEL_ICON '\ue73f' #  RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ - PROXY_ICON '\u21AF' # ↯ + PROXY_ICON '\u2B82' # ⮂ ) ;; *) @@ -517,7 +517,7 @@ function _p9k_init_icons() { LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ - PROXY_ICON '\u21AF' # ↯ + PROXY_ICON '\u2B82' # ⮂ ) ;; esac -- cgit v1.2.3 From 4563f744dd377aca6ae68b5549a9ba2c078346a3 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 19 Sep 2019 14:34:14 +0200 Subject: use lock as vpn icon where lock is available --- internal/icons.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/icons.zsh b/internal/icons.zsh index fd94b456..351a5b12 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -103,7 +103,7 @@ function _p9k_init_icons() { LOCK_ICON '\UE138' #  EXECUTION_TIME_ICON '\UE89C ' #  SSH_ICON 'ssh' - VPN_ICON 'vpn' + VPN_ICON '\UE138' KUBERNETES_ICON '\U2388 ' # ⎈ DROPBOX_ICON '\UF16B ' #  (doesn't always work) DATE_ICON '\uE184 ' #  @@ -408,7 +408,7 @@ function _p9k_init_icons() { LOCK_ICON '\UF023' #  EXECUTION_TIME_ICON '\uF252 ' #  SSH_ICON '\uF489 ' #  - VPN_ICON 'vpn' + VPN_ICON '\UF023' KUBERNETES_ICON '\U2388' # ⎈ DROPBOX_ICON '\UF16B ' #  DATE_ICON '\uF073 ' #  -- cgit v1.2.3 From 11783c73a341f4346032a7cd1c6d4b3fe321af3b Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 19 Sep 2019 14:34:29 +0200 Subject: add vpn_ip (disable by default) --- config/p10k-classic.zsh | 12 ++++++++++++ config/p10k-lean.zsh | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index a72a90a6..1480976f 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -61,6 +61,7 @@ fi context # user@host nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) + # vpn_ip # virtual private network indicator # ram # free RAM # load # CPU load # time # current time @@ -686,6 +687,17 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + ########################[ vpn_ip: virtual private network indicator ]######################### + # VPN IP color. + typeset -g POWERLEVEL9K_VPN_IP_FOREGROUND=81 + # When on VPN, show just an icon without the IP address. + typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION= + # Regular expression for the VPN network interface. Run ifconfig while on VPN to see the + # name of the interface. + typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(wg|(.*tun))[0-9]*' + # Custom icon. + # typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + #########################[ proxy: system-wide http/https/ftp proxy ]########################## # Proxy color. typeset -g POWERLEVEL9K_PROXY_FOREGROUND=68 diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 4df9958a..e2d7b863 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -61,6 +61,7 @@ fi context # user@host nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) + # vpn_ip # virtual private network indicator # ram # free RAM # load # CPU load # time # current time @@ -665,6 +666,17 @@ fi # Custom icon. # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + ########################[ vpn_ip: virtual private network indicator ]######################### + # VPN IP color. + typeset -g POWERLEVEL9K_VPN_IP_FOREGROUND=81 + # When on VPN, show just an icon without the IP address. + typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION= + # Regular expression for the VPN network interface. Run ifconfig while on VPN to see the + # name of the interface. + typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(wg|(.*tun))[0-9]*' + # Custom icon. + # typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + #########################[ proxy: system-wide http/https/ftp proxy ]########################## # Proxy color. typeset -g POWERLEVEL9K_PROXY_FOREGROUND=68 -- cgit v1.2.3 From cea71da00f7cb8ebe89662f7d3b65ae907bf9ca8 Mon Sep 17 00:00:00 2001 From: seiyeah78 Date: Fri, 20 Sep 2019 00:05:24 +0900 Subject: fix readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0487b951..c54ae673 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ somewhere after it. ### Zplug -Add `zplug romkatv/powerlevel10k, use:powerlevel10k.zsh-theme` to your `~/.zshrc`. +Add `zplug "romkatv/powerlevel10k", as:theme` to your `~/.zshrc`. ### Zgen -- cgit v1.2.3 From 5f15731c6ae0380fadcb55cc3d213c577cfd3a8d Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 19 Sep 2019 17:44:21 +0200 Subject: add zplugin installation instructions --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index c54ae673..9ac00f06 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ it will generate the same prompt. 1. [Zplug](#zplug) 1. [Zgen](#zgen) 1. [Antibody](#antibody) + 1. [Zplugin](#zplugin) 1. [Configuration](#configuration) 1. [For new users](#for-new-users) 1. [For Powerlevel9k users](#for-powerlevel9k-users) @@ -82,6 +83,10 @@ Add `zgen load romkatv/powerlevel10k powerlevel10k` to your `~/.zshrc`. Add `antibody bundle romkatv/powerlevel10k` to your `~/.zshrc`. +### Zplugin + +Add `zplugin light romkatv/powerlevel10k` to your `~/.zshrc`. + ## Configuration ### For new users -- cgit v1.2.3 From 0067e0d4a1148593e3d74640579e555439ee9426 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 20 Sep 2019 11:22:14 +0200 Subject: survive emulate sh; fixes #226 --- config/p10k-classic.zsh | 27 +++--- config/p10k-lean.zsh | 23 +++--- internal/configure.zsh | 5 +- internal/icons.zsh | 6 +- internal/p10k.zsh | 215 +++++++++++++++++++++++++++++++++--------------- internal/wizard.zsh | 2 +- powerlevel9k.zsh-theme | 4 +- 7 files changed, 181 insertions(+), 101 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 1480976f..2041d379 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -5,13 +5,12 @@ # # for i in {0..255}; do print -Pn "%${i}F${(l:3::0:)i}%f " ${${(M)$((i%8)):#7}:+$'\n'}; done -if [[ -o 'aliases' ]]; then - # Temporarily disable aliases. - 'builtin' 'unsetopt' 'aliases' - local p9k_classic_restore_aliases=1 -else - local p9k_classic_restore_aliases=0 -fi +# Temporarily change options. +local p10k_config_opts=() +[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') +'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' () { emulate -L zsh @@ -329,16 +328,16 @@ fi vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON} # If local branch name is at most 32 characters long, show it in full. # This is the equivalent of POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=32. - vcs+='${${${$(($#VCS_STATUS_LOCAL_BRANCH<=32)):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' + vcs+='${${${$(( ${#VCS_STATUS_LOCAL_BRANCH}<=32 )):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' # If local branch name is over 32 characters long, show the first 12 … the last 12. The same as # POWERLEVEL9K_VCS_SHORTEN_LENGTH=12 with POWERLEVEL9K_VCS_SHORTEN_STRATEGY=truncate_middle. - vcs+=':-${VCS_STATUS_LOCAL_BRANCH[1,12]//\%/%%}%28F…%76F${VCS_STATUS_LOCAL_BRANCH[-12,-1]//\%/%%}}}' + vcs+=':-${${VCS_STATUS_LOCAL_BRANCH:0:12}//\%/%%}%28F…%76F${${VCS_STATUS_LOCAL_BRANCH: -12}//\%/%%}}}' # '@72f5c8a' if not on a branch. - vcs+=':-%248F@%76F${VCS_STATUS_COMMIT[1,8]}}' + vcs+=':-%f@%76F${VCS_STATUS_COMMIT:0:8}}' # ':master' if the tracking branch name differs from local branch. - vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%248F:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}' + vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%f:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}' # '#tag' if on a tag. - vcs+='${VCS_STATUS_TAG:+%248F#%76F${VCS_STATUS_TAG//\%/%%}}' + vcs+='${VCS_STATUS_TAG:+%f#%76F${VCS_STATUS_TAG//\%/%%}}' # ⇣42 if behind the remote. vcs+='${${VCS_STATUS_COMMITS_BEHIND:#0}:+ %76F⇣${VCS_STATUS_COMMITS_BEHIND}}' # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. @@ -745,5 +744,5 @@ fi typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' } -(( ! p9k_classic_restore_aliases )) || setopt aliases -'builtin' 'unset' 'p9k_classic_restore_aliases' +setopt ${p10k_config_opts[@]} +'builtin' 'unset' 'p10k_config_opts' diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index e2d7b863..7ec288d4 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -5,13 +5,12 @@ # # for i in {0..255}; do print -Pn "%${i}F${(l:3::0:)i}%f " ${${(M)$((i%8)):#7}:+$'\n'}; done -if [[ -o 'aliases' ]]; then - # Temporarily disable aliases. - 'builtin' 'unsetopt' 'aliases' - local p10k_lean_restore_aliases=1 -else - local p10k_lean_restore_aliases=0 -fi +# Temporarily change options. +local p10k_config_opts=() +[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') +'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' () { emulate -L zsh @@ -309,12 +308,12 @@ fi vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON} # If local branch name is at most 32 characters long, show it in full. # This is the equivalent of POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=32. - vcs+='${${${$(($#VCS_STATUS_LOCAL_BRANCH<=32)):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' + vcs+='${${${$(( ${#VCS_STATUS_LOCAL_BRANCH}<=32 )):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' # If local branch name is over 32 characters long, show the first 12 … the last 12. The same as # POWERLEVEL9K_VCS_SHORTEN_LENGTH=12 with POWERLEVEL9K_VCS_SHORTEN_STRATEGY=truncate_middle. - vcs+=':-${VCS_STATUS_LOCAL_BRANCH[1,12]//\%/%%}%28F…%76F${VCS_STATUS_LOCAL_BRANCH[-12,-1]//\%/%%}}}' + vcs+=':-${${VCS_STATUS_LOCAL_BRANCH:0:12}//\%/%%}%28F…%76F${${VCS_STATUS_LOCAL_BRANCH: -12}//\%/%%}}}' # '@72f5c8a' if not on a branch. - vcs+=':-%f@%76F${VCS_STATUS_COMMIT[1,8]}}' + vcs+=':-%f@%76F${VCS_STATUS_COMMIT:0:8}}' # ':master' if the tracking branch name differs from local branch. vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%f:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}' # '#tag' if on a tag. @@ -724,5 +723,5 @@ fi typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' } -(( ! p10k_lean_restore_aliases )) || setopt aliases -'builtin' 'unset' 'p10k_lean_restore_aliases' +setopt ${p10k_config_opts[@]} +'builtin' 'unset' 'p10k_config_opts' diff --git a/internal/configure.zsh b/internal/configure.zsh index ae24be34..202978f6 100644 --- a/internal/configure.zsh +++ b/internal/configure.zsh @@ -11,7 +11,7 @@ typeset -gr __p9k_root_dir_u=${${${(q)__p9k_root_dir}/#(#b)${(q)HOME}(|\/*)/'~'$ function _p9k_can_configure() { emulate -L zsh - setopt extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} + setopt extended_glob no_prompt_{bang,subst} prompt_percent [[ $1 == '-q' ]] && local -i q=1 || local -i q=0 function $0_error() { (( q )) || print -rP "%1F[ERROR]%f %Bp10k configure%b: $1" >&2 @@ -59,7 +59,8 @@ function _p9k_can_configure() { } function p9k_configure() { - emulate -L zsh && setopt no_hist_expand extended_glob + emulate -L zsh + setopt no_hist_expand extended_glob ( local p=("${(@)parameters[(I)AWESOME_*|CODEPOINT_*]}") if (( $#p )); then diff --git a/internal/icons.zsh b/internal/icons.zsh index 351a5b12..918b0565 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -540,7 +540,8 @@ function _p9k_init_icons() { # Sadly, this is a part of public API. Its use is emphatically discouraged. function print_icon() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} _p9k_init_icons [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale local icon_name=$1 @@ -558,7 +559,8 @@ function print_icon() { # otherwise "print_icon" is used, which takes the users # overrides into account. function get_icon_names() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} _p9k_init_icons [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale # Iterate over a ordered list of keys of the icons array diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 839f3cf5..eeef6a90 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -89,7 +89,8 @@ typeset -grA __p9k_colors=( # # Type `getColorCode background` or `getColorCode foreground` to see the list of predefined colors. function getColorCode() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} if (( ARGC == 1 )); then case $1 in foreground) @@ -170,7 +171,6 @@ function _p9k_declare() { # _p9k_prompt_length '%F{red}abc' => 3 # _p9k_prompt_length $'%{a\b%Gb%}' => 1 function _p9k_prompt_length() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} local COLUMNS=1024 local -i x y=$#1 m if (( y )); then @@ -456,7 +456,7 @@ _p9k_left_prompt_segment() { # 4 # fi - local t=$#_p9k_t + local t=$(($#_p9k_t - __p9k_ksh_arrays)) _p9k_t+=$start_sep$style$left_space # 1 _p9k_t+=$style # 2 if [[ -n $fg_color && $fg_color == $bg_color ]]; then @@ -477,10 +477,15 @@ _p9k_left_prompt_segment() { local p= p+="\${_p9k_n::=}" - p+="\${\${\${_p9k_bg:-0}:#NONE}:-\${_p9k_n::=$((t+1))}}" # 1 - p+="\${_p9k_n:=\${\${\$(($join)):#0}:+$((t+2))}}" # 2 - p+="\${_p9k_n:=\${\${(M)\${:-x$bg_color}:#x(\$_p9k_bg|\${_p9k_bg:-0})}:+$((t+3))}}" # 3 - p+="\${_p9k_n:=$((t+4))}" # 4 + p+="\${\${\${_p9k_bg:-0}:#NONE}:-\${_p9k_n::=$((t+1))}}" # 1 + p+="\${_p9k_n:=\${\${\$(($join)):#0}:+$((t+2))}}" # 2 + if (( __p9k_sh_glob )); then + p+="\${_p9k_n:=\${\${(M)\${:-x$bg_color}:#x\$_p9k_bg}:+$((t+3))}}" # 3 + p+="\${_p9k_n:=\${\${(M)\${:-x$bg_color}:#x\$${_p9k_bg:-0}}:+$((t+3))}}" # 3 + else + p+="\${_p9k_n:=\${\${(M)\${:-x$bg_color}:#x(\$_p9k_bg|\${_p9k_bg:-0})}:+$((t+3))}}" # 3 + fi + p+="\${_p9k_n:=$((t+4))}" # 4 _p9k_param $1 VISUAL_IDENTIFIER_EXPANSION '${P9K_VISUAL_IDENTIFIER}' local icon_exp_=${_p9k_ret:+\"$_p9k_ret\"} @@ -666,7 +671,7 @@ _p9k_right_prompt_segment() { # 4 # fi - local t=$#_p9k_t + local t=$(($#_p9k_t - __p9k_ksh_arrays)) _p9k_t+=$start_sep$style$left_space # 1 _p9k_t+=$w$style # 2 _p9k_t+=$w$subsep$style$left_space # 3 @@ -678,10 +683,15 @@ _p9k_right_prompt_segment() { local p= p+="\${_p9k_n::=}" - p+="\${\${\${_p9k_bg:-0}:#NONE}:-\${_p9k_n::=$((t+1))}}" # 1 - p+="\${_p9k_n:=\${\${\$(($join)):#0}:+$((t+2))}}" # 2 - p+="\${_p9k_n:=\${\${(M)\${:-x\$_p9k_bg}:#x(${(b)bg_color}|${(b)bg_color:-0})}:+$((t+3))}}" # 3 - p+="\${_p9k_n:=$((t+4))}" # 4 + p+="\${\${\${_p9k_bg:-0}:#NONE}:-\${_p9k_n::=$((t+1))}}" # 1 + p+="\${_p9k_n:=\${\${\$(($join)):#0}:+$((t+2))}}" # 2 + if (( __p9k_sh_glob )); then + p+="\${_p9k_n:=\${\${(M)\${:-x\$_p9k_bg}:#x${(b)bg_color}}:+$((t+3))}}" # 3 + p+="\${_p9k_n:=\${\${(M)\${:-x\$_p9k_bg}:#x${(b)bg_color:-0}}:+$((t+3))}}" # 3 + else + p+="\${_p9k_n:=\${\${(M)\${:-x\$_p9k_bg}:#x(${(b)bg_color}|${(b)bg_color:-0})}:+$((t+3))}}" # 3 + fi + p+="\${_p9k_n:=$((t+4))}" # 4 _p9k_param $1 VISUAL_IDENTIFIER_EXPANSION '${P9K_VISUAL_IDENTIFIER}' local icon_exp_=${_p9k_ret:+\"$_p9k_ret\"} @@ -2030,24 +2040,46 @@ prompt_status() { } prompt_prompt_char() { - if (( _p9k_status )); then - if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then - _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' '❯' - _p9k_prompt_segment $0_ERROR_VIOWR "$_p9k_color1" 196 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}' '▶' + if (( __p9k_sh_glob )); then + if (( _p9k_status )); then + if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then + _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${${${${${:-$_p9k_keymap.$_p9k_zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*overwrite*}}' '❯' + _p9k_prompt_segment $0_ERROR_VIOWR "$_p9k_color1" 196 '' 0 '${${${${${${:-$_p9k_keymap.$_p9k_zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*insert*}}' '▶' + else + _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${${${_p9k_keymap:#vicmd}:#vivis}:#vivli}}' '❯' + fi + _p9k_prompt_segment $0_ERROR_VICMD "$_p9k_color1" 196 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' '❮' + _p9k_prompt_segment $0_ERROR_VIVIS "$_p9k_color1" 196 '' 0 '${$((! ${#${${${${:-$_p9k_keymap$_p9k_region_active}:#vicmd1}:#vivis?}:#vivli?}})):#0}' 'Ⅴ' else - _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' '❯' + if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then + _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${${${${${:-$_p9k_keymap.$_p9k_zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*overwrite*}}' '❯' + _p9k_prompt_segment $0_OK_VIOWR "$_p9k_color1" 76 '' 0 '${${${${${${:-$_p9k_keymap.$_p9k_zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*insert*}}' '▶' + else + _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${${${_p9k_keymap:#vicmd}:#vivis}:#vivli}}' '❯' + fi + _p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' '❮' + _p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${$((! ${#${${${${:-$_p9k_keymap$_p9k_region_active}:#vicmd1}:#vivis?}:#vivli?}})):#0}' 'Ⅴ' fi - _p9k_prompt_segment $0_ERROR_VICMD "$_p9k_color1" 196 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' '❮' - _p9k_prompt_segment $0_ERROR_VIVIS "$_p9k_color1" 196 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' else - if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then - _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' '❯' - _p9k_prompt_segment $0_OK_VIOWR "$_p9k_color1" 76 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}' '▶' + if (( _p9k_status )); then + if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then + _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' '❯' + _p9k_prompt_segment $0_ERROR_VIOWR "$_p9k_color1" 196 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}' '▶' + else + _p9k_prompt_segment $0_ERROR_VIINS "$_p9k_color1" 196 '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' '❯' + fi + _p9k_prompt_segment $0_ERROR_VICMD "$_p9k_color1" 196 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' '❮' + _p9k_prompt_segment $0_ERROR_VIVIS "$_p9k_color1" 196 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' else - _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' '❯' + if (( _POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE )); then + _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' '❯' + _p9k_prompt_segment $0_OK_VIOWR "$_p9k_color1" 76 '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}' '▶' + else + _p9k_prompt_segment $0_OK_VIINS "$_p9k_color1" 76 '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' '❯' + fi + _p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' '❮' + _p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' fi - _p9k_prompt_segment $0_OK_VICMD "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' '❮' - _p9k_prompt_segment $0_OK_VIVIS "$_p9k_color1" 76 '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' 'Ⅴ' fi } @@ -2615,7 +2647,8 @@ function _p9k_vcs_render() { } function _p9k_vcs_resume() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} if [[ $VCS_STATUS_RESULT == ok-async ]]; then local latency=$((EPOCHREALTIME - _p9k_gitstatus_start_time)) @@ -2726,22 +2759,42 @@ prompt_vcs() { ################################################################ # Vi Mode: show editing mode (NORMAL|INSERT|VISUAL) prompt_vi_mode() { - if (( $+_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING )); then - if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then - _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" + if (( __p9k_sh_glob )); then + if (( $+_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING )); then + if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then + _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${${${${${${:-$_p9k_keymap.$_p9k_zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*overwrite*}}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" + fi + _p9k_prompt_segment $0_OVERWRITE "$_p9k_color1" blue '' 0 '${${${${${${:-$_p9k_keymap.$_p9k_zle_state}:#vicmd.*}:#vivis.*}:#vivli.*}:#*.*insert*}}' "$_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING" + else + if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then + _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${${${${_p9k_keymap:#vicmd}:#vivis}:#vivli}}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" + fi + fi + + if (( $+_POWERLEVEL9K_VI_VISUAL_MODE_STRING )); then + _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" + _p9k_prompt_segment $0_VISUAL "$_p9k_color1" white '' 0 '${$((! ${#${${${${:-$_p9k_keymap$_p9k_region_active}:#vicmd1}:#vivis?}:#vivli?}})):#0}' "$_POWERLEVEL9K_VI_VISUAL_MODE_STRING" + else + _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${$((! ${#${${${_p9k_keymap:#vicmd}:#vivis}:#vivli}})):#0}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" fi - _p9k_prompt_segment $0_OVERWRITE "$_p9k_color1" blue '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}' "$_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING" else - if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then - _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" + if (( $+_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING )); then + if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then + _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*overwrite*)}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" + fi + _p9k_prompt_segment $0_OVERWRITE "$_p9k_color1" blue '' 0 '${${:-$_p9k_keymap.$_p9k_zle_state}:#(vicmd.*|vivis.*|vivli.*|*.*insert*)}' "$_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING" + else + if [[ -n $_POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then + _p9k_prompt_segment $0_INSERT "$_p9k_color1" blue '' 0 '${_p9k_keymap:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_INSERT_MODE_STRING" + fi fi - fi - if (( $+_POWERLEVEL9K_VI_VISUAL_MODE_STRING )); then - _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" - _p9k_prompt_segment $0_VISUAL "$_p9k_color1" white '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' "$_POWERLEVEL9K_VI_VISUAL_MODE_STRING" - else - _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)_p9k_keymap:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" + if (( $+_POWERLEVEL9K_VI_VISUAL_MODE_STRING )); then + _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#vicmd0}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" + _p9k_prompt_segment $0_VISUAL "$_p9k_color1" white '' 0 '${(M)${:-$_p9k_keymap$_p9k_region_active}:#(vicmd1|vivis?|vivli?)}' "$_POWERLEVEL9K_VI_VISUAL_MODE_STRING" + else + _p9k_prompt_segment $0_NORMAL "$_p9k_color1" white '' 0 '${(M)_p9k_keymap:#(vicmd|vivis|vivli)}' "$_POWERLEVEL9K_VI_COMMAND_MODE_STRING" + fi fi } @@ -3203,11 +3256,12 @@ function _p9k_update_prompt() { _p9k_refresh_reason=$1 _p9k_set_prompt _p9k_refresh_reason='' - zle && zle .reset-prompt && zle -R + _p9k_reset_prompt } powerlevel9k_refresh_prompt_inplace() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} (( __p9k_enabled )) || return _p9k_refresh_reason=precmd _p9k_set_prompt @@ -3216,11 +3270,12 @@ powerlevel9k_refresh_prompt_inplace() { p9k_refresh_prompt_inplace() { powerlevel9k_refresh_prompt_inplace } +typeset -gi __p9k_sh_glob +typeset -gi __p9k_ksh_arrays typeset -gi __p9k_new_status typeset -ga __p9k_new_pipestatus _p9k_save_status() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} local -i pipe if (( !$+_p9k_line_finished )); then : # SIGINT @@ -3264,9 +3319,11 @@ _p9k_save_status() { fi } -_p9k_precmd() { - __p9k_new_status=$? - __p9k_new_pipestatus=($pipestatus) +_p9k_precmd_impl() { + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + + (( __p9k_enabled )) || return if ! zle; then print -rn "${_p9k_prompt_newline:-}" @@ -3317,23 +3374,38 @@ _p9k_precmd() { _p9k_zle_state=insert fi + _p9k_refresh_reason=precmd + _p9k_set_prompt + _p9k_refresh_reason='' +} + +_p9k_precmd() { + __p9k_new_status=$? + __p9k_new_pipestatus=($pipestatus) + [[ -o ksh_arrays ]] && __p9k_ksh_arrays=1 || __p9k_ksh_arrays=0 + [[ -o sh_glob ]] && __p9k_sh_glob=1 || __p9k_sh_glob=0 + unsetopt localoptions prompt_opts=(percent subst) [[ ! -o prompt_sp ]] || prompt_opts+=sp [[ ! -o prompt_cr ]] || prompt_opts+=cr - setopt nopromptbang prompt{percent,subst} + setopt nopromptbang prompt_percent prompt_subst - powerlevel9k_refresh_prompt_inplace + _p9k_precmd_impl } -function _p9k_zle_keymap_select() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} +function _p9k_reset_prompt() { + (( __p9k_ksh_arrays )) && setopt ksh_arrays + (( __p9k_sh_glob )) && setopt sh_glob zle && zle .reset-prompt && zle -R } +function _p9k_zle_keymap_select() { + _p9k_reset_prompt +} + function _p9k_zle_state_changed() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} - zle && zle .reset-prompt && zle -R + _p9k_reset_prompt } _p9k_deinit_async_pump() { @@ -3364,7 +3436,8 @@ _p9k_deinit_async_pump() { } function _p9k_on_async_message() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} (( ARGC == 1 )) || return local msg='' IFS='' while read -r -t -u $1 msg; do @@ -3373,7 +3446,7 @@ function _p9k_on_async_message() { msg= done _p9k_async_pump_line+=$msg - [[ $__p9k_enabled == 1 && $1 == $_p9k_async_pump_fd ]] && zle && zle .reset-prompt && zle -R + [[ $__p9k_enabled == 1 && $1 == $_p9k_async_pump_fd ]] && _p9k_reset_prompt } function _p9k_async_pump() { @@ -3440,7 +3513,8 @@ function _p9k_async_pump() { } function _p9k_kill_async_pump() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} if [[ $ZSH_SUBSHELL == $_p9k_async_pump_subshell && $$ == $_p9k_async_pump_shell_pid ]]; then _p9k_deinit_async_pump fi @@ -3880,7 +3954,9 @@ _p9k_wrap_zle_widget() { local wrapper=_p9k_wrapper_$widget_$hook eval "function ${(q)wrapper}() { - ${(q)hook} \"\$@\" + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + (( __p9k_enabled )) && ${(q)hook} \"\$@\" (( \$+widgets[${(q)orig}] )) && zle ${(q)orig} -- \"\$@\" }" @@ -3888,22 +3964,18 @@ _p9k_wrap_zle_widget() { } function _p9k_zle_line_finish() { - (( __p9k_enabled )) || return _p9k_line_finished= if (( _p9k_reset_on_line_finish )); then - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} - zle && zle .reset-prompt && zle -R + _p9k_reset_prompt fi } function _p9k_zle_line_pre_redraw() { - (( __p9k_enabled )) || return [[ ${KEYMAP:-} == vicmd ]] || return 0 local region=${${REGION_ACTIVE:-0}/2/1} [[ $region != $_p9k_region_active ]] || return 0 - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} _p9k_region_active=$region - zle && zle .reset-prompt && zle -R + _p9k_reset_prompt } prompt__p9k_internal_nothing() { @@ -3938,7 +4010,11 @@ _p9k_build_gap_post() { _p9k_ret+='${:-"'$exp'"}' style=1 fi - _p9k_ret+=$'$_p9k_rprompt$_p9k_t[$((1+!_p9k_ind))]}:-\n}' + if (( __p9k_ksh_arrays )); then + _p9k_ret+=$'$_p9k_rprompt${_p9k_t[$((!_p9k_ind))]}}:-\n}' + else + _p9k_ret+=$'$_p9k_rprompt${_p9k_t[$((1+!_p9k_ind))]}}:-\n}' + fi [[ -n $style ]] && _p9k_ret+='%b%k%f' } @@ -4128,7 +4204,11 @@ _p9k_init_prompt() { [[ $ruler_char == '.' ]] && local sep=',' || local sep='.' local ruler_len='${$((_p9k_clm-_p9k_ind))/#-*/0}' _p9k_prompt_prefix_left+="\${(pl$sep$ruler_len$sep$sep${(q)ruler_char}$sep)}%k%f" - _p9k_prompt_prefix_left+='$_p9k_t[$((1+!_p9k_ind))]' + if (( __p9k_ksh_arrays )); then + _p9k_prompt_prefix_left+='${_p9k_t[$((!_p9k_ind))]}' + else + _p9k_prompt_prefix_left+='${_p9k_t[$((1+!_p9k_ind))]}' + fi else print -rP -- "%F{red}WARNING!%f %BPOWERLEVEL9K_RULER_CHAR%b is not one character long. Ruler won't be rendered." print -rP -- "Either change the value of %BPOWERLEVEL9K_RULER_CHAR%b or set %BPOWERLEVEL9K_SHOW_RULER=false%b to" @@ -4179,12 +4259,11 @@ _p9k_init_ssh() { } _p9k_must_init() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} local -a param_keys=( ${(o)parameters[(I)(POWERLEVEL9K_*|GITSTATUS_LOG_LEVEL|GITSTATUS_ENABLE_LOGGING|GITSTATUS_DAEMON|GITSTATUS_NUM_THREADS|DEFAULT_USER|ZLE_RPROMPT_INDENT)]}) local IFS param_sig IFS=$'\1' param_sig="${(@)param_keys:/(#b)(*)/$match[1]=\$$match[1]}" - IFS=$'\2' eval "param_sig=x\"$param_sig\"" + IFS=$'\2' eval "param_sig=$__p9k_ksh_arrays$__p9k_sh_glob\"$param_sig\"" [[ -o transient_rprompt ]] && param_sig+=t [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit @@ -4198,8 +4277,6 @@ function _p9k_set_os() { } _p9k_init() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} - _p9k_init_icons _p9k_init_vars _p9k_init_params @@ -4433,7 +4510,8 @@ typeset -gi __p9k_enabled=0 typeset -gi __p9k_configured=0 prompt_powerlevel9k_setup() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} prompt_powerlevel9k_teardown __p9k_enabled=1 add-zsh-hook preexec _p9k_preexec @@ -4441,7 +4519,8 @@ prompt_powerlevel9k_setup() { } prompt_powerlevel9k_teardown() { - emulate -L zsh && setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} add-zsh-hook -D precmd '(_p9k_|powerlevel9k_)*' add-zsh-hook -D preexec '(_p9k_|powerlevel9k_)*' PROMPT='%m%# ' diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 7210a318..f42e6cd3 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -4,7 +4,7 @@ emulate -L zsh setopt noaliases () { -setopt extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} typeset_silent +setopt extended_glob no_prompt_{bang,subst} prompt_percent typeset_silent zmodload zsh/langinfo if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 6e4969d7..f44e6870 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -17,11 +17,11 @@ else local __p9k_restore_aliases=0 fi -typeset -g __p9k_root_dir=${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}} +typeset -g __p9k_root_dir="${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}}" () { emulate -L zsh - setopt no_hist_expand extended_glob no_prompt_{bang,subst} prompt_{cr,percent,sp} + setopt no_hist_expand extended_glob no_prompt_bang no_prompt_subst prompt_percent if (( $+__p9k_sourced )); then prompt_powerlevel9k_setup return -- cgit v1.2.3 From 8c695f9ad7a7be26127a04c6ae06174e9562f0c4 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 20 Sep 2019 11:44:07 +0200 Subject: survive faulty fifos --- internal/p10k.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index eeef6a90..f2add39e 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3438,7 +3438,10 @@ _p9k_deinit_async_pump() { function _p9k_on_async_message() { emulate -L zsh setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} - (( ARGC == 1 )) || return + if (( ARGC != 1 )); then + _p9k_deinit_async_pump + return + fi local msg='' IFS='' while read -r -t -u $1 msg; do [[ $__p9k_enabled == 1 && $1 == $_p9k_async_pump_fd ]] && eval $_p9k_async_pump_line$msg -- cgit v1.2.3 From 15ff12279cb6e63a9b3a1a830269b4773ef08604 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 20 Sep 2019 12:09:47 +0200 Subject: be more lenient towards awful hacks that zplugin users employ --- internal/p10k.zsh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index f2add39e..bf016b1e 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3325,7 +3325,12 @@ _p9k_precmd_impl() { (( __p9k_enabled )) || return - if ! zle; then + if ! zle || [[ -z $_p9k_param_sig ]]; then + if zle; then + __p9k_new_status=0 + __p9k_new_pipestatus=(0) + fi + print -rn "${_p9k_prompt_newline:-}" if (( $+_p9k_real_zle_rprompt_indent )); then @@ -4270,7 +4275,7 @@ _p9k_must_init() { [[ -o transient_rprompt ]] && param_sig+=t [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit - _p9k_param_sig=$param_sig + typeset -g _p9k_param_sig=$param_sig } function _p9k_set_os() { -- cgit v1.2.3 From 28a3cc7445c270d9f42704f9dd9ac293b0d54ee7 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 20 Sep 2019 12:21:08 +0200 Subject: be explicit that `zplugin ice` is not supported --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9ac00f06..4d72509f 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,8 @@ Add `antibody bundle romkatv/powerlevel10k` to your `~/.zshrc`. Add `zplugin light romkatv/powerlevel10k` to your `~/.zshrc`. +The use of `zplugin ice` with Powerlevel10k is neither recommended nor officially supported. + ## Configuration ### For new users -- cgit v1.2.3 From 19eb4893874dd82eabae60083dc7feb41a0902ec Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 20 Sep 2019 13:22:24 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index 8b7e85f2..a10e6ce4 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -72,7 +72,7 @@ zmodload zsh/datetime zsh/system # VCS_STATUS_RESULT=tout and return 0. # -p Don't compute anything that requires reading Git index. If this option is used, # the following parameters will be 0: VCS_STATUS_INDEX_SIZE, -# VCS_STATUS_{NUM,HAS}_{STAGED,UNSTAGED,UNTRACKED}. +# VCS_STATUS_{NUM,HAS}_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED}. # # On success sets VCS_STATUS_RESULT to one of the following values: # @@ -369,12 +369,9 @@ function gitstatus_start() { local setsid=${commands[setsid]:-/usr/local/opt/util-linux/bin/setsid} [[ -x $setsid ]] && setsid=${(q)setsid} || setsid= cmd="cd /; $setsid zsh -dfxc ${(q)cmd} &!" - # We use `zsh -c` instead of plain {} or () to work around bugs in zplug. It hangs on startup. - # Double fork is to daemonize. Some macOS users had issues when gitstatusd was a child process - # of the interactive zsh. For example, https://github.com/romkatv/powerlevel10k/issues/123 - # and https://github.com/romkatv/powerlevel10k/issues/97. Note that on macOS setsid has to - # be installed manually by running `brew install util-linux`. Unfortunately, none of these - # helped to resolve https://github.com/romkatv/powerlevel10k/issues/123. + # We use `zsh -c` instead of plain {} or () to work around bugs in zplug (it hangs on startup). + # Double fork is to daemonize, and so is `setsid`. Note that on macOS `setsid` has to + # be installed manually by running `brew install util-linux`. zsh -dfmxc $cmd <$req_fifo >$resp_fifo 2>$log_file 3<$lock_file &! sysopen -w -o cloexec,sync -u req_fd $req_fifo -- cgit v1.2.3 From e645b79db3521e480aafdfa3e957cc20da7f1e7f Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 20 Sep 2019 14:20:01 +0200 Subject: survive aliased `local` --- config/p10k-classic.zsh | 2 +- config/p10k-lean.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 2041d379..376879d9 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -6,7 +6,7 @@ # for i in {0..255}; do print -Pn "%${i}F${(l:3::0:)i}%f " ${${(M)$((i%8)):#7}:+$'\n'}; done # Temporarily change options. -local p10k_config_opts=() +'builtin' 'local' '-a' 'p10k_config_opts' [[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') [[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') [[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 7ec288d4..d6a7af92 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -6,7 +6,7 @@ # for i in {0..255}; do print -Pn "%${i}F${(l:3::0:)i}%f " ${${(M)$((i%8)):#7}:+$'\n'}; done # Temporarily change options. -local p10k_config_opts=() +'builtin' 'local' '-a' 'p10k_config_opts' [[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') [[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') [[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') -- cgit v1.2.3 From c000eddcff0fb38df2d0137efe24d9d2d900f209 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 20 Sep 2019 14:20:22 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index a10e6ce4..bb9e64e1 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -48,13 +48,12 @@ [[ -o 'interactive' ]] || 'return' -# Temporarily disable aliases. -if [[ -o 'aliases' ]]; then - 'builtin' 'unsetopt' 'aliases' - local _gitstatus_restore_aliases=1 -else - local _gitstatus_restore_aliases=0 -fi +# Temporarily change options. +'builtin' 'local' '-a' '_gitstatus_opts' +[[ ! -o 'aliases' ]] || _gitstatus_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || _gitstatus_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || _gitstatus_opts+=('no_brace_expand') +'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' autoload -Uz add-zsh-hook zmodload zsh/datetime zsh/system @@ -523,5 +522,5 @@ function gitstatus_check() { [[ -n ${(P)${:-GITSTATUS_DAEMON_PID_${1}}} ]] } -(( ! _gitstatus_restore_aliases )) || setopt aliases -'builtin' 'unset' '_gitstatus_restore_aliases' +setopt ${_gitstatus_opts[@]} +'builtin' 'unset' '_gitstatus_opts' -- cgit v1.2.3 From 5f08c5493f78f3dcacc3877d1b8064a58515c48c Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 23 Sep 2019 19:32:39 +0200 Subject: merge improvements from lean to pure --- config/p10k-pure.zsh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/config/p10k-pure.zsh b/config/p10k-pure.zsh index a49653a0..61a2f5a1 100644 --- a/config/p10k-pure.zsh +++ b/config/p10k-pure.zsh @@ -14,13 +14,12 @@ # you like the general style of Pure but not particularly attached to all its quirks, type # `p10k configure` while having Powerlevel10k theme active and pick lean style. -# Temporarily disable aliases. -if [[ -o 'aliases' ]]; then - 'builtin' 'unsetopt' 'aliases' - local p10k_pure_restore_aliases=1 -else - local p10k_pure_restore_aliases=0 -fi +# Temporarily change options. +'builtin' 'local' '-a' 'p10k_config_opts' +[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') +'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' () { emulate -L zsh @@ -101,5 +100,5 @@ fi typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=yellow } -(( ! p10k_pure_restore_aliases )) || setopt aliases -'builtin' 'unset' 'p10k_pure_restore_aliases' +setopt ${p10k_config_opts[@]} +'builtin' 'unset' 'p10k_config_opts' -- cgit v1.2.3 From 4a4f7e1eef960881661276ab382f1bc5a5bb46a3 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 24 Sep 2019 10:17:54 +0200 Subject: new prompt segment: dotnet_version To enable this segment: 1. Run `p10k configure`. 2. Open `~/.p10k.zsh` and search for `dotnet_version`. 3. Uncomment the first occurrence. Fixes #233. --- config/p10k-classic.zsh | 9 +++++++++ config/p10k-lean.zsh | 9 +++++++++ internal/icons.zsh | 5 +++++ internal/p10k.zsh | 21 +++++++++++++++++++-- 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 376879d9..da478513 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -53,6 +53,7 @@ # node_version # node.js version # go_version # go version (https://golang.org) # rust_version # rustc version (https://www.rust-lang.org) + # dotnet_version # .NET version (https://dotnet.microsoft.com) rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rvm # ruby version from rvm (https://rvm.io) kubecontext # current kubernetes context (https://kubernetes.io/) @@ -575,6 +576,14 @@ # Custom icon. # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + ###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################ + # .NET version color. + typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=134 + # Show .NET version only when in a .NET project subdirectory. + typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## # Rbenv color. typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index d6a7af92..fa69892d 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -53,6 +53,7 @@ # node_version # node.js version # go_version # go version (https://golang.org) # rust_version # rustc version (https://www.rust-lang.org) + # dotnet_version # .NET version (https://dotnet.microsoft.com) rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rvm # ruby version from rvm (https://rvm.io) kubecontext # current kubernetes context (https://kubernetes.io/) @@ -554,6 +555,14 @@ # Custom icon. # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + ###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################ + # .NET version color. + typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=134 + # Show .NET version only when in a .NET project subdirectory. + typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## # Rbenv color. typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 diff --git a/internal/icons.zsh b/internal/icons.zsh index 918b0565..36e76fac 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -113,6 +113,7 @@ function _p9k_init_icons() { RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ + DOTNET_ICON '.NET' ) ;; 'awesome-fontconfig') @@ -213,6 +214,7 @@ function _p9k_init_icons() { RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ + DOTNET_ICON '.NET' ) ;; 'awesome-mapped-fontconfig') @@ -317,6 +319,7 @@ function _p9k_init_icons() { RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ + DOTNET_ICON '.NET' ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -418,6 +421,7 @@ function _p9k_init_icons() { RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ + DOTNET_ICON '\uE77F' #  ) ;; *) @@ -518,6 +522,7 @@ function _p9k_init_icons() { RANGER_ICON '\u2B50' # ⭐ TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ + DOTNET_ICON '.NET' ) ;; esac diff --git a/internal/p10k.zsh b/internal/p10k.zsh index bf016b1e..e6a75c15 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1627,7 +1627,7 @@ prompt_load() { } function _p9k_cached_cmd_stdout() { - local cmd=$commands[$1] + local cmd=${commands[$1]:A} [[ -n $cmd ]] || return shift local -H stat @@ -1642,7 +1642,7 @@ function _p9k_cached_cmd_stdout() { } function _p9k_cached_cmd_stdout_stderr() { - local cmd=$commands[$1] + local cmd=${commands[$1]:A} [[ -n $cmd ]] || return shift local -H stat @@ -1844,6 +1844,22 @@ prompt_nodenv() { _p9k_prompt_segment "$0" "black" "green" 'NODE_ICON' 0 '' "${v//\%/%%}" } +prompt_dotnet_version() { + (( $+commands[dotnet] )) || return + + if (( _POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY )); then + local dir=$_p9k_pwd + while true; do + [[ $dir == / ]] && return + [[ -n $dir/(project.json|global.json|packet.dependencies|*.csproj|*.fsproj|*.xproj|*.sln)(#qN^/) ]] && break + dir=${dir:h} + done + fi + + _p9k_cached_cmd_stdout dotnet --version || return + _p9k_prompt_segment "$0" "magenta" "white" 'DOTNET_ICON' 0 '' "$_p9k_ret" +} + ################################################################ # Segment to print a little OS icon prompt_os_icon() { @@ -3821,6 +3837,7 @@ _p9k_init_params() { _p9k_declare -i POWERLEVEL9K_LOAD_WHICH 5 _p9k_declare -b POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -b POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY 0 + _p9k_declare -b POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY 1 _p9k_declare -b POWERLEVEL9K_GO_VERSION_PROJECT_ONLY 1 _p9k_declare -b POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY 1 _p9k_declare -b POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW 0 -- cgit v1.2.3 From 742ed29d93f25e081ad49af3747373bfeb3d6d05 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 24 Sep 2019 10:40:50 +0200 Subject: bold user@hostname when root; add a comment explaining how to always show user@hostname --- config/p10k-classic.zsh | 9 +++++---- config/p10k-lean.zsh | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index da478513..2a3eaaef 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -58,7 +58,7 @@ rvm # ruby version from rvm (https://rvm.io) kubecontext # current kubernetes context (https://kubernetes.io/) terraform # terraform workspace (https://www.terraform.io) - context # user@host + context # user@hostname nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) # vpn_ip # virtual private network indicator @@ -481,7 +481,7 @@ # Custom icon. # typeset -g POWERLEVEL9K_LOAD_VISUAL_IDENTIFIER_EXPANSION='⭐' - ####################################[ context: user@host ]#################################### + ##################################[ context: user@hostname ]################################## # Default context color. typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=180 # Default context format: %n is username, %m is hostname. @@ -489,10 +489,11 @@ # Context color when running with privileges. typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178 - # Context format when running with privileges: %n is username, %m is hostname. - typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%n@%m' + # Context format when running with privileges: bold user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%B%n@%m' # Don't show context unless running with privileges or in SSH. + # Tip: Remove the next line to always show context. typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= # Custom icon. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index fa69892d..8ff392b6 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -58,7 +58,7 @@ rvm # ruby version from rvm (https://rvm.io) kubecontext # current kubernetes context (https://kubernetes.io/) terraform # terraform workspace (https://www.terraform.io) - context # user@host + context # user@hostname nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) # vpn_ip # virtual private network indicator @@ -460,7 +460,7 @@ # Custom icon. # typeset -g POWERLEVEL9K_LOAD_VISUAL_IDENTIFIER_EXPANSION='⭐' - ####################################[ context: user@host ]#################################### + ##################################[ context: user@hostname ]################################## # Default context color. typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=180 # Default context format: %n is username, %m is hostname. @@ -468,10 +468,11 @@ # Context color when running with privileges. typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178 - # Context format when running with privileges: %n is username, %m is hostname. - typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%n@%m' + # Context format when running with privileges: bold user@hostname. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%B%n@%m' # Don't show context unless running with privileges or in SSH. + # Tip: Remove the next line to always show context. typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= # Custom icon. -- cgit v1.2.3 From f6d361d70a8d4a0835363dfa932f33a08cc51b85 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 24 Sep 2019 14:07:28 +0200 Subject: remove old screenshots --- config/p10k-lean.png | Bin 68531 -> 0 bytes demo.png | Bin 13240 -> 0 bytes prompt.png | Bin 6142 -> 0 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 config/p10k-lean.png delete mode 100644 demo.png delete mode 100644 prompt.png diff --git a/config/p10k-lean.png b/config/p10k-lean.png deleted file mode 100644 index 933b781a..00000000 Binary files a/config/p10k-lean.png and /dev/null differ diff --git a/demo.png b/demo.png deleted file mode 100644 index 9a9cf16e..00000000 Binary files a/demo.png and /dev/null differ diff --git a/prompt.png b/prompt.png deleted file mode 100644 index 104b550b..00000000 Binary files a/prompt.png and /dev/null differ -- cgit v1.2.3 From cf00c04d1b9af80eda513657cafc1ea194155b06 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 24 Sep 2019 14:29:21 +0200 Subject: aws: consult AWS_VAULT; hide if "default" --- internal/p10k.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index e6a75c15..c569a408 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -857,8 +857,8 @@ prompt_anaconda() { ################################################################ # AWS Profile prompt_aws() { - local aws_profile="${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}" - if [[ -n "$aws_profile" ]]; then + local aws_profile="${AWS_VAULT:-${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}}" + if [[ "$aws_profile" != (default|) ]]; then _p9k_prompt_segment "$0" red white 'AWS_ICON' 0 '' "${aws_profile//\%/%%}" fi } @@ -1860,6 +1860,7 @@ prompt_dotnet_version() { _p9k_prompt_segment "$0" "magenta" "white" 'DOTNET_ICON' 0 '' "$_p9k_ret" } + ################################################################ # Segment to print a little OS icon prompt_os_icon() { -- cgit v1.2.3 From 5f8ca7259819ae76c256248d3fdf1e3bec91564b Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 24 Sep 2019 14:30:06 +0200 Subject: enable `aws` prompt segment by default --- config/p10k-classic.zsh | 7 +++++++ config/p10k-lean.zsh | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 2a3eaaef..35cfac1e 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -58,6 +58,7 @@ rvm # ruby version from rvm (https://rvm.io) kubecontext # current kubernetes context (https://kubernetes.io/) terraform # terraform workspace (https://www.terraform.io) + aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) context # user@hostname nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) @@ -609,6 +610,12 @@ # Custom icon. # typeset -g POWERLEVEL9K_TERRAFORM_VISUAL_IDENTIFIER_EXPANSION='⭐' + #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]# + # AWS profile color. + typeset -g POWERLEVEL9K_AWS_FOREGROUND=208 + # Custom icon. + # typeset -g POWERLEVEL9K_AWS_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# # Kubernetes context classes for the purpose of using different colors, icons and expansions with # different contexts. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 8ff392b6..96aba8e3 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -58,6 +58,7 @@ rvm # ruby version from rvm (https://rvm.io) kubecontext # current kubernetes context (https://kubernetes.io/) terraform # terraform workspace (https://www.terraform.io) + aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) context # user@hostname nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) @@ -669,6 +670,12 @@ # Custom icon. # typeset -g POWERLEVEL9K_TERRAFORM_VISUAL_IDENTIFIER_EXPANSION='⭐' + #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]# + # AWS profile color. + typeset -g POWERLEVEL9K_AWS_FOREGROUND=208 + # Custom icon. + # typeset -g POWERLEVEL9K_AWS_VISUAL_IDENTIFIER_EXPANSION='⭐' + ###############################[ public_ip: public IP address ]############################### # Public IP color. typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=94 -- cgit v1.2.3 From add0875137fc45a065064f8be124db2a37e45876 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 25 Sep 2019 09:22:34 +0200 Subject: bug fix: set _p9k_keymap whenever vi_mode is in use fixes #232 --- internal/p10k.zsh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index c569a408..240e4bdc 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -4183,7 +4183,7 @@ _p9k_init_prompt() { _p9k_prompt_suffix_left='${${COLUMNS::=$_p9k_clm}+}' _p9k_prompt_suffix_right='${${COLUMNS::=$_p9k_clm}+}' - if _p9k_segment_in_use vi_mode && (( $+_POWERLEVEL9K_VI_VISUAL_MODE_STRING )) || _p9k_segment_in_use prompt_char; then + if _p9k_segment_in_use vi_mode || _p9k_segment_in_use prompt_char; then _p9k_prompt_prefix_left+='${${_p9k_keymap::=${KEYMAP:-$_p9k_keymap}}+}' fi if { _p9k_segment_in_use vi_mode && (( $+_POWERLEVEL9K_VI_OVERWRITE_MODE_STRING )) } || @@ -4490,6 +4490,10 @@ _p9k_init() { _p9k_init_async_pump + if _p9k_segment_in_use vi_mode || _p9k_segment_in_use prompt_char; then + _p9k_wrap_zle_widget zle-keymap-select _p9k_zle_keymap_select + fi + if _p9k_segment_in_use vi_mode && (( $+_POWERLEVEL9K_VI_VISUAL_MODE_STRING )) || _p9k_segment_in_use prompt_char; then _p9k_wrap_zle_widget zle-line-pre-redraw _p9k_zle_line_pre_redraw fi @@ -4518,8 +4522,6 @@ _p9k_init() { fi fi - _p9k_wrap_zle_widget zle-keymap-select _p9k_zle_keymap_select - if [[ -n $_POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]] && _p9k_segment_in_use public_ip || _p9k_segment_in_use ip || _p9k_segment_in_use vpn_ip; then _p9k_fetch_iface=1 -- cgit v1.2.3 From da72685c8b954ddb5e03e4c62a4ff0197f6f6326 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 2 Oct 2019 15:29:23 +0200 Subject: speed up startup by about 3x --- internal/p10k.zsh | 174 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 115 insertions(+), 59 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 240e4bdc..20685b32 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1218,6 +1218,7 @@ prompt_dir() { fi local -i fake_first=0 expand=0 + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale local delim=${_POWERLEVEL9K_SHORTEN_DELIMITER-$'\u2026'} local -i shortenlen=${_POWERLEVEL9K_SHORTEN_DIR_LENGTH:--1} @@ -2744,7 +2745,7 @@ function _p9k_vcs_gitstatus() { prompt_vcs() { local -a backends=($_POWERLEVEL9K_VCS_BACKENDS) - if (( ${backends[(I)git]} && !_POWERLEVEL9K_DISABLE_GITSTATUS )) && _p9k_vcs_gitstatus; then + if (( ${backends[(I)git]} && !_p9k_gitstatus_disabled )) && _p9k_vcs_gitstatus; then _p9k_vcs_render && return backends=(${backends:#git}) fi @@ -3336,12 +3337,38 @@ _p9k_save_status() { fi } +function _p9k_dump_state() { + local dir=${XDG_CACHE_HOME:-$HOME/.cache} + [[ -d $dir ]] || mkdir -pm 0700 $dir || return + [[ -w $dir && -z $dir(#qNR) ]] || return + local tmp=$dir/p10k-state-$USER.zsh.$$-$EPOCHREALTIME-$RANDOM + local -i fd + sysopen -a -m 600 -o creat,trunc -u fd $tmp || return + { + print -r -- "# $_p9k_param_sig" >&$fd || return + typeset -pm '(_POWERLEVEL9K_|_p9k_)*~(_p9k_async_pump*)' >&$fd || return + } always { + exec {fd}>&- + } + zf_mv -f $tmp $dir/p10k-state-$USER.zsh +} + +function _p9k_restore_state() { + local file=${XDG_CACHE_HOME:-$HOME/.cache}/p10k-state-$USER.zsh + [[ -r $file && -z $file(#qNW) ]] || return + local content && content="$(<$file)" + [[ $content == '# '$_p9k_param_sig$'\n'* ]] || return + eval $content +} + _p9k_precmd_impl() { emulate -L zsh setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} (( __p9k_enabled )) || return + local -i init=0 + if ! zle || [[ -z $_p9k_param_sig ]]; then if zle; then __p9k_new_status=0 @@ -3377,6 +3404,7 @@ _p9k_precmd_impl() { fi fi _p9k_init + local -i init=1 fi _p9k_timer_end=EPOCHREALTIME @@ -3399,6 +3427,8 @@ _p9k_precmd_impl() { _p9k_refresh_reason=precmd _p9k_set_prompt _p9k_refresh_reason='' + + (( init )) && _p9k_dump_state } _p9k_precmd() { @@ -3554,8 +3584,9 @@ _p9k_init_async_pump() { _p9k_start_async_pump() { setopt err_return no_bg_nice - _p9k_async_pump_lock="$(mktemp ${TMPDIR:-/tmp}/p9k-$$-async-pump-lock.XXXXXXXXXX)" - _p9k_async_pump_fifo="$(mktemp -u ${TMPDIR:-/tmp}/p9k-$$-async-pump-fifo.XXXXXXXXXX)" + _p9k_async_pump_lock=${TMPDIR:-/tmp}/p9k-$$-async-pump-lock.$EPOCHREALTIME.$RANDOM + _p9k_async_pump_fifo=${TMPDIR:-/tmp}/p9k-$$-async-pump-fifo.$EPOCHREALTIME.$RANDOM + echo -n >$_p9k_async_pump_lock mkfifo $_p9k_async_pump_fifo sysopen -rw -o cloexec,sync -u _p9k_async_pump_fd $_p9k_async_pump_fifo zle -F $_p9k_async_pump_fd _p9k_on_async_message @@ -3690,6 +3721,10 @@ _p9k_init_vars() { typeset -gi _p9k_fetch_iface typeset -g _p9k_keymap typeset -g _p9k_zle_state + typeset -g _p9k_uname + typeset -g _p9k_uname_o + typeset -g _p9k_uname_m + typeset -gi _p9k_gitstatus_disabled typeset -g P9K_VISUAL_IDENTIFIER typeset -g P9K_CONTENT @@ -4289,7 +4324,7 @@ _p9k_must_init() { ${(o)parameters[(I)(POWERLEVEL9K_*|GITSTATUS_LOG_LEVEL|GITSTATUS_ENABLE_LOGGING|GITSTATUS_DAEMON|GITSTATUS_NUM_THREADS|DEFAULT_USER|ZLE_RPROMPT_INDENT)]}) local IFS param_sig IFS=$'\1' param_sig="${(@)param_keys:/(#b)(*)/$match[1]=\$$match[1]}" - IFS=$'\2' eval "param_sig=$__p9k_ksh_arrays$__p9k_sh_glob\"$param_sig\"" + IFS=$'\2' eval "param_sig=0.$USER.$P9K_SSH$__p9k_ksh_arrays$__p9k_sh_glob\"$param_sig\"" [[ -o transient_rprompt ]] && param_sig+=t [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit @@ -4302,17 +4337,19 @@ function _p9k_set_os() { _p9k_os_icon=$_p9k_ret } -_p9k_init() { +function _p9k_init_cacheable() { _p9k_init_icons - _p9k_init_vars _p9k_init_params _p9k_init_prompt - local uname="$(uname)" - if [[ $uname == Linux && "$(uname -o 2>/dev/null)" == Android ]]; then + _p9k_uname="$(uname)" + [[ $_p9k_uname == Linux ]] && _p9k_uname_o="$(uname -o 2>/dev/null)" + _p9k_uname_m="$(uname -m)" + + if [[ $_p9k_uname == Linux && _p9k_uname_o == Android ]]; then _p9k_set_os Android ANDROID_ICON else - case $uname in + case $_p9k_uname in SunOS) _p9k_set_os Solaris SUNOS_ICON;; Darwin) _p9k_set_os OSX APPLE_ICON;; CYGWIN_NT-* | MSYS_NT-*) _p9k_set_os Windows WINDOWS_ICON;; @@ -4394,12 +4431,60 @@ _p9k_init() { fi done + case $_p9k_os in + OSX) (( $+commands[sysctl] )) && _p9k_num_cpus="$(sysctl -n hw.logicalcpu 2>/dev/null)";; + BSD) (( $+commands[sysctl] )) && _p9k_num_cpus="$(sysctl -n hw.ncpu 2>/dev/null)";; + *) (( $+commands[nproc] )) && _p9k_num_cpus="$(nproc 2>/dev/null)";; + esac + + if _p9k_segment_in_use dir; then + if (( $+_POWERLEVEL9K_DIR_CLASSES )); then + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale + local -i i=3 + for ((; i <= $#_POWERLEVEL9K_DIR_CLASSES; i+=3)); do + _POWERLEVEL9K_DIR_CLASSES[i]=${(g::)_POWERLEVEL9K_DIR_CLASSES[i]} + done + else + typeset -ga _POWERLEVEL9K_DIR_CLASSES=() + _p9k_get_icon prompt_dir_ETC ETC_ICON + _POWERLEVEL9K_DIR_CLASSES+=('/etc|/etc/*' ETC "$_p9k_ret") + _p9k_get_icon prompt_dir_HOME HOME_ICON + _POWERLEVEL9K_DIR_CLASSES+=('~' HOME "$_p9k_ret") + _p9k_get_icon prompt_dir_HOME_SUBFOLDER HOME_SUB_ICON + _POWERLEVEL9K_DIR_CLASSES+=('~/*' HOME_SUBFOLDER "$_p9k_ret") + _p9k_get_icon prompt_dir_DEFAULT FOLDER_ICON + _POWERLEVEL9K_DIR_CLASSES+=('*' DEFAULT "$_p9k_ret") + fi + fi + + if _p9k_segment_in_use status; then + typeset -g _p9k_exitcode2str=({0..255}) + local -i i=2 + if (( !_POWERLEVEL9K_STATUS_HIDE_SIGNAME )); then + for ((; i <= $#signals; ++i)); do + local sig=$signals[i] + (( _POWERLEVEL9K_STATUS_VERBOSE_SIGNAME )) && sig="SIG${sig}($((i-1)))" + _p9k_exitcode2str[$((128+i))]=$sig + done + fi + fi + + if [[ -n $_POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]] && _p9k_segment_in_use public_ip || + _p9k_segment_in_use ip || _p9k_segment_in_use vpn_ip; then + _p9k_fetch_iface=1 + fi +} + +_p9k_init() { + _p9k_init_vars + _p9k_restore_state || _p9k_init_cacheable + if _p9k_segment_in_use vcs; then _p9k_vcs_info_init - local gitstatus_dir=${_POWERLEVEL9K_GITSTATUS_DIR:-${__p9k_root_dir}/gitstatus} if [[ $_POWERLEVEL9K_DISABLE_GITSTATUS == 0 && -n $_POWERLEVEL9K_VCS_BACKENDS[(r)git] ]]; then - if [[ -z $GITSTATUS_DAEMON && "$(uname -m)" == i686 && -z $gitstatus_dir/bin/*-i686(-static|)(#qN) ]]; then - _POWERLEVEL9K_DISABLE_GITSTATUS=1 + local gitstatus_dir=${_POWERLEVEL9K_GITSTATUS_DIR:-${__p9k_root_dir}/gitstatus} + if [[ -z $GITSTATUS_DAEMON && $_p9k_uname == i686 && -z $gitstatus_dir/bin/*-i686(-static|)(#qN) ]]; then + _p9k_gitstatus_disabled=1 >&2 echo -E - "${(%):-[%1FERROR%f]: %BPowerlevel10k%b is unable to use %Bgitstatus%b. Git prompt will be slow.}" >&2 echo -E - "" >&2 echo -E - "${(%):-Reason: There is no %Bgitstatusd%b binary for i686 (32-bit Intel architecture).}" @@ -4431,6 +4516,19 @@ _p9k_init() { >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}" >&2 echo -E - "${(%):- * Git prompt will be %Bfast%b.}" else + local -i daemon threads + if (( ! $+GITSTATUS_DAEMON )); then + local os=$_p9k_uname + [[ $_p9k_uname == Linux && _p9k_uname_o == Android ]] && os=Android + typeset -g GITSTATUS_DAEMON=$gitstatus_dir/bin/gitstatusd-${os:l}-${_p9k_uname_m:l} + daemon=1 + fi + if (( ! $+GITSTATUS_NUM_THREADS )); then + typeset -gi GITSTATUS_NUM_THREADS=$(( _p9k_num_cpus * 2 )) + (( GITSTATUS_NUM_THREADS > 0 )) || GITSTATUS_NUM_THREADS=8 + (( GITSTATUS_NUM_THREADS <= 32 )) || GITSTATUS_NUM_THREADS=32 + threads=1 + fi source $gitstatus_dir/gitstatus.plugin.zsh gitstatus_start \ -s $_POWERLEVEL9K_VCS_STAGED_MAX_NUM \ @@ -4438,7 +4536,9 @@ _p9k_init() { -d $_POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM \ -c $_POWERLEVEL9K_VCS_CONFLICTED_MAX_NUM \ -m $_POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY \ - POWERLEVEL9K || _POWERLEVEL9K_DISABLE_GITSTATUS=1 + POWERLEVEL9K || _p9k_gitstatus_disabled=1 + (( daemon )) && unset GITSTATUS_DAEMON + (( threads )) && unset GITSTATUS_NUM_THREADS fi fi fi @@ -4460,36 +4560,6 @@ _p9k_init() { fi fi - if _p9k_segment_in_use load; then - case $_p9k_os in - OSX) (( $+commands[sysctl] )) && _p9k_num_cpus="$(sysctl -n hw.logicalcpu 2>/dev/null)";; - BSD) (( $+commands[sysctl] )) && _p9k_num_cpus="$(sysctl -n hw.ncpu 2>/dev/null)";; - *) (( $+commands[nproc] )) && _p9k_num_cpus="$(nproc 2>/dev/null)";; - esac - fi - - if _p9k_segment_in_use dir; then - if (( $+_POWERLEVEL9K_DIR_CLASSES )); then - [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale - local -i i=3 - for ((; i <= $#_POWERLEVEL9K_DIR_CLASSES; i+=3)); do - _POWERLEVEL9K_DIR_CLASSES[i]=${(g::)_POWERLEVEL9K_DIR_CLASSES[i]} - done - else - typeset -ga _POWERLEVEL9K_DIR_CLASSES=() - _p9k_get_icon prompt_dir_ETC ETC_ICON - _POWERLEVEL9K_DIR_CLASSES+=('/etc|/etc/*' ETC "$_p9k_ret") - _p9k_get_icon prompt_dir_HOME HOME_ICON - _POWERLEVEL9K_DIR_CLASSES+=('~' HOME "$_p9k_ret") - _p9k_get_icon prompt_dir_HOME_SUBFOLDER HOME_SUB_ICON - _POWERLEVEL9K_DIR_CLASSES+=('~/*' HOME_SUBFOLDER "$_p9k_ret") - _p9k_get_icon prompt_dir_DEFAULT FOLDER_ICON - _POWERLEVEL9K_DIR_CLASSES+=('*' DEFAULT "$_p9k_ret") - fi - fi - - _p9k_init_async_pump - if _p9k_segment_in_use vi_mode || _p9k_segment_in_use prompt_char; then _p9k_wrap_zle_widget zle-keymap-select _p9k_zle_keymap_select fi @@ -4510,22 +4580,7 @@ _p9k_init() { print -rP -- 'Either install %F{green}jq%f or change the value of %BPOWERLEVEL9K_SHORTEN_STRATEGY%b.' fi - if _p9k_segment_in_use status; then - typeset -g _p9k_exitcode2str=({0..255}) - local -i i=2 - if (( !_POWERLEVEL9K_STATUS_HIDE_SIGNAME )); then - for ((; i <= $#signals; ++i)); do - local sig=$signals[i] - (( _POWERLEVEL9K_STATUS_VERBOSE_SIGNAME )) && sig="SIG${sig}($((i-1)))" - _p9k_exitcode2str[$((128+i))]=$sig - done - fi - fi - - if [[ -n $_POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]] && _p9k_segment_in_use public_ip || - _p9k_segment_in_use ip || _p9k_segment_in_use vpn_ip; then - _p9k_fetch_iface=1 - fi + _p9k_init_async_pump } _p9k_deinit() { @@ -4727,6 +4782,7 @@ zmodload zsh/mathfunc zmodload zsh/system zmodload -F zsh/stat b:zstat zmodload -F zsh/net/socket b:zsocket +zmodload -F zsh/files b:zf_mv _p9k_init_ssh prompt_powerlevel9k_setup -- cgit v1.2.3 From 47cb0b26d8e993f759a0d11160bec1e25619b847 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 2 Oct 2019 15:30:10 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 55 +++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index bb9e64e1..55d18a89 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -19,32 +19,34 @@ # # Example: Start gitstatusd, send it a request, wait for response and print it. # -# source gitstatus.plugin.zsh +# source ~/gitstatus/gitstatus.plugin.zsh # gitstatus_start MY # gitstatus_query -d $PWD MY -# set | egrep '^VCS_STATUS' +# typeset -m 'VCS_STATUS_*' # # Output: # # VCS_STATUS_ACTION='' -# VCS_STATUS_COMMIT=6e86ec135bf77875e222463cbac8ef72a7e8d823 +# VCS_STATUS_COMMIT=c000eddcff0fb38df2d0137efe24d9d2d900f209 # VCS_STATUS_COMMITS_AHEAD=0 # VCS_STATUS_COMMITS_BEHIND=0 -# VCS_STATUS_INDEX_SIZE=42 -# VCS_STATUS_NUM_STAGED=0 -# VCS_STATUS_NUM_UNSTAGED=2 -# VCS_STATUS_NUM_UNTRACKED=3 +# VCS_STATUS_HAS_CONFLICTED=0 # VCS_STATUS_HAS_STAGED=0 # VCS_STATUS_HAS_UNSTAGED=1 # VCS_STATUS_HAS_UNTRACKED=1 +# VCS_STATUS_INDEX_SIZE=33 # VCS_STATUS_LOCAL_BRANCH=master +# VCS_STATUS_NUM_CONFLICTED=0 +# VCS_STATUS_NUM_STAGED=0 +# VCS_STATUS_NUM_UNSTAGED=1 +# VCS_STATUS_NUM_UNTRACKED=1 # VCS_STATUS_REMOTE_BRANCH=master # VCS_STATUS_REMOTE_NAME=origin # VCS_STATUS_REMOTE_URL=git@github.com:romkatv/powerlevel10k.git # VCS_STATUS_RESULT=ok-sync # VCS_STATUS_STASHES=0 # VCS_STATUS_TAG='' -# VCS_STATUS_WORKDIR=/home/romka/.oh-my-zsh/custom/themes/powerlevel10k +# VCS_STATUS_WORKDIR=/home/romka/powerlevel10k [[ -o 'interactive' ]] || 'return' @@ -57,6 +59,7 @@ autoload -Uz add-zsh-hook zmodload zsh/datetime zsh/system +zmodload -F zsh/files b:zf_rm # Retrives status of a git repo from a directory under its working tree. # @@ -307,30 +310,34 @@ function gitstatus_start() { [[ -n $log_level || ${GITSTATUS_ENABLE_LOGGING:-0} != 1 ]] || log_level=INFO [[ -z $log_level ]] || { - xtrace_file=$(mktemp "${TMPDIR:-/tmp}"/gitstatus.$$.xtrace.XXXXXXXXXX) + xtrace_file=${TMPDIR:-/tmp}/gitstatus.$$.xtrace.$EPOCHREALTIME.$RANDOM typeset -g GITSTATUS_XTRACE_${name}=$xtrace_file exec {stderr_fd}>&2 2>$xtrace_file setopt xtrace } - local os && os=$(uname -s) && [[ -n $os ]] - [[ $os != Linux || $(uname -o) != Android ]] || os=Android - local arch && arch=$(uname -m) && [[ -n $arch ]] - - local daemon=${GITSTATUS_DAEMON:-$dir/bin/gitstatusd-${os:l}-${arch:l}} + local daemon=${GITSTATUS_DAEMON:-} + [[ -n $daemon ]] || { + local os arch + os="$(uname -s)" + [[ -n $os ]] + [[ $os != Linux || "$(uname -o)" != Android ]] || os=Android + arch="$(uname -m)" + [[ -n $arch ]] + daemon=$dir/bin/gitstatusd-${os:l}-${arch:l} + } [[ -x $daemon ]] - lock_file=$(mktemp "${TMPDIR:-/tmp}"/gitstatus.$$.lock.XXXXXXXXXX) + lock_file=${TMPDIR:-/tmp}/gitstatus.$$.lock.$EPOCHREALTIME.$RANDOM + echo -n >$lock_file zsystem flock -f lock_fd $lock_file - req_fifo=$(mktemp -u "${TMPDIR:-/tmp}"/gitstatus.$$.pipe.req.XXXXXXXXXX) - mkfifo $req_fifo - - resp_fifo=$(mktemp -u "${TMPDIR:-/tmp}"/gitstatus.$$.pipe.resp.XXXXXXXXXX) - mkfifo $resp_fifo + req_fifo=${TMPDIR:-/tmp}/gitstatus.$$.req.$EPOCHREALTIME.$RANDOM + resp_fifo=${TMPDIR:-/tmp}/gitstatus.$$.resp.$EPOCHREALTIME.$RANDOM + mkfifo $req_fifo $resp_fifo [[ -n $log_level ]] && - log_file=$(mktemp "${TMPDIR:-/tmp}"/gitstatus.$$.daemon-log.XXXXXXXXXX) || + log_file=${TMPDIR:-/tmp}/gitstatus.$$.daemon-log.$EPOCHREALTIME.$RANDOM || log_file=/dev/null typeset -g GITSTATUS_DAEMON_LOG_${name}=$log_file @@ -359,9 +366,7 @@ function gitstatus_start() { local cmd=" echo \$\$ ${(q)daemon} $daemon_args - if [[ \$? != (0|10) && \$? -le 128 && - -z ${(q)GITSTATUS_DAEMON:-} && - -f ${(q)daemon}-static ]]; then + if [[ \$? != (0|10) && \$? -le 128 && -f ${(q)daemon}-static ]]; then ${(q)daemon}-static $daemon_args fi echo -nE $'bye\x1f0\x1e'" @@ -378,7 +383,7 @@ function gitstatus_start() { read -u $resp_fd daemon_pid - rm -f $req_fifo $resp_fifo $lock_file + zf_rm -f $req_fifo $resp_fifo $lock_file function _gitstatus_process_response_${name}() { local name=${${(%):-%N}#_gitstatus_process_response_} -- cgit v1.2.3 From 4f3e6c5a8e4980f5d6e1e7ffed9ab34e5fa55356 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 2 Oct 2019 16:39:41 +0200 Subject: update docs: powerlevel10k is no longer slow to load (still not fast though) --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4d72509f..94674687 100644 --- a/README.md +++ b/README.md @@ -262,8 +262,9 @@ prompt latency when using Powerlevel10k, please ### Is Powerlevel10k fast to load? -The short answer is no. The amount of time it takes for Powerlevel10k to render the first prompt -is in the same ballpark as for Powerlevel9k. +The amount of time it takes for Powerlevel10k to render the first prompt is singnificantly higher +than for the subsequent prompts. In comparison to other ZSH themes, Powerlevel10k loading latency +is unremarkable. Powerlevel10k is neither fast nor slow to load. Time to first prompt can be measured with the following benchmark: @@ -271,13 +272,13 @@ Time to first prompt can be measured with the following benchmark: time (repeat 100 zsh -dfis <<< 'source ~/powerlevel10k/powerlevel10k.zsh-theme') ``` -On the same machine as in the [prompt benchmark](#is-it-really-fast) this results in 147 ms per +On the same machine as in the [prompt benchmark](#is-it-really-fast) this results in 59.7 ms per invocation when executed in a small git repository (I used the `powerlevel10k` repo itself). For -comparison, the same benchmark gives 170 ms for powerlevel9k/master and 505 ms for +comparison, the same benchmark gives 171 ms for powerlevel9k/master and 505 ms for powerlevel9k/next. -If your workflow requires that you open a terminal tab, type a command or two and close the tab, -Powerlevel10k isn't the best choice. Powerlevel10k is optimized for long-lived ZSH sessions. +*Note: Powerlevel10k startup latency can be reduced by about 15% by compiling its source files with +`zcompile`.* ### Does Powerlevel10k always render exactly the same prompt as Powerlevel9k given the same config? -- cgit v1.2.3 From e5e6249ffd592695ccdb6030a42d3664b3dde480 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 2 Oct 2019 19:40:50 +0200 Subject: Revert "speed up startup by about 3x" This reverts commit da72685c8b954ddb5e03e4c62a4ff0197f6f6326. Something broke. See #242. Will debug this and roll forward later. --- internal/p10k.zsh | 174 ++++++++++++++++++------------------------------------ 1 file changed, 59 insertions(+), 115 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 20685b32..240e4bdc 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1218,7 +1218,6 @@ prompt_dir() { fi local -i fake_first=0 expand=0 - [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale local delim=${_POWERLEVEL9K_SHORTEN_DELIMITER-$'\u2026'} local -i shortenlen=${_POWERLEVEL9K_SHORTEN_DIR_LENGTH:--1} @@ -2745,7 +2744,7 @@ function _p9k_vcs_gitstatus() { prompt_vcs() { local -a backends=($_POWERLEVEL9K_VCS_BACKENDS) - if (( ${backends[(I)git]} && !_p9k_gitstatus_disabled )) && _p9k_vcs_gitstatus; then + if (( ${backends[(I)git]} && !_POWERLEVEL9K_DISABLE_GITSTATUS )) && _p9k_vcs_gitstatus; then _p9k_vcs_render && return backends=(${backends:#git}) fi @@ -3337,38 +3336,12 @@ _p9k_save_status() { fi } -function _p9k_dump_state() { - local dir=${XDG_CACHE_HOME:-$HOME/.cache} - [[ -d $dir ]] || mkdir -pm 0700 $dir || return - [[ -w $dir && -z $dir(#qNR) ]] || return - local tmp=$dir/p10k-state-$USER.zsh.$$-$EPOCHREALTIME-$RANDOM - local -i fd - sysopen -a -m 600 -o creat,trunc -u fd $tmp || return - { - print -r -- "# $_p9k_param_sig" >&$fd || return - typeset -pm '(_POWERLEVEL9K_|_p9k_)*~(_p9k_async_pump*)' >&$fd || return - } always { - exec {fd}>&- - } - zf_mv -f $tmp $dir/p10k-state-$USER.zsh -} - -function _p9k_restore_state() { - local file=${XDG_CACHE_HOME:-$HOME/.cache}/p10k-state-$USER.zsh - [[ -r $file && -z $file(#qNW) ]] || return - local content && content="$(<$file)" - [[ $content == '# '$_p9k_param_sig$'\n'* ]] || return - eval $content -} - _p9k_precmd_impl() { emulate -L zsh setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} (( __p9k_enabled )) || return - local -i init=0 - if ! zle || [[ -z $_p9k_param_sig ]]; then if zle; then __p9k_new_status=0 @@ -3404,7 +3377,6 @@ _p9k_precmd_impl() { fi fi _p9k_init - local -i init=1 fi _p9k_timer_end=EPOCHREALTIME @@ -3427,8 +3399,6 @@ _p9k_precmd_impl() { _p9k_refresh_reason=precmd _p9k_set_prompt _p9k_refresh_reason='' - - (( init )) && _p9k_dump_state } _p9k_precmd() { @@ -3584,9 +3554,8 @@ _p9k_init_async_pump() { _p9k_start_async_pump() { setopt err_return no_bg_nice - _p9k_async_pump_lock=${TMPDIR:-/tmp}/p9k-$$-async-pump-lock.$EPOCHREALTIME.$RANDOM - _p9k_async_pump_fifo=${TMPDIR:-/tmp}/p9k-$$-async-pump-fifo.$EPOCHREALTIME.$RANDOM - echo -n >$_p9k_async_pump_lock + _p9k_async_pump_lock="$(mktemp ${TMPDIR:-/tmp}/p9k-$$-async-pump-lock.XXXXXXXXXX)" + _p9k_async_pump_fifo="$(mktemp -u ${TMPDIR:-/tmp}/p9k-$$-async-pump-fifo.XXXXXXXXXX)" mkfifo $_p9k_async_pump_fifo sysopen -rw -o cloexec,sync -u _p9k_async_pump_fd $_p9k_async_pump_fifo zle -F $_p9k_async_pump_fd _p9k_on_async_message @@ -3721,10 +3690,6 @@ _p9k_init_vars() { typeset -gi _p9k_fetch_iface typeset -g _p9k_keymap typeset -g _p9k_zle_state - typeset -g _p9k_uname - typeset -g _p9k_uname_o - typeset -g _p9k_uname_m - typeset -gi _p9k_gitstatus_disabled typeset -g P9K_VISUAL_IDENTIFIER typeset -g P9K_CONTENT @@ -4324,7 +4289,7 @@ _p9k_must_init() { ${(o)parameters[(I)(POWERLEVEL9K_*|GITSTATUS_LOG_LEVEL|GITSTATUS_ENABLE_LOGGING|GITSTATUS_DAEMON|GITSTATUS_NUM_THREADS|DEFAULT_USER|ZLE_RPROMPT_INDENT)]}) local IFS param_sig IFS=$'\1' param_sig="${(@)param_keys:/(#b)(*)/$match[1]=\$$match[1]}" - IFS=$'\2' eval "param_sig=0.$USER.$P9K_SSH$__p9k_ksh_arrays$__p9k_sh_glob\"$param_sig\"" + IFS=$'\2' eval "param_sig=$__p9k_ksh_arrays$__p9k_sh_glob\"$param_sig\"" [[ -o transient_rprompt ]] && param_sig+=t [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit @@ -4337,19 +4302,17 @@ function _p9k_set_os() { _p9k_os_icon=$_p9k_ret } -function _p9k_init_cacheable() { +_p9k_init() { _p9k_init_icons + _p9k_init_vars _p9k_init_params _p9k_init_prompt - _p9k_uname="$(uname)" - [[ $_p9k_uname == Linux ]] && _p9k_uname_o="$(uname -o 2>/dev/null)" - _p9k_uname_m="$(uname -m)" - - if [[ $_p9k_uname == Linux && _p9k_uname_o == Android ]]; then + local uname="$(uname)" + if [[ $uname == Linux && "$(uname -o 2>/dev/null)" == Android ]]; then _p9k_set_os Android ANDROID_ICON else - case $_p9k_uname in + case $uname in SunOS) _p9k_set_os Solaris SUNOS_ICON;; Darwin) _p9k_set_os OSX APPLE_ICON;; CYGWIN_NT-* | MSYS_NT-*) _p9k_set_os Windows WINDOWS_ICON;; @@ -4431,60 +4394,12 @@ function _p9k_init_cacheable() { fi done - case $_p9k_os in - OSX) (( $+commands[sysctl] )) && _p9k_num_cpus="$(sysctl -n hw.logicalcpu 2>/dev/null)";; - BSD) (( $+commands[sysctl] )) && _p9k_num_cpus="$(sysctl -n hw.ncpu 2>/dev/null)";; - *) (( $+commands[nproc] )) && _p9k_num_cpus="$(nproc 2>/dev/null)";; - esac - - if _p9k_segment_in_use dir; then - if (( $+_POWERLEVEL9K_DIR_CLASSES )); then - [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale - local -i i=3 - for ((; i <= $#_POWERLEVEL9K_DIR_CLASSES; i+=3)); do - _POWERLEVEL9K_DIR_CLASSES[i]=${(g::)_POWERLEVEL9K_DIR_CLASSES[i]} - done - else - typeset -ga _POWERLEVEL9K_DIR_CLASSES=() - _p9k_get_icon prompt_dir_ETC ETC_ICON - _POWERLEVEL9K_DIR_CLASSES+=('/etc|/etc/*' ETC "$_p9k_ret") - _p9k_get_icon prompt_dir_HOME HOME_ICON - _POWERLEVEL9K_DIR_CLASSES+=('~' HOME "$_p9k_ret") - _p9k_get_icon prompt_dir_HOME_SUBFOLDER HOME_SUB_ICON - _POWERLEVEL9K_DIR_CLASSES+=('~/*' HOME_SUBFOLDER "$_p9k_ret") - _p9k_get_icon prompt_dir_DEFAULT FOLDER_ICON - _POWERLEVEL9K_DIR_CLASSES+=('*' DEFAULT "$_p9k_ret") - fi - fi - - if _p9k_segment_in_use status; then - typeset -g _p9k_exitcode2str=({0..255}) - local -i i=2 - if (( !_POWERLEVEL9K_STATUS_HIDE_SIGNAME )); then - for ((; i <= $#signals; ++i)); do - local sig=$signals[i] - (( _POWERLEVEL9K_STATUS_VERBOSE_SIGNAME )) && sig="SIG${sig}($((i-1)))" - _p9k_exitcode2str[$((128+i))]=$sig - done - fi - fi - - if [[ -n $_POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]] && _p9k_segment_in_use public_ip || - _p9k_segment_in_use ip || _p9k_segment_in_use vpn_ip; then - _p9k_fetch_iface=1 - fi -} - -_p9k_init() { - _p9k_init_vars - _p9k_restore_state || _p9k_init_cacheable - if _p9k_segment_in_use vcs; then _p9k_vcs_info_init + local gitstatus_dir=${_POWERLEVEL9K_GITSTATUS_DIR:-${__p9k_root_dir}/gitstatus} if [[ $_POWERLEVEL9K_DISABLE_GITSTATUS == 0 && -n $_POWERLEVEL9K_VCS_BACKENDS[(r)git] ]]; then - local gitstatus_dir=${_POWERLEVEL9K_GITSTATUS_DIR:-${__p9k_root_dir}/gitstatus} - if [[ -z $GITSTATUS_DAEMON && $_p9k_uname == i686 && -z $gitstatus_dir/bin/*-i686(-static|)(#qN) ]]; then - _p9k_gitstatus_disabled=1 + if [[ -z $GITSTATUS_DAEMON && "$(uname -m)" == i686 && -z $gitstatus_dir/bin/*-i686(-static|)(#qN) ]]; then + _POWERLEVEL9K_DISABLE_GITSTATUS=1 >&2 echo -E - "${(%):-[%1FERROR%f]: %BPowerlevel10k%b is unable to use %Bgitstatus%b. Git prompt will be slow.}" >&2 echo -E - "" >&2 echo -E - "${(%):-Reason: There is no %Bgitstatusd%b binary for i686 (32-bit Intel architecture).}" @@ -4516,19 +4431,6 @@ _p9k_init() { >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}" >&2 echo -E - "${(%):- * Git prompt will be %Bfast%b.}" else - local -i daemon threads - if (( ! $+GITSTATUS_DAEMON )); then - local os=$_p9k_uname - [[ $_p9k_uname == Linux && _p9k_uname_o == Android ]] && os=Android - typeset -g GITSTATUS_DAEMON=$gitstatus_dir/bin/gitstatusd-${os:l}-${_p9k_uname_m:l} - daemon=1 - fi - if (( ! $+GITSTATUS_NUM_THREADS )); then - typeset -gi GITSTATUS_NUM_THREADS=$(( _p9k_num_cpus * 2 )) - (( GITSTATUS_NUM_THREADS > 0 )) || GITSTATUS_NUM_THREADS=8 - (( GITSTATUS_NUM_THREADS <= 32 )) || GITSTATUS_NUM_THREADS=32 - threads=1 - fi source $gitstatus_dir/gitstatus.plugin.zsh gitstatus_start \ -s $_POWERLEVEL9K_VCS_STAGED_MAX_NUM \ @@ -4536,9 +4438,7 @@ _p9k_init() { -d $_POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM \ -c $_POWERLEVEL9K_VCS_CONFLICTED_MAX_NUM \ -m $_POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY \ - POWERLEVEL9K || _p9k_gitstatus_disabled=1 - (( daemon )) && unset GITSTATUS_DAEMON - (( threads )) && unset GITSTATUS_NUM_THREADS + POWERLEVEL9K || _POWERLEVEL9K_DISABLE_GITSTATUS=1 fi fi fi @@ -4560,6 +4460,36 @@ _p9k_init() { fi fi + if _p9k_segment_in_use load; then + case $_p9k_os in + OSX) (( $+commands[sysctl] )) && _p9k_num_cpus="$(sysctl -n hw.logicalcpu 2>/dev/null)";; + BSD) (( $+commands[sysctl] )) && _p9k_num_cpus="$(sysctl -n hw.ncpu 2>/dev/null)";; + *) (( $+commands[nproc] )) && _p9k_num_cpus="$(nproc 2>/dev/null)";; + esac + fi + + if _p9k_segment_in_use dir; then + if (( $+_POWERLEVEL9K_DIR_CLASSES )); then + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale + local -i i=3 + for ((; i <= $#_POWERLEVEL9K_DIR_CLASSES; i+=3)); do + _POWERLEVEL9K_DIR_CLASSES[i]=${(g::)_POWERLEVEL9K_DIR_CLASSES[i]} + done + else + typeset -ga _POWERLEVEL9K_DIR_CLASSES=() + _p9k_get_icon prompt_dir_ETC ETC_ICON + _POWERLEVEL9K_DIR_CLASSES+=('/etc|/etc/*' ETC "$_p9k_ret") + _p9k_get_icon prompt_dir_HOME HOME_ICON + _POWERLEVEL9K_DIR_CLASSES+=('~' HOME "$_p9k_ret") + _p9k_get_icon prompt_dir_HOME_SUBFOLDER HOME_SUB_ICON + _POWERLEVEL9K_DIR_CLASSES+=('~/*' HOME_SUBFOLDER "$_p9k_ret") + _p9k_get_icon prompt_dir_DEFAULT FOLDER_ICON + _POWERLEVEL9K_DIR_CLASSES+=('*' DEFAULT "$_p9k_ret") + fi + fi + + _p9k_init_async_pump + if _p9k_segment_in_use vi_mode || _p9k_segment_in_use prompt_char; then _p9k_wrap_zle_widget zle-keymap-select _p9k_zle_keymap_select fi @@ -4580,7 +4510,22 @@ _p9k_init() { print -rP -- 'Either install %F{green}jq%f or change the value of %BPOWERLEVEL9K_SHORTEN_STRATEGY%b.' fi - _p9k_init_async_pump + if _p9k_segment_in_use status; then + typeset -g _p9k_exitcode2str=({0..255}) + local -i i=2 + if (( !_POWERLEVEL9K_STATUS_HIDE_SIGNAME )); then + for ((; i <= $#signals; ++i)); do + local sig=$signals[i] + (( _POWERLEVEL9K_STATUS_VERBOSE_SIGNAME )) && sig="SIG${sig}($((i-1)))" + _p9k_exitcode2str[$((128+i))]=$sig + done + fi + fi + + if [[ -n $_POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]] && _p9k_segment_in_use public_ip || + _p9k_segment_in_use ip || _p9k_segment_in_use vpn_ip; then + _p9k_fetch_iface=1 + fi } _p9k_deinit() { @@ -4782,7 +4727,6 @@ zmodload zsh/mathfunc zmodload zsh/system zmodload -F zsh/stat b:zstat zmodload -F zsh/net/socket b:zsocket -zmodload -F zsh/files b:zf_mv _p9k_init_ssh prompt_powerlevel9k_setup -- cgit v1.2.3 From cb14b9dfc8e927743a484d3d1dbf5059deabaa19 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 2 Oct 2019 19:51:42 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index 55d18a89..4b0ee043 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -316,9 +316,9 @@ function gitstatus_start() { setopt xtrace } - local daemon=${GITSTATUS_DAEMON:-} + local daemon=${GITSTATUS_DAEMON:-} os [[ -n $daemon ]] || { - local os arch + local arch os="$(uname -s)" [[ -n $os ]] [[ $os != Linux || "$(uname -o)" != Android ]] || os=Android @@ -344,6 +344,7 @@ function gitstatus_start() { local -i threads=${GITSTATUS_NUM_THREADS:-0} (( threads > 0)) || { threads=8 + [[ -n $os ]] || { os="$(uname -s)" && [[ -n $os ]] } case $os in FreeBSD) (( ! $+commands[sysctl] )) || threads=$(( 2 * $(sysctl -n hw.ncpu) ));; *) (( ! $+commands[getconf] )) || threads=$(( 2 * $(getconf _NPROCESSORS_ONLN) ));; -- cgit v1.2.3 From b8d648b339c2b6cd784c73c704c0ebddd821f2e4 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 3 Oct 2019 09:42:02 +0200 Subject: Revert "Revert "speed up startup by about 3x"" This reverts commit e5e6249ffd592695ccdb6030a42d3664b3dde480. --- internal/p10k.zsh | 174 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 115 insertions(+), 59 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 240e4bdc..20685b32 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1218,6 +1218,7 @@ prompt_dir() { fi local -i fake_first=0 expand=0 + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale local delim=${_POWERLEVEL9K_SHORTEN_DELIMITER-$'\u2026'} local -i shortenlen=${_POWERLEVEL9K_SHORTEN_DIR_LENGTH:--1} @@ -2744,7 +2745,7 @@ function _p9k_vcs_gitstatus() { prompt_vcs() { local -a backends=($_POWERLEVEL9K_VCS_BACKENDS) - if (( ${backends[(I)git]} && !_POWERLEVEL9K_DISABLE_GITSTATUS )) && _p9k_vcs_gitstatus; then + if (( ${backends[(I)git]} && !_p9k_gitstatus_disabled )) && _p9k_vcs_gitstatus; then _p9k_vcs_render && return backends=(${backends:#git}) fi @@ -3336,12 +3337,38 @@ _p9k_save_status() { fi } +function _p9k_dump_state() { + local dir=${XDG_CACHE_HOME:-$HOME/.cache} + [[ -d $dir ]] || mkdir -pm 0700 $dir || return + [[ -w $dir && -z $dir(#qNR) ]] || return + local tmp=$dir/p10k-state-$USER.zsh.$$-$EPOCHREALTIME-$RANDOM + local -i fd + sysopen -a -m 600 -o creat,trunc -u fd $tmp || return + { + print -r -- "# $_p9k_param_sig" >&$fd || return + typeset -pm '(_POWERLEVEL9K_|_p9k_)*~(_p9k_async_pump*)' >&$fd || return + } always { + exec {fd}>&- + } + zf_mv -f $tmp $dir/p10k-state-$USER.zsh +} + +function _p9k_restore_state() { + local file=${XDG_CACHE_HOME:-$HOME/.cache}/p10k-state-$USER.zsh + [[ -r $file && -z $file(#qNW) ]] || return + local content && content="$(<$file)" + [[ $content == '# '$_p9k_param_sig$'\n'* ]] || return + eval $content +} + _p9k_precmd_impl() { emulate -L zsh setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} (( __p9k_enabled )) || return + local -i init=0 + if ! zle || [[ -z $_p9k_param_sig ]]; then if zle; then __p9k_new_status=0 @@ -3377,6 +3404,7 @@ _p9k_precmd_impl() { fi fi _p9k_init + local -i init=1 fi _p9k_timer_end=EPOCHREALTIME @@ -3399,6 +3427,8 @@ _p9k_precmd_impl() { _p9k_refresh_reason=precmd _p9k_set_prompt _p9k_refresh_reason='' + + (( init )) && _p9k_dump_state } _p9k_precmd() { @@ -3554,8 +3584,9 @@ _p9k_init_async_pump() { _p9k_start_async_pump() { setopt err_return no_bg_nice - _p9k_async_pump_lock="$(mktemp ${TMPDIR:-/tmp}/p9k-$$-async-pump-lock.XXXXXXXXXX)" - _p9k_async_pump_fifo="$(mktemp -u ${TMPDIR:-/tmp}/p9k-$$-async-pump-fifo.XXXXXXXXXX)" + _p9k_async_pump_lock=${TMPDIR:-/tmp}/p9k-$$-async-pump-lock.$EPOCHREALTIME.$RANDOM + _p9k_async_pump_fifo=${TMPDIR:-/tmp}/p9k-$$-async-pump-fifo.$EPOCHREALTIME.$RANDOM + echo -n >$_p9k_async_pump_lock mkfifo $_p9k_async_pump_fifo sysopen -rw -o cloexec,sync -u _p9k_async_pump_fd $_p9k_async_pump_fifo zle -F $_p9k_async_pump_fd _p9k_on_async_message @@ -3690,6 +3721,10 @@ _p9k_init_vars() { typeset -gi _p9k_fetch_iface typeset -g _p9k_keymap typeset -g _p9k_zle_state + typeset -g _p9k_uname + typeset -g _p9k_uname_o + typeset -g _p9k_uname_m + typeset -gi _p9k_gitstatus_disabled typeset -g P9K_VISUAL_IDENTIFIER typeset -g P9K_CONTENT @@ -4289,7 +4324,7 @@ _p9k_must_init() { ${(o)parameters[(I)(POWERLEVEL9K_*|GITSTATUS_LOG_LEVEL|GITSTATUS_ENABLE_LOGGING|GITSTATUS_DAEMON|GITSTATUS_NUM_THREADS|DEFAULT_USER|ZLE_RPROMPT_INDENT)]}) local IFS param_sig IFS=$'\1' param_sig="${(@)param_keys:/(#b)(*)/$match[1]=\$$match[1]}" - IFS=$'\2' eval "param_sig=$__p9k_ksh_arrays$__p9k_sh_glob\"$param_sig\"" + IFS=$'\2' eval "param_sig=0.$USER.$P9K_SSH$__p9k_ksh_arrays$__p9k_sh_glob\"$param_sig\"" [[ -o transient_rprompt ]] && param_sig+=t [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit @@ -4302,17 +4337,19 @@ function _p9k_set_os() { _p9k_os_icon=$_p9k_ret } -_p9k_init() { +function _p9k_init_cacheable() { _p9k_init_icons - _p9k_init_vars _p9k_init_params _p9k_init_prompt - local uname="$(uname)" - if [[ $uname == Linux && "$(uname -o 2>/dev/null)" == Android ]]; then + _p9k_uname="$(uname)" + [[ $_p9k_uname == Linux ]] && _p9k_uname_o="$(uname -o 2>/dev/null)" + _p9k_uname_m="$(uname -m)" + + if [[ $_p9k_uname == Linux && _p9k_uname_o == Android ]]; then _p9k_set_os Android ANDROID_ICON else - case $uname in + case $_p9k_uname in SunOS) _p9k_set_os Solaris SUNOS_ICON;; Darwin) _p9k_set_os OSX APPLE_ICON;; CYGWIN_NT-* | MSYS_NT-*) _p9k_set_os Windows WINDOWS_ICON;; @@ -4394,12 +4431,60 @@ _p9k_init() { fi done + case $_p9k_os in + OSX) (( $+commands[sysctl] )) && _p9k_num_cpus="$(sysctl -n hw.logicalcpu 2>/dev/null)";; + BSD) (( $+commands[sysctl] )) && _p9k_num_cpus="$(sysctl -n hw.ncpu 2>/dev/null)";; + *) (( $+commands[nproc] )) && _p9k_num_cpus="$(nproc 2>/dev/null)";; + esac + + if _p9k_segment_in_use dir; then + if (( $+_POWERLEVEL9K_DIR_CLASSES )); then + [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale + local -i i=3 + for ((; i <= $#_POWERLEVEL9K_DIR_CLASSES; i+=3)); do + _POWERLEVEL9K_DIR_CLASSES[i]=${(g::)_POWERLEVEL9K_DIR_CLASSES[i]} + done + else + typeset -ga _POWERLEVEL9K_DIR_CLASSES=() + _p9k_get_icon prompt_dir_ETC ETC_ICON + _POWERLEVEL9K_DIR_CLASSES+=('/etc|/etc/*' ETC "$_p9k_ret") + _p9k_get_icon prompt_dir_HOME HOME_ICON + _POWERLEVEL9K_DIR_CLASSES+=('~' HOME "$_p9k_ret") + _p9k_get_icon prompt_dir_HOME_SUBFOLDER HOME_SUB_ICON + _POWERLEVEL9K_DIR_CLASSES+=('~/*' HOME_SUBFOLDER "$_p9k_ret") + _p9k_get_icon prompt_dir_DEFAULT FOLDER_ICON + _POWERLEVEL9K_DIR_CLASSES+=('*' DEFAULT "$_p9k_ret") + fi + fi + + if _p9k_segment_in_use status; then + typeset -g _p9k_exitcode2str=({0..255}) + local -i i=2 + if (( !_POWERLEVEL9K_STATUS_HIDE_SIGNAME )); then + for ((; i <= $#signals; ++i)); do + local sig=$signals[i] + (( _POWERLEVEL9K_STATUS_VERBOSE_SIGNAME )) && sig="SIG${sig}($((i-1)))" + _p9k_exitcode2str[$((128+i))]=$sig + done + fi + fi + + if [[ -n $_POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]] && _p9k_segment_in_use public_ip || + _p9k_segment_in_use ip || _p9k_segment_in_use vpn_ip; then + _p9k_fetch_iface=1 + fi +} + +_p9k_init() { + _p9k_init_vars + _p9k_restore_state || _p9k_init_cacheable + if _p9k_segment_in_use vcs; then _p9k_vcs_info_init - local gitstatus_dir=${_POWERLEVEL9K_GITSTATUS_DIR:-${__p9k_root_dir}/gitstatus} if [[ $_POWERLEVEL9K_DISABLE_GITSTATUS == 0 && -n $_POWERLEVEL9K_VCS_BACKENDS[(r)git] ]]; then - if [[ -z $GITSTATUS_DAEMON && "$(uname -m)" == i686 && -z $gitstatus_dir/bin/*-i686(-static|)(#qN) ]]; then - _POWERLEVEL9K_DISABLE_GITSTATUS=1 + local gitstatus_dir=${_POWERLEVEL9K_GITSTATUS_DIR:-${__p9k_root_dir}/gitstatus} + if [[ -z $GITSTATUS_DAEMON && $_p9k_uname == i686 && -z $gitstatus_dir/bin/*-i686(-static|)(#qN) ]]; then + _p9k_gitstatus_disabled=1 >&2 echo -E - "${(%):-[%1FERROR%f]: %BPowerlevel10k%b is unable to use %Bgitstatus%b. Git prompt will be slow.}" >&2 echo -E - "" >&2 echo -E - "${(%):-Reason: There is no %Bgitstatusd%b binary for i686 (32-bit Intel architecture).}" @@ -4431,6 +4516,19 @@ _p9k_init() { >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}" >&2 echo -E - "${(%):- * Git prompt will be %Bfast%b.}" else + local -i daemon threads + if (( ! $+GITSTATUS_DAEMON )); then + local os=$_p9k_uname + [[ $_p9k_uname == Linux && _p9k_uname_o == Android ]] && os=Android + typeset -g GITSTATUS_DAEMON=$gitstatus_dir/bin/gitstatusd-${os:l}-${_p9k_uname_m:l} + daemon=1 + fi + if (( ! $+GITSTATUS_NUM_THREADS )); then + typeset -gi GITSTATUS_NUM_THREADS=$(( _p9k_num_cpus * 2 )) + (( GITSTATUS_NUM_THREADS > 0 )) || GITSTATUS_NUM_THREADS=8 + (( GITSTATUS_NUM_THREADS <= 32 )) || GITSTATUS_NUM_THREADS=32 + threads=1 + fi source $gitstatus_dir/gitstatus.plugin.zsh gitstatus_start \ -s $_POWERLEVEL9K_VCS_STAGED_MAX_NUM \ @@ -4438,7 +4536,9 @@ _p9k_init() { -d $_POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM \ -c $_POWERLEVEL9K_VCS_CONFLICTED_MAX_NUM \ -m $_POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY \ - POWERLEVEL9K || _POWERLEVEL9K_DISABLE_GITSTATUS=1 + POWERLEVEL9K || _p9k_gitstatus_disabled=1 + (( daemon )) && unset GITSTATUS_DAEMON + (( threads )) && unset GITSTATUS_NUM_THREADS fi fi fi @@ -4460,36 +4560,6 @@ _p9k_init() { fi fi - if _p9k_segment_in_use load; then - case $_p9k_os in - OSX) (( $+commands[sysctl] )) && _p9k_num_cpus="$(sysctl -n hw.logicalcpu 2>/dev/null)";; - BSD) (( $+commands[sysctl] )) && _p9k_num_cpus="$(sysctl -n hw.ncpu 2>/dev/null)";; - *) (( $+commands[nproc] )) && _p9k_num_cpus="$(nproc 2>/dev/null)";; - esac - fi - - if _p9k_segment_in_use dir; then - if (( $+_POWERLEVEL9K_DIR_CLASSES )); then - [[ -z $_p9k_locale ]] || local LC_ALL=$_p9k_locale - local -i i=3 - for ((; i <= $#_POWERLEVEL9K_DIR_CLASSES; i+=3)); do - _POWERLEVEL9K_DIR_CLASSES[i]=${(g::)_POWERLEVEL9K_DIR_CLASSES[i]} - done - else - typeset -ga _POWERLEVEL9K_DIR_CLASSES=() - _p9k_get_icon prompt_dir_ETC ETC_ICON - _POWERLEVEL9K_DIR_CLASSES+=('/etc|/etc/*' ETC "$_p9k_ret") - _p9k_get_icon prompt_dir_HOME HOME_ICON - _POWERLEVEL9K_DIR_CLASSES+=('~' HOME "$_p9k_ret") - _p9k_get_icon prompt_dir_HOME_SUBFOLDER HOME_SUB_ICON - _POWERLEVEL9K_DIR_CLASSES+=('~/*' HOME_SUBFOLDER "$_p9k_ret") - _p9k_get_icon prompt_dir_DEFAULT FOLDER_ICON - _POWERLEVEL9K_DIR_CLASSES+=('*' DEFAULT "$_p9k_ret") - fi - fi - - _p9k_init_async_pump - if _p9k_segment_in_use vi_mode || _p9k_segment_in_use prompt_char; then _p9k_wrap_zle_widget zle-keymap-select _p9k_zle_keymap_select fi @@ -4510,22 +4580,7 @@ _p9k_init() { print -rP -- 'Either install %F{green}jq%f or change the value of %BPOWERLEVEL9K_SHORTEN_STRATEGY%b.' fi - if _p9k_segment_in_use status; then - typeset -g _p9k_exitcode2str=({0..255}) - local -i i=2 - if (( !_POWERLEVEL9K_STATUS_HIDE_SIGNAME )); then - for ((; i <= $#signals; ++i)); do - local sig=$signals[i] - (( _POWERLEVEL9K_STATUS_VERBOSE_SIGNAME )) && sig="SIG${sig}($((i-1)))" - _p9k_exitcode2str[$((128+i))]=$sig - done - fi - fi - - if [[ -n $_POWERLEVEL9K_PUBLIC_IP_VPN_INTERFACE ]] && _p9k_segment_in_use public_ip || - _p9k_segment_in_use ip || _p9k_segment_in_use vpn_ip; then - _p9k_fetch_iface=1 - fi + _p9k_init_async_pump } _p9k_deinit() { @@ -4727,6 +4782,7 @@ zmodload zsh/mathfunc zmodload zsh/system zmodload -F zsh/stat b:zstat zmodload -F zsh/net/socket b:zsocket +zmodload -F zsh/files b:zf_mv _p9k_init_ssh prompt_powerlevel9k_setup -- cgit v1.2.3 From e0bb4f01478162018e64fa1795dab96f6d2572f1 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 3 Oct 2019 14:21:21 +0200 Subject: zcompile all sources --- .gitignore | 1 + powerlevel9k.zsh-theme | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..416cfaac --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.zwc diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index f44e6870..8a0dc15b 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -27,6 +27,10 @@ typeset -g __p9k_root_dir="${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}}" return fi typeset -gr __p9k_sourced=1 + local f + for f in $__p9k_root_dir/{powerlevel9k.zsh-theme,powerlevel10k.zsh-theme,internal/p10k.zsh,internal/icons.zsh,internal/configure.zsh,gitstatus/gitstatus.plugin.zsh}; do + [[ $f.zwc -nt $f ]] || zcompile $f + done source $__p9k_root_dir/internal/p10k.zsh || true } -- cgit v1.2.3 From 0cb680edd1989e6a643b320ab28e2618bd8d068d Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 3 Oct 2019 14:21:58 +0200 Subject: fix bugs in startup speedup and make it yet faster --- internal/icons.zsh | 4 +- internal/p10k.zsh | 117 ++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 82 insertions(+), 39 deletions(-) diff --git a/internal/icons.zsh b/internal/icons.zsh index 36e76fac..718e1663 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -544,7 +544,7 @@ function _p9k_init_icons() { } # Sadly, this is a part of public API. Its use is emphatically discouraged. -function print_icon() { +function _p9k_print_icon() { emulate -L zsh setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} _p9k_init_icons @@ -563,7 +563,7 @@ function print_icon() { # * $1 string - If "original", then the original icons are printed, # otherwise "print_icon" is used, which takes the users # overrides into account. -function get_icon_names() { +function _p9k_get_icon_names() { emulate -L zsh setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} _p9k_init_icons diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 20685b32..27efcca8 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -27,7 +27,6 @@ if ! autoload -Uz is-at-least || ! is-at-least 5.1; then return 1 fi -source "${__p9k_root_dir}/internal/icons.zsh" source "${__p9k_root_dir}/internal/configure.zsh" # For compatibility with Powerlevel9k. It's not recommended to use mnemonic color @@ -115,6 +114,26 @@ function getColorCode() { return 1 } +# Sadly, this is a part of public API. Its use is emphatically discouraged. +function print_icon() { + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} no_aliases + (( $+functions[_p9k_print_icon] )) || source "${__p9k_root_dir}/internal/icons.zsh" + _p9k_print_icon "$@" +} + +# Prints a list of configured icons. +# +# * $1 string - If "original", then the original icons are printed, +# otherwise "print_icon" is used, which takes the users +# overrides into account. +function get_icon_names() { + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang prompt_{percent,subst} no_aliases + (( $+functions[_p9k_get_icon_names] )) || source "${__p9k_root_dir}/internal/icons.zsh" + _p9k_get_icon_names "$@" +} + # _p9k_declare [default]... function _p9k_declare() { local -i set=$+parameters[$2] @@ -2488,7 +2507,7 @@ function _p9k_vcs_icon() { function _p9k_vcs_render() { local state - if (( $+_p9k_next_vcs_dir )); then + if (( $+_p9k_gitstatus_next_dir )); then if _p9k_vcs_status_for_dir ${${GIT_DIR:A}:-$_p9k_pwd_a}; then _p9k_vcs_status_restore $_p9k_ret state=LOADING @@ -2678,23 +2697,23 @@ function _p9k_vcs_resume() { _p9k_vcs_status_save fi - if [[ -z $_p9k_next_vcs_dir ]]; then - unset _p9k_next_vcs_dir + if [[ -z $_p9k_gitstatus_next_dir ]]; then + unset _p9k_gitstatus_next_dir case $VCS_STATUS_RESULT in norepo-async) (( $1 )) && _p9k_vcs_status_purge ${${GIT_DIR:A}:-$_p9k_pwd_a};; - ok-async) (( $1 )) || _p9k_next_vcs_dir=${${GIT_DIR:A}:-$_p9k_pwd_a};; + ok-async) (( $1 )) || _p9k_gitstatus_next_dir=${${GIT_DIR:A}:-$_p9k_pwd_a};; esac fi - if [[ -n $_p9k_next_vcs_dir ]]; then - if ! gitstatus_query -d $_p9k_next_vcs_dir -t 0 -c '_p9k_vcs_resume 1' POWERLEVEL9K; then - unset _p9k_next_vcs_dir + if [[ -n $_p9k_gitstatus_next_dir ]]; then + if ! gitstatus_query -d $_p9k_gitstatus_next_dir -t 0 -c '_p9k_vcs_resume 1' POWERLEVEL9K; then + unset _p9k_gitstatus_next_dir unset VCS_STATUS_RESULT else case $VCS_STATUS_RESULT in - tout) _p9k_next_vcs_dir=''; _p9k_gitstatus_start_time=$EPOCHREALTIME;; - norepo-sync) _p9k_vcs_status_purge $_p9k_next_vcs_dir; unset _p9k_next_vcs_dir;; - ok-sync) _p9k_vcs_status_save; unset _p9k_next_vcs_dir;; + tout) _p9k_gitstatus_next_dir=''; _p9k_gitstatus_start_time=$EPOCHREALTIME;; + norepo-sync) _p9k_vcs_status_purge $_p9k_gitstatus_next_dir; unset _p9k_gitstatus_next_dir;; + ok-sync) _p9k_vcs_status_save; unset _p9k_gitstatus_next_dir;; esac fi fi @@ -2704,15 +2723,15 @@ function _p9k_vcs_resume() { function _p9k_vcs_gitstatus() { if [[ $_p9k_refresh_reason == precmd ]]; then - if (( $+_p9k_next_vcs_dir )); then - _p9k_next_vcs_dir=${${GIT_DIR:A}:-$_p9k_pwd_a} + if (( $+_p9k_gitstatus_next_dir )); then + _p9k_gitstatus_next_dir=${${GIT_DIR:A}:-$_p9k_pwd_a} else local dir=${${GIT_DIR:A}:-$_p9k_pwd_a} local -F timeout=_POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS if ! _p9k_vcs_status_for_dir $dir; then gitstatus_query -d $dir -t $timeout -p -c '_p9k_vcs_resume 0' POWERLEVEL9K || return 1 case $VCS_STATUS_RESULT in - tout) _p9k_next_vcs_dir=''; _p9k_gitstatus_start_time=$EPOCHREALTIME; return 0;; + tout) _p9k_gitstatus_next_dir=''; _p9k_gitstatus_start_time=$EPOCHREALTIME; return 0;; norepo-sync) return 0;; ok-sync) _p9k_vcs_status_save;; esac @@ -2726,12 +2745,13 @@ function _p9k_vcs_gitstatus() { done dir=${${GIT_DIR:A}:-$_p9k_pwd_a} fi + (( _p9k_prompt_idx == 1 )) && timeout=0 if ! gitstatus_query -d $dir -t $timeout -c '_p9k_vcs_resume 1' POWERLEVEL9K; then unset VCS_STATUS_RESULT return 1 fi case $VCS_STATUS_RESULT in - tout) _p9k_next_vcs_dir=''; _p9k_gitstatus_start_time=$EPOCHREALTIME;; + tout) _p9k_gitstatus_next_dir=''; _p9k_gitstatus_start_time=$EPOCHREALTIME;; norepo-sync) _p9k_vcs_status_purge $dir;; ok-sync) _p9k_vcs_status_save;; esac @@ -3338,27 +3358,38 @@ _p9k_save_status() { } function _p9k_dump_state() { - local dir=${XDG_CACHE_HOME:-$HOME/.cache} + is-at-least 5.3 || return + local dir=${_p9k_state_file:h} [[ -d $dir ]] || mkdir -pm 0700 $dir || return [[ -w $dir && -z $dir(#qNR) ]] || return - local tmp=$dir/p10k-state-$USER.zsh.$$-$EPOCHREALTIME-$RANDOM + local tmp=$_p9k_state_file.$$-$EPOCHREALTIME-$RANDOM local -i fd sysopen -a -m 600 -o creat,trunc -u fd $tmp || return { - print -r -- "# $_p9k_param_sig" >&$fd || return - typeset -pm '(_POWERLEVEL9K_|_p9k_)*~(_p9k_async_pump*)' >&$fd || return + print -r -- $_p9k_param_sig >&$fd || return + local include='_POWERLEVEL9K_*|_p9k_*|icons|OS|DEFAULT_COLOR|DEFAULT_COLOR_INVERTED' + local exclude='_p9k_gitstatus_*|_p9k_param_sig|_p9k_public_ip|_p9k_prompt|_p9k_prompt_idx' + typeset -pm "($include)~($exclude)" >&$fd || return } always { exec {fd}>&- } - zf_mv -f $tmp $dir/p10k-state-$USER.zsh + zf_mv -f $tmp $_p9k_state_file } function _p9k_restore_state() { - local file=${XDG_CACHE_HOME:-$HOME/.cache}/p10k-state-$USER.zsh - [[ -r $file && -z $file(#qNW) ]] || return - local content && content="$(<$file)" - [[ $content == '# '$_p9k_param_sig$'\n'* ]] || return - eval $content + [[ -z $_p9k_state_file(#qNW) ]] || return + local tmp=$_p9k_state_file.$$-$EPOCHREALTIME-$RANDOM + zf_mv -f $_p9k_state_file $tmp 2>/dev/null || return + { + [[ -r $tmp ]] || return + local sig + IFS='' read -r sig <$tmp || return + [[ $sig == $_p9k_param_sig ]] || return + source $tmp || return + _p9k_state_restored=1 + } always { + zf_mv -f $tmp $_p9k_state_file 2>/dev/null + } } _p9k_precmd_impl() { @@ -3367,8 +3398,6 @@ _p9k_precmd_impl() { (( __p9k_enabled )) || return - local -i init=0 - if ! zle || [[ -z $_p9k_param_sig ]]; then if zle; then __p9k_new_status=0 @@ -3404,12 +3433,10 @@ _p9k_precmd_impl() { fi fi _p9k_init - local -i init=1 fi - _p9k_timer_end=EPOCHREALTIME if (( _p9k_timer_start )); then - typeset -gF P9K_COMMAND_DURATION_SECONDS=$((_p9k_timer_end - _p9k_timer_start)) + typeset -gF P9K_COMMAND_DURATION_SECONDS=$((EPOCHREALTIME - _p9k_timer_start)) else unset P9K_COMMAND_DURATION_SECONDS fi @@ -3422,13 +3449,19 @@ _p9k_precmd_impl() { unset _p9k_preexec_cmd _p9k_keymap=main _p9k_zle_state=insert + + if ! zle; then + (( ++_p9k_prompt_idx )) + fi fi _p9k_refresh_reason=precmd _p9k_set_prompt _p9k_refresh_reason='' - (( init )) && _p9k_dump_state + if ! zle && (( _p9k_prompt_idx == 1 && !_p9k_state_restored || _p9k_prompt_idx == 2 )); then + _p9k_dump_state + fi } _p9k_precmd() { @@ -3638,9 +3671,10 @@ function _p9k_prompt_overflow_bug() { } _p9k_init_vars() { + typeset -gi _p9k_prompt_idx + typeset -gi _p9k_state_restored typeset -gi _p9k_reset_on_line_finish typeset -gF _p9k_timer_start - typeset -gF _p9k_timer_end typeset -gi _p9k_status typeset -ga _p9k_pipestatus typeset -g _p9k_param_sig @@ -3660,6 +3694,7 @@ _p9k_init_vars() { typeset -gA _p9k_last_git_prompt # git workdir => 1 if gitstatus is slow on it, 0 if it's fast. typeset -gA _p9k_git_slow + typeset -gi _p9k_gitstatus_disabled typeset -gF _p9k_gitstatus_start_time typeset -g _p9k_prompt typeset -g _p9k_rprompt @@ -3724,7 +3759,6 @@ _p9k_init_vars() { typeset -g _p9k_uname typeset -g _p9k_uname_o typeset -g _p9k_uname_m - typeset -gi _p9k_gitstatus_disabled typeset -g P9K_VISUAL_IDENTIFIER typeset -g P9K_CONTENT @@ -4320,12 +4354,15 @@ _p9k_init_ssh() { } _p9k_must_init() { - local -a param_keys=( - ${(o)parameters[(I)(POWERLEVEL9K_*|GITSTATUS_LOG_LEVEL|GITSTATUS_ENABLE_LOGGING|GITSTATUS_DAEMON|GITSTATUS_NUM_THREADS|DEFAULT_USER|ZLE_RPROMPT_INDENT)]}) + local -a param_keys=(${(o)parameters[(I)POWERLEVEL9K_*]}) local IFS param_sig IFS=$'\1' param_sig="${(@)param_keys:/(#b)(*)/$match[1]=\$$match[1]}" - IFS=$'\2' eval "param_sig=0.$USER.$P9K_SSH$__p9k_ksh_arrays$__p9k_sh_glob\"$param_sig\"" - [[ -o transient_rprompt ]] && param_sig+=t + param_sig+=( + '${ZSH_VERSION}' '${ZSH_PATCHLEVEL}' '${(%):-%n}' '${GITSTATUS_LOG_LEVEL}' + '${GITSTATUS_ENABLE_LOGGING}' '${GITSTATUS_DAEMON}' '${GITSTATUS_NUM_THREADS}' + '${DEFAULT_USER}' '${ZLE_RPROMPT_INDENT}' '${P9K_SSH}' '${__p9k_ksh_arrays}' + '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v0') + IFS=$'\2' param_sig="#${(e)param_sig}" [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit typeset -g _p9k_param_sig=$param_sig @@ -4338,6 +4375,10 @@ function _p9k_set_os() { } function _p9k_init_cacheable() { + (( $+functions[_p9k_init_icons] )) || { + setopt no_aliases + source "${__p9k_root_dir}/internal/icons.zsh" + } _p9k_init_icons _p9k_init_params _p9k_init_prompt @@ -4477,6 +4518,7 @@ function _p9k_init_cacheable() { _p9k_init() { _p9k_init_vars + typeset -g _p9k_state_file=${XDG_CACHE_HOME:-~/.cache}/p10k-state-${(%):-%n}.zsh _p9k_restore_state || _p9k_init_cacheable if _p9k_segment_in_use vcs; then @@ -4779,6 +4821,7 @@ autoload -Uz add-zsh-hook zmodload zsh/datetime zmodload zsh/mathfunc +zmodload zsh/parameter zmodload zsh/system zmodload -F zsh/stat b:zstat zmodload -F zsh/net/socket b:zsocket -- cgit v1.2.3 From aa606e6cb0cb6ae852cca343fbffe72ed8015a1c Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 3 Oct 2019 14:50:08 +0200 Subject: don't print options when no_aliases, no_sh_glob and brace_expand are all set --- config/p10k-classic.zsh | 2 +- config/p10k-lean.zsh | 2 +- config/p10k-pure.zsh | 2 +- powerlevel9k.zsh-theme | 16 ++++++++-------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 35cfac1e..8c1e36f1 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -761,5 +761,5 @@ typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' } -setopt ${p10k_config_opts[@]} +(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} 'builtin' 'unset' 'p10k_config_opts' diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 96aba8e3..4693b363 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -740,5 +740,5 @@ typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' } -setopt ${p10k_config_opts[@]} +(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} 'builtin' 'unset' 'p10k_config_opts' diff --git a/config/p10k-pure.zsh b/config/p10k-pure.zsh index 61a2f5a1..a7ce1f5b 100644 --- a/config/p10k-pure.zsh +++ b/config/p10k-pure.zsh @@ -100,5 +100,5 @@ typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=yellow } -setopt ${p10k_config_opts[@]} +(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} 'builtin' 'unset' 'p10k_config_opts' diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 8a0dc15b..9d2847ce 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -10,12 +10,12 @@ # https://github.com/robbyrussell/oh-my-zsh/blob/74177c5320b2a1b2f8c4c695c05984b57fd7c6ea/themes/agnoster.zsh-theme ################################################################ -if [[ -o 'aliases' ]]; then - 'builtin' 'unsetopt' 'aliases' - local __p9k_restore_aliases=1 -else - local __p9k_restore_aliases=0 -fi +# Temporarily change options. +'builtin' 'local' '-a' '_p9k_src_opts' +[[ ! -o 'aliases' ]] || _p9k_src_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || _p9k_src_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || _p9k_src_opts+=('no_brace_expand') +'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' typeset -g __p9k_root_dir="${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}}" @@ -34,5 +34,5 @@ typeset -g __p9k_root_dir="${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}}" source $__p9k_root_dir/internal/p10k.zsh || true } -(( ! __p9k_restore_aliases )) || setopt aliases -'builtin' 'unset' '__p9k_restore_aliases' +(( ${#_p9k_src_opts} )) && setopt ${_p9k_src_opts[@]} +'builtin' 'unset' '_p9k_src_opts' -- cgit v1.2.3 From aa79dad7e30fff087ef5b87b58c650a0769a5192 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 3 Oct 2019 14:51:01 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index 4b0ee043..9473d2f5 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -528,5 +528,5 @@ function gitstatus_check() { [[ -n ${(P)${:-GITSTATUS_DAEMON_PID_${1}}} ]] } -setopt ${_gitstatus_opts[@]} +(( ${#_gitstatus_opts} )) && setopt ${_gitstatus_opts[@]} 'builtin' 'unset' '_gitstatus_opts' -- cgit v1.2.3 From 60a6ad81dd2d753e9707fc58120a9f121630ed31 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 3 Oct 2019 14:52:52 +0200 Subject: further startup speedup: zcompile state dump --- internal/p10k.zsh | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 27efcca8..12da570a 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3366,30 +3366,29 @@ function _p9k_dump_state() { local -i fd sysopen -a -m 600 -o creat,trunc -u fd $tmp || return { - print -r -- $_p9k_param_sig >&$fd || return local include='_POWERLEVEL9K_*|_p9k_*|icons|OS|DEFAULT_COLOR|DEFAULT_COLOR_INVERTED' local exclude='_p9k_gitstatus_*|_p9k_param_sig|_p9k_public_ip|_p9k_prompt|_p9k_prompt_idx' + local _p9k_cached_param_sig=$_p9k_param_sig + typeset -p _p9k_cached_param_sig >&$fd || return + print -r -- '_p9k_restore_state_impl() {' >&$fd || return typeset -pm "($include)~($exclude)" >&$fd || return + print -r -- '}' >&$fd || return } always { exec {fd}>&- } zf_mv -f $tmp $_p9k_state_file + zcompile $_p9k_state_file } function _p9k_restore_state() { - [[ -z $_p9k_state_file(#qNW) ]] || return - local tmp=$_p9k_state_file.$$-$EPOCHREALTIME-$RANDOM - zf_mv -f $_p9k_state_file $tmp 2>/dev/null || return - { - [[ -r $tmp ]] || return - local sig - IFS='' read -r sig <$tmp || return - [[ $sig == $_p9k_param_sig ]] || return - source $tmp || return - _p9k_state_restored=1 - } always { - zf_mv -f $tmp $_p9k_state_file 2>/dev/null - } + [[ -z $_p9k_state_file(.zwc|)(#qNW) ]] || return + unset _p9k_cached_param_sig + (( $+functions[_p9k_restore_state_impl] )) && unfunction _p9k_restore_state_impl + source $_p9k_state_file 2>/dev/null || return + [[ $_p9k_cached_param_sig == $_p9k_param_sig ]] || return + (( $+functions[_p9k_restore_state_impl] )) || return + _p9k_restore_state_impl + _p9k_state_restored=1 } _p9k_precmd_impl() { @@ -4362,7 +4361,7 @@ _p9k_must_init() { '${GITSTATUS_ENABLE_LOGGING}' '${GITSTATUS_DAEMON}' '${GITSTATUS_NUM_THREADS}' '${DEFAULT_USER}' '${ZLE_RPROMPT_INDENT}' '${P9K_SSH}' '${__p9k_ksh_arrays}' '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v0') - IFS=$'\2' param_sig="#${(e)param_sig}" + IFS=$'\2' param_sig="${(e)param_sig}" [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit typeset -g _p9k_param_sig=$param_sig -- cgit v1.2.3 From 9d0c49dc5838c9bdcfe686a1f17536a7650d8778 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 3 Oct 2019 20:13:04 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 273 +++++++++++++++++++++++------------------ 1 file changed, 151 insertions(+), 122 deletions(-) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index 9473d2f5..f9a12ae5 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -147,7 +147,8 @@ function gitstatus_query() { (( OPTIND == ARGC )) || { echo "usage: gitstatus_query [OPTION]... NAME" >&2; return 1 } local name=${*[$OPTIND]} - [[ -n ${(P)${:-GITSTATUS_DAEMON_PID_${name}}:-} ]] + local daemon_pid_var=GITSTATUS_DAEMON_PID_${name} + (( ${(P)daemon_pid_var:-0} > 0 )) # Verify that gitstatus_query is running in the same process that ran gitstatus_start. local client_pid_var=_GITSTATUS_CLIENT_PID_${name} @@ -279,10 +280,12 @@ function gitstatus_start() { local -i max_num_conflicted=1 local -i max_num_untracked=1 local -i dirty_max_index_size=-1 + local -i async local recurse_untracked_dirs while true; do - getopts "t:s:u:c:d:m:e" opt || break + getopts "t:s:u:c:d:m:ea" opt || break case $opt in + a) async=1;; t) timeout=$OPTARG;; s) max_num_staged=$OPTARG;; u) max_num_unstaged=$OPTARG;; @@ -299,143 +302,161 @@ function gitstatus_start() { (( OPTIND == ARGC )) || { echo "usage: gitstatus_start [OPTION]... NAME" >&2; return 1 } local name=${*[$OPTIND]} - [[ -z ${(P)${:-GITSTATUS_DAEMON_PID_${name}}:-} ]] || return 0 - - local dir && dir=${${(%):-%x}:A:h} - local xtrace_file lock_file req_fifo resp_fifo log_file - local -i stderr_fd=-1 lock_fd=-1 req_fd=-1 resp_fd=-1 daemon_pid=-1 - - function gitstatus_start_impl() { - local log_level=${GITSTATUS_LOG_LEVEL:-} + local lock_file req_fifo resp_fifo log_level + local log_file=/dev/null xtrace_file=/dev/null + local -i stderr_fd lock_fd req_fd resp_fd daemon_pid + local daemon_pid_var=GITSTATUS_DAEMON_PID_${name} + (( $+parameters[$daemon_pid_var] )) && { + (( ! async )) || return 0 + daemon_pid=${(P)daemon_pid_var} + (( daemon_pid == -1 )) || return 0 + local resp_fd_var=_GITSTATUS_RESP_FD_${name} + local log_file_var=GITSTATUS_DAEMON_LOG_${name} + local xtrace_file_var=GITSTATUS_XTRACE_${name} + resp_fd=${(P)resp_fd_var} + log_file=${(P)log_file_var} + xtrace_file=${(P)xtrace_file_var} + } || { + log_level=${GITSTATUS_LOG_LEVEL:-} [[ -n $log_level || ${GITSTATUS_ENABLE_LOGGING:-0} != 1 ]] || log_level=INFO - [[ -z $log_level ]] || { + log_file=${TMPDIR:-/tmp}/gitstatus.$$.daemon-log.$EPOCHREALTIME.$RANDOM xtrace_file=${TMPDIR:-/tmp}/gitstatus.$$.xtrace.$EPOCHREALTIME.$RANDOM - typeset -g GITSTATUS_XTRACE_${name}=$xtrace_file - exec {stderr_fd}>&2 2>$xtrace_file - setopt xtrace } + typeset -g GITSTATUS_DAEMON_LOG_${name}=$log_file + typeset -g GITSTATUS_XTRACE_${name}=$xtrace_file + } - local daemon=${GITSTATUS_DAEMON:-} os - [[ -n $daemon ]] || { - local arch - os="$(uname -s)" - [[ -n $os ]] - [[ $os != Linux || "$(uname -o)" != Android ]] || os=Android - arch="$(uname -m)" - [[ -n $arch ]] - daemon=$dir/bin/gitstatusd-${os:l}-${arch:l} + function gitstatus_start_impl() { + [[ $xtrace_file == /dev/null ]] || { + exec {stderr_fd}>&2 2>>$xtrace_file + setopt xtrace } - [[ -x $daemon ]] - - lock_file=${TMPDIR:-/tmp}/gitstatus.$$.lock.$EPOCHREALTIME.$RANDOM - echo -n >$lock_file - zsystem flock -f lock_fd $lock_file - req_fifo=${TMPDIR:-/tmp}/gitstatus.$$.req.$EPOCHREALTIME.$RANDOM - resp_fifo=${TMPDIR:-/tmp}/gitstatus.$$.resp.$EPOCHREALTIME.$RANDOM - mkfifo $req_fifo $resp_fifo - - [[ -n $log_level ]] && - log_file=${TMPDIR:-/tmp}/gitstatus.$$.daemon-log.$EPOCHREALTIME.$RANDOM || - log_file=/dev/null - typeset -g GITSTATUS_DAEMON_LOG_${name}=$log_file + (( daemon_pid == -1 )) || { + local daemon=${GITSTATUS_DAEMON:-} os + [[ -n $daemon ]] || { + os="$(uname -s)" && [[ -n $os ]] + [[ $os != Linux || "$(uname -o)" != Android ]] || os=Android + local arch && arch="$(uname -m)" && [[ -n $arch ]] + local dir && dir=${${(%):-%x}:A:h} + daemon=$dir/bin/gitstatusd-${os:l}-${arch:l} + } + [[ -x $daemon ]] + + lock_file=${TMPDIR:-/tmp}/gitstatus.$$.lock.$EPOCHREALTIME.$RANDOM + echo -n >$lock_file + zsystem flock -f lock_fd $lock_file + + req_fifo=${TMPDIR:-/tmp}/gitstatus.$$.req.$EPOCHREALTIME.$RANDOM + resp_fifo=${TMPDIR:-/tmp}/gitstatus.$$.resp.$EPOCHREALTIME.$RANDOM + mkfifo $req_fifo $resp_fifo + + local -i threads=${GITSTATUS_NUM_THREADS:-0} + (( threads > 0)) || { + threads=8 + [[ -n $os ]] || { os="$(uname -s)" && [[ -n $os ]] } + case $os in + FreeBSD) (( ! $+commands[sysctl] )) || threads=$(( 2 * $(sysctl -n hw.ncpu) ));; + *) (( ! $+commands[getconf] )) || threads=$(( 2 * $(getconf _NPROCESSORS_ONLN) ));; + esac + (( threads <= 32 )) || threads=32 + } - local -i threads=${GITSTATUS_NUM_THREADS:-0} - (( threads > 0)) || { - threads=8 - [[ -n $os ]] || { os="$(uname -s)" && [[ -n $os ]] } - case $os in - FreeBSD) (( ! $+commands[sysctl] )) || threads=$(( 2 * $(sysctl -n hw.ncpu) ));; - *) (( ! $+commands[getconf] )) || threads=$(( 2 * $(getconf _NPROCESSORS_ONLN) ));; - esac - (( threads <= 32 )) || threads=32 + local -a daemon_args=( + --lock-fd=3 + --parent-pid=${(q)$} + --num-threads=${(q)threads} + --max-num-staged=${(q)max_num_staged} + --max-num-unstaged=${(q)max_num_unstaged} + --max-num-conflicted=${(q)max_num_conflicted} + --max-num-untracked=${(q)max_num_untracked} + --dirty-max-index-size=${(q)dirty_max_index_size} + --log-level=${(q)log_level:-INFO} + $recurse_untracked_dirs) + + local cmd=" + echo \$\$ + ${(q)daemon} $daemon_args + if [[ \$? != (0|10) && \$? -le 128 && -f ${(q)daemon}-static ]]; then + ${(q)daemon}-static $daemon_args + fi + echo -nE $'bye\x1f0\x1e'" + local setsid=${commands[setsid]:-/usr/local/opt/util-linux/bin/setsid} + [[ -x $setsid ]] && setsid=${(q)setsid} || setsid= + cmd="cd /; $setsid zsh -dfxc ${(q)cmd} &!" + # We use `zsh -c` instead of plain {} or () to work around bugs in zplug (it hangs on + # startup). Double fork is to daemonize, and so is `setsid`. Note that on macOS `setsid` has + # to be installed manually by running `brew install util-linux`. + zsh -dfmxc $cmd <$req_fifo >$resp_fifo 2>$log_file 3<$lock_file &! + + sysopen -w -o cloexec,sync -u req_fd $req_fifo + sysopen -r -o cloexec -u resp_fd $resp_fifo + zf_rm -f $req_fifo $resp_fifo $lock_file + echo -nE $'hello\x1f\x1e' >&$req_fd } - local -a daemon_args=( - --lock-fd=3 - --parent-pid=${(q)$} - --num-threads=${(q)threads} - --max-num-staged=${(q)max_num_staged} - --max-num-unstaged=${(q)max_num_unstaged} - --max-num-conflicted=${(q)max_num_conflicted} - --max-num-untracked=${(q)max_num_untracked} - --dirty-max-index-size=${(q)dirty_max_index_size} - --log-level=${(q)log_level:-INFO} - $recurse_untracked_dirs) - - local cmd=" - echo \$\$ - ${(q)daemon} $daemon_args - if [[ \$? != (0|10) && \$? -le 128 && -f ${(q)daemon}-static ]]; then - ${(q)daemon}-static $daemon_args - fi - echo -nE $'bye\x1f0\x1e'" - local setsid=${commands[setsid]:-/usr/local/opt/util-linux/bin/setsid} - [[ -x $setsid ]] && setsid=${(q)setsid} || setsid= - cmd="cd /; $setsid zsh -dfxc ${(q)cmd} &!" - # We use `zsh -c` instead of plain {} or () to work around bugs in zplug (it hangs on startup). - # Double fork is to daemonize, and so is `setsid`. Note that on macOS `setsid` has to - # be installed manually by running `brew install util-linux`. - zsh -dfmxc $cmd <$req_fifo >$resp_fifo 2>$log_file 3<$lock_file &! - - sysopen -w -o cloexec,sync -u req_fd $req_fifo - sysopen -r -o cloexec -u resp_fd $resp_fifo - - read -u $resp_fd daemon_pid - - zf_rm -f $req_fifo $resp_fifo $lock_file - - function _gitstatus_process_response_${name}() { - local name=${${(%):-%N}#_gitstatus_process_response_} - (( ARGC == 1 )) && { - _gitstatus_process_response $name 0 '' - true - } || { - gitstatus_stop $name + (( async )) && { + daemon_pid=-1 + } || { + read -u $resp_fd daemon_pid + + function _gitstatus_process_response_${name}() { + local name=${${(%):-%N}#_gitstatus_process_response_} + (( ARGC == 1 )) && { + _gitstatus_process_response $name 0 '' + true + } || { + gitstatus_stop $name + } } + zle -F $resp_fd _gitstatus_process_response_${name} + + local reply IFS='' + read -r -d $'\x1e' -u $resp_fd -t $timeout reply + [[ $reply == $'hello\x1f0' ]] + + function _gitstatus_cleanup_$$_${ZSH_SUBSHELL}_${daemon_pid}() { + emulate -L zsh + setopt err_return no_unset + local fname=${(%):-%N} + local prefix=_gitstatus_cleanup_$$_${ZSH_SUBSHELL}_ + [[ $fname == ${prefix}* ]] || return 0 + local -i daemon_pid=${fname#$prefix} + kill -- -$daemon_pid &>/dev/null || true + } + add-zsh-hook zshexit _gitstatus_cleanup_$$_${ZSH_SUBSHELL}_${daemon_pid} } - zle -F $resp_fd _gitstatus_process_response_${name} - - local reply IFS='' - echo -nE $'hello\x1f\x1e' >&$req_fd - read -r -d $'\x1e' -u $resp_fd -t $timeout reply - [[ $reply == $'hello\x1f0' ]] - - function _gitstatus_cleanup_$$_${ZSH_SUBSHELL}_${daemon_pid}() { - emulate -L zsh - setopt err_return no_unset - local fname=${(%):-%N} - local prefix=_gitstatus_cleanup_$$_${ZSH_SUBSHELL}_ - [[ $fname == ${prefix}* ]] || return 0 - local -i daemon_pid=${fname#$prefix} - kill -- -$daemon_pid &>/dev/null || true - } - add-zsh-hook zshexit _gitstatus_cleanup_$$_${ZSH_SUBSHELL}_${daemon_pid} - [[ $stderr_fd == -1 ]] || { + (( ! stderr_fd )) || { unsetopt xtrace exec 2>&$stderr_fd {stderr_fd}>&- - stderr_fd=-1 + stderr_fd=0 } } gitstatus_start_impl && { typeset -gi GITSTATUS_DAEMON_PID_${name}=$daemon_pid - typeset -gi _GITSTATUS_REQ_FD_${name}=$req_fd - typeset -gi _GITSTATUS_RESP_FD_${name}=$resp_fd - typeset -gi _GITSTATUS_LOCK_FD_${name}=$lock_fd - typeset -gi _GITSTATUS_CLIENT_PID_${name}=$$ - typeset -gi _GITSTATUS_DIRTY_MAX_INDEX_SIZE_${name}=$dirty_max_index_size + (( ! req_fd )) || { + typeset -gi _GITSTATUS_REQ_FD_${name}=$req_fd + typeset -gi _GITSTATUS_RESP_FD_${name}=$resp_fd + typeset -gi _GITSTATUS_LOCK_FD_${name}=$lock_fd + typeset -gi _GITSTATUS_CLIENT_PID_${name}=$$ + typeset -gi _GITSTATUS_DIRTY_MAX_INDEX_SIZE_${name}=$dirty_max_index_size + } unset -f gitstatus_start_impl } || { unsetopt err_return add-zsh-hook -d zshexit _gitstatus_cleanup_$$_${ZSH_SUBSHELL}_${daemon_pid} - [[ $resp_fd -ge 0 ]] && { zle -F $resp_fd; exec {resp_fd}>&- } - [[ $req_fd -ge 0 ]] && exec {req_fd}>&- - [[ $lock_fd -ge 0 ]] && zsystem flock -u $lock_fd - [[ $stderr_fd -ge 0 ]] && { exec 2>&$stderr_fd {stderr_fd}>&- } - [[ $daemon_pid -gt 0 ]] && kill -- -$daemon_pid &>/dev/null + (( $+functions[_gitstatus_process_response_${name}] )) && { + zle -F $resp_fd + unfunction _gitstatus_process_response_${name} + } + (( resp_fd )) && exec {resp_fd}>&- + (( req_fd )) && exec {req_fd}>&- + (( lock_fd )) && zsystem flock -u $lock_fd + (( stderr_fd )) && { exec 2>&$stderr_fd {stderr_fd}>&- } + (( daemon_pid > 0 )) && kill -- -$daemon_pid &>/dev/null rm -f $lock_file $req_fifo $resp_fifo unset -f gitstatus_start_impl @@ -457,7 +478,7 @@ function gitstatus_start() { >&2 awk '{print " " $0}' <$log_file >&2 print -nP '%f' fi - if [[ -n ${GITSTATUS_LOG_LEVEL:-} || ${GITSTATUS_ENABLE_LOGGING:-0} == 1 ]]; then + if [[ ${GITSTATUS_LOG_LEVEL:-} == DEBUG ]]; then >&2 echo -E '' >&2 echo -E ' Your system information:' >&2 print -P '%F{yellow}' @@ -496,17 +517,24 @@ function gitstatus_stop() { local client_pid_var=_GITSTATUS_CLIENT_PID_${name} local dirty_size_var=_GITSTATUS_DIRTY_MAX_INDEX_SIZE_${name} + [[ ${(P)daemon_pid_var:-} != -1 ]] || gitstatus_start -t 0 "$name" 2>/dev/null + local req_fd=${(P)req_fd_var:-} local resp_fd=${(P)resp_fd_var:-} local lock_fd=${(P)lock_fd_var:-} - local daemon_pid=${(P)daemon_pid_var:-} + local daemon_pid=${(P)daemon_pid_var:-0} local cleanup_func=_gitstatus_cleanup_$$_${ZSH_SUBSHELL}_${daemon_pid} - [[ -n $resp_fd ]] && { zle -F $resp_fd; exec {resp_fd}>&- } - [[ -n $req_fd ]] && exec {req_fd}>&- - [[ -n $lock_fd ]] && zsystem flock -u $lock_fd - [[ -n $daemon_pid ]] && kill -- -$daemon_pid &>/dev/null + (( $+functions[_gitstatus_process_response_${name}] )) && { + zle -F $resp_fd + unfunction _gitstatus_process_response_${name} + } + + (( resp_fd )) && exec {resp_fd}>&- + (( req_fd )) && exec {req_fd}>&- + (( lock_fd )) && zsystem flock -u $lock_fd + (( daemon_pid > 0 )) && kill -- -$daemon_pid &>/dev/null unset $req_fd_var $resp_fd_var $lock_fd_var $daemon_pid_var $client_pid_var $dirty_size_var @@ -525,7 +553,8 @@ function gitstatus_stop() { function gitstatus_check() { emulate -L zsh (( ARGC == 1 )) || { echo "usage: gitstatus_check NAME" >&2; return 1 } - [[ -n ${(P)${:-GITSTATUS_DAEMON_PID_${1}}} ]] + local daemon_pid_var=GITSTATUS_DAEMON_PID_${1} + (( ${(P)daemon_pid_var:-0} > 0 )) } (( ${#_gitstatus_opts} )) && setopt ${_gitstatus_opts[@]} -- cgit v1.2.3 From d435235c29c0966295018fe15c64717436f909f6 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 3 Oct 2019 20:14:16 +0200 Subject: take advantage of async gitstatus start to make p10k startup faster --- internal/p10k.zsh | 182 +++++++++++++++++++++++++++---------------------- powerlevel9k.zsh-theme | 16 +++-- 2 files changed, 113 insertions(+), 85 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 12da570a..5d6f0dad 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3359,36 +3359,42 @@ _p9k_save_status() { function _p9k_dump_state() { is-at-least 5.3 || return - local dir=${_p9k_state_file:h} + local dir=${__p9k_dump_file:h} [[ -d $dir ]] || mkdir -pm 0700 $dir || return [[ -w $dir && -z $dir(#qNR) ]] || return - local tmp=$_p9k_state_file.$$-$EPOCHREALTIME-$RANDOM + local tmp=$__p9k_dump_file.$$-$EPOCHREALTIME-$RANDOM local -i fd sysopen -a -m 600 -o creat,trunc -u fd $tmp || return { local include='_POWERLEVEL9K_*|_p9k_*|icons|OS|DEFAULT_COLOR|DEFAULT_COLOR_INVERTED' local exclude='_p9k_gitstatus_*|_p9k_param_sig|_p9k_public_ip|_p9k_prompt|_p9k_prompt_idx' - local _p9k_cached_param_sig=$_p9k_param_sig - typeset -p _p9k_cached_param_sig >&$fd || return + typeset -g __p9k_cached_param_sig=$_p9k_param_sig + typeset -p __p9k_cached_param_sig >&$fd || return + unset __p9k_cached_param_sig + (( $+functions[_p9k_preinit] )) && functions _p9k_preinit >&$fd || return print -r -- '_p9k_restore_state_impl() {' >&$fd || return typeset -pm "($include)~($exclude)" >&$fd || return print -r -- '}' >&$fd || return } always { exec {fd}>&- } - zf_mv -f $tmp $_p9k_state_file - zcompile $_p9k_state_file + zf_mv -f $tmp $__p9k_dump_file || return + zcompile $__p9k_dump_file || zf_rm -f $__p9k_dump_file.zwc } function _p9k_restore_state() { - [[ -z $_p9k_state_file(.zwc|)(#qNW) ]] || return - unset _p9k_cached_param_sig - (( $+functions[_p9k_restore_state_impl] )) && unfunction _p9k_restore_state_impl - source $_p9k_state_file 2>/dev/null || return - [[ $_p9k_cached_param_sig == $_p9k_param_sig ]] || return - (( $+functions[_p9k_restore_state_impl] )) || return - _p9k_restore_state_impl - _p9k_state_restored=1 + { + [[ $__p9k_cached_param_sig == $_p9k_param_sig ]] || return + (( $+functions[_p9k_restore_state_impl] )) || return + _p9k_restore_state_impl + _p9k_state_restored=1 + } always { + unset __p9k_cached_param_sig + if (( !_p9k_state_restored && $+functions[_p9k_preinit] )); then + unfunction _p9k_preinit + (( $+functions[gitstatus_stop] )) && gitstatus_stop POWERLEVEL9K + fi + } } _p9k_precmd_impl() { @@ -4515,75 +4521,90 @@ function _p9k_init_cacheable() { fi } +_p9k_init_vcs() { + _p9k_segment_in_use vcs || return + _p9k_vcs_info_init + if (( $+functions[_p9k_preinit] )); then + (( $+parameters[GITSTATUS_DAEMON_PID_POWERLEVEL9K] )) && gitstatus_start POWERLEVEL9K || _p9k_gitstatus_disabled=1 + return + fi + (( _POWERLEVEL9K_DISABLE_GITSTATUS )) && return + (( $_POWERLEVEL9K_VCS_BACKENDS[(I)git] )) || return + + local gitstatus_dir=${_POWERLEVEL9K_GITSTATUS_DIR:-${__p9k_root_dir}/gitstatus} + if [[ -z $GITSTATUS_DAEMON && $_p9k_uname == i686 && -z $gitstatus_dir/bin/*-i686(-static|)(#qN) ]]; then + _p9k_gitstatus_disabled=1 + >&2 echo -E - "${(%):-[%1FERROR%f]: %BPowerlevel10k%b is unable to use %Bgitstatus%b. Git prompt will be slow.}" + >&2 echo -E - "" + >&2 echo -E - "${(%):-Reason: There is no %Bgitstatusd%b binary for i686 (32-bit Intel architecture).}" + >&2 echo -E - "" + >&2 echo -E - "${(%):-You can:}" + >&2 echo -E - "" + >&2 echo -E - "${(%):- - Do nothing.}" + >&2 echo -E - "" + >&2 echo -E - "${(%):- * You %Bwill%b see this error message every time you start zsh.}" + >&2 echo -E - "${(%):- * Git prompt will be %Bslow%b.}" + >&2 echo -E - "" + >&2 echo -E - "${(%):- - Set %BPOWERLEVEL9K_DISABLE_GITSTATUS=true%b at the bottom of %B$__p9k_zshrc_u%b.}" + >&2 echo -E - "${(%):- You can do this by running the following command:}" + >&2 echo -E - "" + >&2 echo -E - "${(%):- %2Fecho%f %3F'POWERLEVEL9K_DISABLE_GITSTATUS=true'%f >>! $__p9k_zshrc_u}" + >&2 echo -E - "" + >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}" + >&2 echo -E - "${(%):- * Git prompt will be %Bslow%b.}" + >&2 echo -E - "" + >&2 echo -E - "${(%):- - Upgrade to a 64-bit OS.}" + >&2 echo -E - "" + >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}" + >&2 echo -E - "${(%):- * Git prompt will be %Bfast%b.}" + >&2 echo -E - "" + >&2 echo -E - "${(%):- - Compile %Bgitstatusd%b and set %BGITSTATUS_DAEMON=/path/to/gitstatusd%b at}" + >&2 echo -E - "${(%):- the bottom of %B$__p9k_zshrc_u%b. See instructions at}" + >&2 echo -E - "${(%):- https://github.com/romkatv/gitstatus/blob/master/README.md#compiling.}" + >&2 echo -E - "" + >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}" + >&2 echo -E - "${(%):- * Git prompt will be %Bfast%b.}" + return + fi + + local daemon=${GITSTATUS_DAEMON} + if [[ -z $daemon ]]; then + daemon=$gitstatus_dir/bin/gitstatusd- + [[ _p9k_uname_o == Android ]] && daemon+=android || daemon+=${_p9k_uname:l} + daemon+=-${_p9k_uname_m:l} + fi + local -i threads=${GITSTATUS_NUM_THREADS:-0} + if (( threads <= 0 )); then + threads=$(( _p9k_num_cpus * 2 )) + (( threads > 0 )) || threads=8 + (( threads <= 32 )) || threads=32 + fi + eval "function _p9k_preinit() { + source ${(q)gitstatus_dir}/gitstatus.plugin.zsh + GITSTATUS_DAEMON=${(q)daemon} GITSTATUS_NUM_THREADS=$threads \ + GITSTATUS_LOG_LEVEL=${(q)GITSTATUS_LOG_LEVEL} \ + GITSTATUS_ENABLE_LOGGING=${(q)GITSTATUS_ENABLE_LOGGING} gitstatus_start \ + -s $_POWERLEVEL9K_VCS_STAGED_MAX_NUM \ + -u $_POWERLEVEL9K_VCS_UNSTAGED_MAX_NUM \ + -d $_POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM \ + -c $_POWERLEVEL9K_VCS_CONFLICTED_MAX_NUM \ + -m $_POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY \ + -a POWERLEVEL9K + }" + source ${gitstatus_dir}/gitstatus.plugin.zsh + GITSTATUS_DAEMON=$daemon GITSTATUS_NUM_THREADS=$threads gitstatus_start \ + -s $_POWERLEVEL9K_VCS_STAGED_MAX_NUM \ + -u $_POWERLEVEL9K_VCS_UNSTAGED_MAX_NUM \ + -d $_POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM \ + -c $_POWERLEVEL9K_VCS_CONFLICTED_MAX_NUM \ + -m $_POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY \ + POWERLEVEL9K || _p9k_gitstatus_disabled=1 +} + _p9k_init() { _p9k_init_vars - typeset -g _p9k_state_file=${XDG_CACHE_HOME:-~/.cache}/p10k-state-${(%):-%n}.zsh _p9k_restore_state || _p9k_init_cacheable - if _p9k_segment_in_use vcs; then - _p9k_vcs_info_init - if [[ $_POWERLEVEL9K_DISABLE_GITSTATUS == 0 && -n $_POWERLEVEL9K_VCS_BACKENDS[(r)git] ]]; then - local gitstatus_dir=${_POWERLEVEL9K_GITSTATUS_DIR:-${__p9k_root_dir}/gitstatus} - if [[ -z $GITSTATUS_DAEMON && $_p9k_uname == i686 && -z $gitstatus_dir/bin/*-i686(-static|)(#qN) ]]; then - _p9k_gitstatus_disabled=1 - >&2 echo -E - "${(%):-[%1FERROR%f]: %BPowerlevel10k%b is unable to use %Bgitstatus%b. Git prompt will be slow.}" - >&2 echo -E - "" - >&2 echo -E - "${(%):-Reason: There is no %Bgitstatusd%b binary for i686 (32-bit Intel architecture).}" - >&2 echo -E - "" - >&2 echo -E - "${(%):-You can:}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- - Do nothing.}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- * You %Bwill%b see this error message every time you start zsh.}" - >&2 echo -E - "${(%):- * Git prompt will be %Bslow%b.}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- - Set %BPOWERLEVEL9K_DISABLE_GITSTATUS=true%b at the bottom of %B$__p9k_zshrc_u%b.}" - >&2 echo -E - "${(%):- You can do this by running the following command:}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- %2Fecho%f %3F'POWERLEVEL9K_DISABLE_GITSTATUS=true'%f >>! $__p9k_zshrc_u}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}" - >&2 echo -E - "${(%):- * Git prompt will be %Bslow%b.}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- - Upgrade to a 64-bit OS.}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}" - >&2 echo -E - "${(%):- * Git prompt will be %Bfast%b.}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- - Compile %Bgitstatusd%b and set %BGITSTATUS_DAEMON=/path/to/gitstatusd%b at}" - >&2 echo -E - "${(%):- the bottom of %B$__p9k_zshrc_u%b. See instructions at}" - >&2 echo -E - "${(%):- https://github.com/romkatv/gitstatus/blob/master/README.md#compiling.}" - >&2 echo -E - "" - >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}" - >&2 echo -E - "${(%):- * Git prompt will be %Bfast%b.}" - else - local -i daemon threads - if (( ! $+GITSTATUS_DAEMON )); then - local os=$_p9k_uname - [[ $_p9k_uname == Linux && _p9k_uname_o == Android ]] && os=Android - typeset -g GITSTATUS_DAEMON=$gitstatus_dir/bin/gitstatusd-${os:l}-${_p9k_uname_m:l} - daemon=1 - fi - if (( ! $+GITSTATUS_NUM_THREADS )); then - typeset -gi GITSTATUS_NUM_THREADS=$(( _p9k_num_cpus * 2 )) - (( GITSTATUS_NUM_THREADS > 0 )) || GITSTATUS_NUM_THREADS=8 - (( GITSTATUS_NUM_THREADS <= 32 )) || GITSTATUS_NUM_THREADS=32 - threads=1 - fi - source $gitstatus_dir/gitstatus.plugin.zsh - gitstatus_start \ - -s $_POWERLEVEL9K_VCS_STAGED_MAX_NUM \ - -u $_POWERLEVEL9K_VCS_UNSTAGED_MAX_NUM \ - -d $_POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM \ - -c $_POWERLEVEL9K_VCS_CONFLICTED_MAX_NUM \ - -m $_POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY \ - POWERLEVEL9K || _p9k_gitstatus_disabled=1 - (( daemon )) && unset GITSTATUS_DAEMON - (( threads )) && unset GITSTATUS_NUM_THREADS - fi - fi - fi - if _p9k_segment_in_use todo; then local todo=$commands[todo.sh] if [[ -n $todo ]]; then @@ -4622,6 +4643,7 @@ _p9k_init() { fi _p9k_init_async_pump + _p9k_init_vcs } _p9k_deinit() { @@ -4824,7 +4846,7 @@ zmodload zsh/parameter zmodload zsh/system zmodload -F zsh/stat b:zstat zmodload -F zsh/net/socket b:zsocket -zmodload -F zsh/files b:zf_mv +zmodload -F zsh/files b:zf_mv b:zf_rm _p9k_init_ssh prompt_powerlevel9k_setup diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 9d2847ce..5fc89041 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -17,7 +17,8 @@ [[ ! -o 'no_brace_expand' ]] || _p9k_src_opts+=('no_brace_expand') 'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' -typeset -g __p9k_root_dir="${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}}" +typeset -g __p9k_root_dir=${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}} +typeset -g __p9k_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh () { emulate -L zsh @@ -27,10 +28,15 @@ typeset -g __p9k_root_dir="${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}}" return fi typeset -gr __p9k_sourced=1 - local f - for f in $__p9k_root_dir/{powerlevel9k.zsh-theme,powerlevel10k.zsh-theme,internal/p10k.zsh,internal/icons.zsh,internal/configure.zsh,gitstatus/gitstatus.plugin.zsh}; do - [[ $f.zwc -nt $f ]] || zcompile $f - done + if [[ -w $__p9k_root_dir && -w $__p9k_root_dir/internal && -w $__p9k_root_dir/gitstatus && ${(%):-%#} == % ]]; then + local f + for f in $__p9k_root_dir/{powerlevel9k.zsh-theme,powerlevel10k.zsh-theme,internal/p10k.zsh,internal/icons.zsh,internal/configure.zsh,gitstatus/gitstatus.plugin.zsh}; do + [[ $f.zwc -nt $f ]] || zcompile $f + done + fi + if [[ -z $__p9k_dump_file(.zwc|)(#qNW) ]] && source $__p9k_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then + _p9k_preinit + fi source $__p9k_root_dir/internal/p10k.zsh || true } -- cgit v1.2.3 From de00d42d6e3f82625b453461fae0deb56bd65006 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 3 Oct 2019 20:41:21 +0200 Subject: don't zcompile state dump when root --- internal/p10k.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 5d6f0dad..2b6519df 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3379,7 +3379,9 @@ function _p9k_dump_state() { exec {fd}>&- } zf_mv -f $tmp $__p9k_dump_file || return - zcompile $__p9k_dump_file || zf_rm -f $__p9k_dump_file.zwc + if [[ ${(%):-%#} == % ]]; then + zcompile $__p9k_dump_file || zf_rm -f $__p9k_dump_file.zwc + fi } function _p9k_restore_state() { -- cgit v1.2.3 From 4faa24a23ddef72187267ef1e03ef7573a6ae377 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 3 Oct 2019 20:42:35 +0200 Subject: require zsh >= 5.4 for state dumps --- internal/p10k.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 2b6519df..08f5f95a 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3358,7 +3358,7 @@ _p9k_save_status() { } function _p9k_dump_state() { - is-at-least 5.3 || return + is-at-least 5.4 || return # `typeset -g` doesn't roundtrip in zsh prior to 5.4. local dir=${__p9k_dump_file:h} [[ -d $dir ]] || mkdir -pm 0700 $dir || return [[ -w $dir && -z $dir(#qNR) ]] || return -- cgit v1.2.3 From c0cb09991e887c01d01651bf35474b5b794be8f8 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 3 Oct 2019 22:05:15 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index f9a12ae5..7fc0a58e 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -59,7 +59,6 @@ autoload -Uz add-zsh-hook zmodload zsh/datetime zsh/system -zmodload -F zsh/files b:zf_rm # Retrives status of a git repo from a directory under its working tree. # @@ -384,7 +383,7 @@ function gitstatus_start() { echo -nE $'bye\x1f0\x1e'" local setsid=${commands[setsid]:-/usr/local/opt/util-linux/bin/setsid} [[ -x $setsid ]] && setsid=${(q)setsid} || setsid= - cmd="cd /; $setsid zsh -dfxc ${(q)cmd} &!" + cmd="cd /; read; $setsid zsh -dfxc ${(q)cmd} &!; rm -f ${(q)req_fifo} ${(q)resp_fifo} ${(q)lock_file}" # We use `zsh -c` instead of plain {} or () to work around bugs in zplug (it hangs on # startup). Double fork is to daemonize, and so is `setsid`. Note that on macOS `setsid` has # to be installed manually by running `brew install util-linux`. @@ -392,8 +391,7 @@ function gitstatus_start() { sysopen -w -o cloexec,sync -u req_fd $req_fifo sysopen -r -o cloexec -u resp_fd $resp_fifo - zf_rm -f $req_fifo $resp_fifo $lock_file - echo -nE $'hello\x1f\x1e' >&$req_fd + echo -nE $'0\nhello\x1f\x1e' >&$req_fd } (( async )) && { -- cgit v1.2.3 From 6f11dca7d36415479ff26c7e37efed83dc13df9e Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 3 Oct 2019 22:15:30 +0200 Subject: update loading time benchmarks --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 94674687..de15a27e 100644 --- a/README.md +++ b/README.md @@ -262,9 +262,8 @@ prompt latency when using Powerlevel10k, please ### Is Powerlevel10k fast to load? -The amount of time it takes for Powerlevel10k to render the first prompt is singnificantly higher -than for the subsequent prompts. In comparison to other ZSH themes, Powerlevel10k loading latency -is unremarkable. Powerlevel10k is neither fast nor slow to load. +The amount of time it takes for Powerlevel10k to render the first prompt is higher than for the +subsequent prompts but it's still fairly fast. Time to first prompt can be measured with the following benchmark: @@ -272,13 +271,12 @@ Time to first prompt can be measured with the following benchmark: time (repeat 100 zsh -dfis <<< 'source ~/powerlevel10k/powerlevel10k.zsh-theme') ``` -On the same machine as in the [prompt benchmark](#is-it-really-fast) this results in 59.7 ms per +On the same machine as in the [prompt benchmark](#is-it-really-fast) this results in 36.9 ms per invocation when executed in a small git repository (I used the `powerlevel10k` repo itself). For comparison, the same benchmark gives 171 ms for powerlevel9k/master and 505 ms for powerlevel9k/next. -*Note: Powerlevel10k startup latency can be reduced by about 15% by compiling its source files with -`zcompile`.* +*Note: Powerlevel10k is significantly faster to load with zsh version 5.4 and above.* ### Does Powerlevel10k always render exactly the same prompt as Powerlevel9k given the same config? -- cgit v1.2.3 From 2862e5f3950e449bc5cbffd00dd43a8806582ccb Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 4 Oct 2019 08:00:06 +0200 Subject: replace ubuntu with archlinux in the docker command; it's faster to install --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index de15a27e..15adbc61 100644 --- a/README.md +++ b/README.md @@ -155,9 +155,9 @@ Try Powerlevel10k in Docker. You can safely make any changes to the file system the theme. Once you exit zsh, the image is deleted. ```zsh -docker run -e LANG=C.UTF-8 -e LC_ALL=C.UTF-8 -e TERM -it --rm ubuntu bash -uexc ' - cd && apt update && apt install -y zsh git - git clone https://github.com/romkatv/powerlevel10k.git +docker run -e LANG=en_US.utf8 -e TERM -it --rm archlinux/base bash -uexc ' + pacman -Sy --noconfirm zsh git + git clone https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k echo "source ~/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc cd ~/powerlevel10k exec zsh' -- cgit v1.2.3 From 9c8cf7ac5f511648e40865941bccf90b7afaf80e Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 4 Oct 2019 08:55:15 +0200 Subject: dump state even if the cache directory is world-readable --- internal/p10k.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 08f5f95a..12e9e89c 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3361,7 +3361,7 @@ function _p9k_dump_state() { is-at-least 5.4 || return # `typeset -g` doesn't roundtrip in zsh prior to 5.4. local dir=${__p9k_dump_file:h} [[ -d $dir ]] || mkdir -pm 0700 $dir || return - [[ -w $dir && -z $dir(#qNR) ]] || return + [[ -w $dir ]] || return local tmp=$__p9k_dump_file.$$-$EPOCHREALTIME-$RANDOM local -i fd sysopen -a -m 600 -o creat,trunc -u fd $tmp || return -- cgit v1.2.3 From 93c19e1d626900bfa3523ce122a19ecc1ffd12b6 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 4 Oct 2019 09:21:49 +0200 Subject: run preinit asap --- powerlevel9k.zsh-theme | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 5fc89041..7c8c5bdb 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -27,6 +27,9 @@ typeset -g __p9k_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh prompt_powerlevel9k_setup return fi + if [[ -z $__p9k_dump_file(.zwc|)(#qNW) ]] && source $__p9k_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then + _p9k_preinit + fi typeset -gr __p9k_sourced=1 if [[ -w $__p9k_root_dir && -w $__p9k_root_dir/internal && -w $__p9k_root_dir/gitstatus && ${(%):-%#} == % ]]; then local f @@ -34,9 +37,6 @@ typeset -g __p9k_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh [[ $f.zwc -nt $f ]] || zcompile $f done fi - if [[ -z $__p9k_dump_file(.zwc|)(#qNW) ]] && source $__p9k_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then - _p9k_preinit - fi source $__p9k_root_dir/internal/p10k.zsh || true } -- cgit v1.2.3 From 8a11e83fe1a60ccbd17586ce08770908df6495d5 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 4 Oct 2019 09:22:02 +0200 Subject: disable aliases --- powerlevel9k.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 7c8c5bdb..36307b4e 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -22,7 +22,7 @@ typeset -g __p9k_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh () { emulate -L zsh - setopt no_hist_expand extended_glob no_prompt_bang no_prompt_subst prompt_percent + setopt no_hist_expand extended_glob no_prompt_bang no_prompt_subst prompt_percent no_aliases if (( $+__p9k_sourced )); then prompt_powerlevel9k_setup return -- cgit v1.2.3 From 6765b618239d3c6815339468393d3354f48b1589 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 4 Oct 2019 09:44:21 +0200 Subject: replace eval with (e) --- internal/p10k.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 12e9e89c..4ce09210 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1513,7 +1513,7 @@ prompt_dir() { content=$pref$content$suf fi - (( expand )) && eval "_p9k_prompt_length \"\${\${_p9k_d::=0}+}$content\"" || _p9k_ret= + (( expand )) && _p9k_prompt_length "${(e):-"\${\${_p9k_d::=0}+}$content"}" || _p9k_ret= _p9k_cache_set "$state" "$icon" "$expand" "$content" $_p9k_ret fi -- cgit v1.2.3 From f8314e59591788ad19b10abff655897eddaac414 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 4 Oct 2019 09:48:53 +0200 Subject: stop autoloading and running "color"; p10k does not use it anymore; people who need it can autoload it themselves --- internal/p10k.zsh | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 4ce09210..62ca8638 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -4839,7 +4839,6 @@ function p10k() { # Hook for zplugin. powerlevel10k_plugin_unload() { prompt_powerlevel9k_teardown; } -autoload -Uz colors && colors autoload -Uz add-zsh-hook zmodload zsh/datetime -- cgit v1.2.3 From adfdf198b7576a9d445c7afceecd2591c66d40eb Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 4 Oct 2019 10:06:13 +0200 Subject: update loading time benchmark --- README.md | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 15adbc61..e42d551a 100644 --- a/README.md +++ b/README.md @@ -262,21 +262,17 @@ prompt latency when using Powerlevel10k, please ### Is Powerlevel10k fast to load? -The amount of time it takes for Powerlevel10k to render the first prompt is higher than for the -subsequent prompts but it's still fairly fast. +Yes, provided that you are using ZSH >= 5.4. -Time to first prompt can be measured with the following benchmark: +Loading time, or time to first prompt, can be measured with the following benchmark: ```zsh -time (repeat 100 zsh -dfis <<< 'source ~/powerlevel10k/powerlevel10k.zsh-theme') +time (repeat 1000 zsh -dfis <<< 'source ~/powerlevel10k/powerlevel10k.zsh-theme') ``` -On the same machine as in the [prompt benchmark](#is-it-really-fast) this results in 36.9 ms per -invocation when executed in a small git repository (I used the `powerlevel10k` repo itself). For -comparison, the same benchmark gives 171 ms for powerlevel9k/master and 505 ms for -powerlevel9k/next. - -*Note: Powerlevel10k is significantly faster to load with zsh version 5.4 and above.* +Running this command with `~/powerlevel10k` as the current directory on the same machine as in the +[prompt benchmark](#is-it-really-fast) takes 29 seconds (29 ms per invocation). This is about 6 +times faster than powerlevel9k/master and 17 times faster than powerlevel9k/next. ### Does Powerlevel10k always render exactly the same prompt as Powerlevel9k given the same config? -- cgit v1.2.3 From 195a0910d191abf619b6939c679d759bb800c4a1 Mon Sep 17 00:00:00 2001 From: Mark Trolley Date: Fri, 4 Oct 2019 17:07:32 -0400 Subject: Correct typo when replacing config file --- internal/wizard.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index f42e6cd3..a2e078eb 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -1464,7 +1464,7 @@ clear flowing +c Powerlevel10k configuration has been written to %2F$__p9k_cfg_path_u%f. if [[ -n $config_backup ]]; then - flowing +c The backup of the previuos version is at %3F$config_backup_u%f. + flowing +c The backup of the previous version is at %3F$config_backup_u%f. fi if (( write_config )); then -- cgit v1.2.3 From 6d16760253c0a0a09858ccfac288ec379dc815f1 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 5 Oct 2019 09:57:13 +0200 Subject: bug fix: don't leave temp state dumps if gitstatus is disabled --- internal/p10k.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 62ca8638..a4cdcc96 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3371,7 +3371,7 @@ function _p9k_dump_state() { typeset -g __p9k_cached_param_sig=$_p9k_param_sig typeset -p __p9k_cached_param_sig >&$fd || return unset __p9k_cached_param_sig - (( $+functions[_p9k_preinit] )) && functions _p9k_preinit >&$fd || return + (( $+functions[_p9k_preinit] )) && { functions _p9k_preinit >&$fd || return } print -r -- '_p9k_restore_state_impl() {' >&$fd || return typeset -pm "($include)~($exclude)" >&$fd || return print -r -- '}' >&$fd || return -- cgit v1.2.3 From bacb43775d61aac4cd110842f321baa4e90386cd Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 5 Oct 2019 10:43:50 +0200 Subject: don't unsetopt aliases when the theme is sourced twice --- powerlevel9k.zsh-theme | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 36307b4e..7221b8f5 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -11,12 +11,14 @@ ################################################################ # Temporarily change options. -'builtin' 'local' '-a' '_p9k_src_opts' -[[ ! -o 'aliases' ]] || _p9k_src_opts+=('aliases') -[[ ! -o 'sh_glob' ]] || _p9k_src_opts+=('sh_glob') -[[ ! -o 'no_brace_expand' ]] || _p9k_src_opts+=('no_brace_expand') +'builtin' 'local' '-a' '__p9k_src_opts' +[[ ! -o 'aliases' ]] || __p9k_src_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || __p9k_src_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || __p9k_src_opts+=('no_brace_expand') 'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' +echo saved ${__p9k_src_opts[@]} + typeset -g __p9k_root_dir=${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}} typeset -g __p9k_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh @@ -40,5 +42,6 @@ typeset -g __p9k_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh source $__p9k_root_dir/internal/p10k.zsh || true } -(( ${#_p9k_src_opts} )) && setopt ${_p9k_src_opts[@]} -'builtin' 'unset' '_p9k_src_opts' +echo setopt ${__p9k_src_opts[@]} +(( ${#__p9k_src_opts} )) && setopt ${__p9k_src_opts[@]} +'builtin' 'unset' '__p9k_src_opts' -- cgit v1.2.3 From e1f5e46c9cdfb356708f50e3d607eadbf578fb48 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 5 Oct 2019 11:37:44 +0200 Subject: remove debug output --- powerlevel9k.zsh-theme | 3 --- 1 file changed, 3 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 7221b8f5..0c31ba80 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -17,8 +17,6 @@ [[ ! -o 'no_brace_expand' ]] || __p9k_src_opts+=('no_brace_expand') 'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' -echo saved ${__p9k_src_opts[@]} - typeset -g __p9k_root_dir=${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}} typeset -g __p9k_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh @@ -42,6 +40,5 @@ typeset -g __p9k_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh source $__p9k_root_dir/internal/p10k.zsh || true } -echo setopt ${__p9k_src_opts[@]} (( ${#__p9k_src_opts} )) && setopt ${__p9k_src_opts[@]} 'builtin' 'unset' '__p9k_src_opts' -- cgit v1.2.3 From ad48c1e77ae0028543e8ab082eafe56aaa399572 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 5 Oct 2019 18:07:55 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/bin/gitstatusd-darwin-x86_64 | Bin 2095156 -> 2095092 bytes gitstatus/bin/gitstatusd-linux-x86_64 | Bin 2336008 -> 2340104 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/gitstatus/bin/gitstatusd-darwin-x86_64 b/gitstatus/bin/gitstatusd-darwin-x86_64 index e5c46cc2..fb4e4a02 100755 Binary files a/gitstatus/bin/gitstatusd-darwin-x86_64 and b/gitstatus/bin/gitstatusd-darwin-x86_64 differ diff --git a/gitstatus/bin/gitstatusd-linux-x86_64 b/gitstatus/bin/gitstatusd-linux-x86_64 index e81bb09a..36691cf4 100755 Binary files a/gitstatus/bin/gitstatusd-linux-x86_64 and b/gitstatus/bin/gitstatusd-linux-x86_64 differ -- cgit v1.2.3 From b73042cf43737690d0bae8f3259287c6c9123043 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sat, 5 Oct 2019 18:14:17 +0200 Subject: simplify and speed up gitstatus/pull-upstream.zsh --- gitstatus/pull-upstream.zsh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/gitstatus/pull-upstream.zsh b/gitstatus/pull-upstream.zsh index 2cb758a5..05995da4 100755 --- a/gitstatus/pull-upstream.zsh +++ b/gitstatus/pull-upstream.zsh @@ -9,10 +9,10 @@ setopt err_exit no_unset pipe_fail extended_glob xtrace readonly GITSTATUS_DIR GITSTATUS_URL readonly -a IGNORE=(pull-upstream.zsh README.md) -function pull() { - local repo && repo=$(mktemp -d ${TMPDIR:-/tmp}/gitstatus-pull-upstream.XXXXXXXXXX) +() { + local repo && repo="$(mktemp -d ${TMPDIR:-/tmp}/gitstatus-pull-upstream.XXXXXXXXXX)" trap "rm -rf ${(q)repo}" EXIT - git clone $GITSTATUS_URL $repo + git clone --depth 1 --single-branch $GITSTATUS_URL $repo local dst for dst in $GITSTATUS_DIR/**/*(.,@); do @@ -22,9 +22,7 @@ function pull() { [[ -f $src ]] && { mkdir -p ${dst:h} && cp -f $src $dst || return } || { - rm $dst + rm -f $dst } done } - -pull -- cgit v1.2.3 From 99c9a2ea25aa5da796a96557c1e5238118b4ddb2 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sun, 6 Oct 2019 10:29:23 +0200 Subject: write function _p9k_preinit directly instead of roundtripping it through eval + functions --- internal/p10k.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index a4cdcc96..2dd51fa9 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3367,11 +3367,11 @@ function _p9k_dump_state() { sysopen -a -m 600 -o creat,trunc -u fd $tmp || return { local include='_POWERLEVEL9K_*|_p9k_*|icons|OS|DEFAULT_COLOR|DEFAULT_COLOR_INVERTED' - local exclude='_p9k_gitstatus_*|_p9k_param_sig|_p9k_public_ip|_p9k_prompt|_p9k_prompt_idx' + local exclude='_p9k_gitstatus_*|_p9k_param_sig|_p9k_public_ip|_p9k_prompt|_p9k_prompt_idx|_p9k_async_pump_*' typeset -g __p9k_cached_param_sig=$_p9k_param_sig typeset -p __p9k_cached_param_sig >&$fd || return unset __p9k_cached_param_sig - (( $+functions[_p9k_preinit] )) && { functions _p9k_preinit >&$fd || return } + (( $+_p9k_preinit )) && { print -r -- $_p9k_preinit >&$fd || return } print -r -- '_p9k_restore_state_impl() {' >&$fd || return typeset -pm "($include)~($exclude)" >&$fd || return print -r -- '}' >&$fd || return @@ -4368,7 +4368,7 @@ _p9k_must_init() { '${ZSH_VERSION}' '${ZSH_PATCHLEVEL}' '${(%):-%n}' '${GITSTATUS_LOG_LEVEL}' '${GITSTATUS_ENABLE_LOGGING}' '${GITSTATUS_DAEMON}' '${GITSTATUS_NUM_THREADS}' '${DEFAULT_USER}' '${ZLE_RPROMPT_INDENT}' '${P9K_SSH}' '${__p9k_ksh_arrays}' - '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v0') + '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v1') IFS=$'\2' param_sig="${(e)param_sig}" [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit @@ -4527,7 +4527,7 @@ _p9k_init_vcs() { _p9k_segment_in_use vcs || return _p9k_vcs_info_init if (( $+functions[_p9k_preinit] )); then - (( $+parameters[GITSTATUS_DAEMON_PID_POWERLEVEL9K] )) && gitstatus_start POWERLEVEL9K || _p9k_gitstatus_disabled=1 + (( $+GITSTATUS_DAEMON_PID_POWERLEVEL9K )) && gitstatus_start POWERLEVEL9K || _p9k_gitstatus_disabled=1 return fi (( _POWERLEVEL9K_DISABLE_GITSTATUS )) && return @@ -4581,7 +4581,7 @@ _p9k_init_vcs() { (( threads > 0 )) || threads=8 (( threads <= 32 )) || threads=32 fi - eval "function _p9k_preinit() { + typeset -g _p9k_preinit="function _p9k_preinit() { source ${(q)gitstatus_dir}/gitstatus.plugin.zsh GITSTATUS_DAEMON=${(q)daemon} GITSTATUS_NUM_THREADS=$threads \ GITSTATUS_LOG_LEVEL=${(q)GITSTATUS_LOG_LEVEL} \ -- cgit v1.2.3 From 5bd389e707aff21ef43413e1272965bf375ab197 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sun, 6 Oct 2019 10:30:00 +0200 Subject: make __p9k_dump_file readonly to ensure no one unsets it --- powerlevel9k.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 0c31ba80..7bf59736 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -17,8 +17,7 @@ [[ ! -o 'no_brace_expand' ]] || __p9k_src_opts+=('no_brace_expand') 'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' -typeset -g __p9k_root_dir=${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}} -typeset -g __p9k_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh +(( $+__p9k_root_dir )) || typeset -gr __p9k_root_dir=${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}} () { emulate -L zsh @@ -27,6 +26,7 @@ typeset -g __p9k_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh prompt_powerlevel9k_setup return fi + typeset -gr __p9k_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh if [[ -z $__p9k_dump_file(.zwc|)(#qNW) ]] && source $__p9k_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then _p9k_preinit fi -- cgit v1.2.3 From 55a27c1f07f2f1d8225fce6935fc0d5503d63f34 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sun, 6 Oct 2019 10:38:05 +0200 Subject: add POWERLEVEL9K_DEBUG_DUMP_STATE to aid in debugging #244 --- internal/p10k.zsh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 2dd51fa9..cd67dcf6 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3359,6 +3359,10 @@ _p9k_save_status() { function _p9k_dump_state() { is-at-least 5.4 || return # `typeset -g` doesn't roundtrip in zsh prior to 5.4. + if [[ $POWERLEVEL9K_DEBUG_DUMP_STATE == true && -z $__p9k_debug_dump_state ]]; then + __p9k_debug_dump_state=done + setopt xtrace + fi local dir=${__p9k_dump_file:h} [[ -d $dir ]] || mkdir -pm 0700 $dir || return [[ -w $dir ]] || return -- cgit v1.2.3 From d6a336358a1629d262d95e2e147885ca30693673 Mon Sep 17 00:00:00 2001 From: romkatv Date: Sun, 6 Oct 2019 11:38:00 +0200 Subject: replace symbolic links with regular files that "source" --- powerlevel10k.zsh-theme | 45 ++++++++++++++++++++++++++++++++++++++++++++- powerlevel9k.zsh-theme | 45 +-------------------------------------------- prompt_powerlevel10k_setup | 2 +- prompt_powerlevel9k_setup | 2 +- 4 files changed, 47 insertions(+), 47 deletions(-) mode change 120000 => 100644 powerlevel10k.zsh-theme mode change 120000 => 100644 prompt_powerlevel10k_setup mode change 120000 => 100644 prompt_powerlevel9k_setup diff --git a/powerlevel10k.zsh-theme b/powerlevel10k.zsh-theme deleted file mode 120000 index 311575f4..00000000 --- a/powerlevel10k.zsh-theme +++ /dev/null @@ -1 +0,0 @@ -powerlevel9k.zsh-theme \ No newline at end of file diff --git a/powerlevel10k.zsh-theme b/powerlevel10k.zsh-theme new file mode 100644 index 00000000..7bf59736 --- /dev/null +++ b/powerlevel10k.zsh-theme @@ -0,0 +1,44 @@ +# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 +################################################################ +# Powerlevel10k Theme +# https://github.com/romkatv/powerlevel10k +# +# Forked from Powerlevel9k Theme +# https://github.com/bhilburn/powerlevel9k +# +# Which in turn was forked from Agnoster Theme +# https://github.com/robbyrussell/oh-my-zsh/blob/74177c5320b2a1b2f8c4c695c05984b57fd7c6ea/themes/agnoster.zsh-theme +################################################################ + +# Temporarily change options. +'builtin' 'local' '-a' '__p9k_src_opts' +[[ ! -o 'aliases' ]] || __p9k_src_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || __p9k_src_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || __p9k_src_opts+=('no_brace_expand') +'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' + +(( $+__p9k_root_dir )) || typeset -gr __p9k_root_dir=${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}} + +() { + emulate -L zsh + setopt no_hist_expand extended_glob no_prompt_bang no_prompt_subst prompt_percent no_aliases + if (( $+__p9k_sourced )); then + prompt_powerlevel9k_setup + return + fi + typeset -gr __p9k_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh + if [[ -z $__p9k_dump_file(.zwc|)(#qNW) ]] && source $__p9k_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then + _p9k_preinit + fi + typeset -gr __p9k_sourced=1 + if [[ -w $__p9k_root_dir && -w $__p9k_root_dir/internal && -w $__p9k_root_dir/gitstatus && ${(%):-%#} == % ]]; then + local f + for f in $__p9k_root_dir/{powerlevel9k.zsh-theme,powerlevel10k.zsh-theme,internal/p10k.zsh,internal/icons.zsh,internal/configure.zsh,gitstatus/gitstatus.plugin.zsh}; do + [[ $f.zwc -nt $f ]] || zcompile $f + done + fi + source $__p9k_root_dir/internal/p10k.zsh || true +} + +(( ${#__p9k_src_opts} )) && setopt ${__p9k_src_opts[@]} +'builtin' 'unset' '__p9k_src_opts' diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 7bf59736..328cd838 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1,44 +1 @@ -# vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8 -################################################################ -# Powerlevel10k Theme -# https://github.com/romkatv/powerlevel10k -# -# Forked from Powerlevel9k Theme -# https://github.com/bhilburn/powerlevel9k -# -# Which in turn was forked from Agnoster Theme -# https://github.com/robbyrussell/oh-my-zsh/blob/74177c5320b2a1b2f8c4c695c05984b57fd7c6ea/themes/agnoster.zsh-theme -################################################################ - -# Temporarily change options. -'builtin' 'local' '-a' '__p9k_src_opts' -[[ ! -o 'aliases' ]] || __p9k_src_opts+=('aliases') -[[ ! -o 'sh_glob' ]] || __p9k_src_opts+=('sh_glob') -[[ ! -o 'no_brace_expand' ]] || __p9k_src_opts+=('no_brace_expand') -'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' - -(( $+__p9k_root_dir )) || typeset -gr __p9k_root_dir=${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}} - -() { - emulate -L zsh - setopt no_hist_expand extended_glob no_prompt_bang no_prompt_subst prompt_percent no_aliases - if (( $+__p9k_sourced )); then - prompt_powerlevel9k_setup - return - fi - typeset -gr __p9k_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh - if [[ -z $__p9k_dump_file(.zwc|)(#qNW) ]] && source $__p9k_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then - _p9k_preinit - fi - typeset -gr __p9k_sourced=1 - if [[ -w $__p9k_root_dir && -w $__p9k_root_dir/internal && -w $__p9k_root_dir/gitstatus && ${(%):-%#} == % ]]; then - local f - for f in $__p9k_root_dir/{powerlevel9k.zsh-theme,powerlevel10k.zsh-theme,internal/p10k.zsh,internal/icons.zsh,internal/configure.zsh,gitstatus/gitstatus.plugin.zsh}; do - [[ $f.zwc -nt $f ]] || zcompile $f - done - fi - source $__p9k_root_dir/internal/p10k.zsh || true -} - -(( ${#__p9k_src_opts} )) && setopt ${__p9k_src_opts[@]} -'builtin' 'unset' '__p9k_src_opts' +'builtin' 'source' "${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}}/powerlevel10k.zsh-theme" diff --git a/prompt_powerlevel10k_setup b/prompt_powerlevel10k_setup deleted file mode 120000 index 866a1f4a..00000000 --- a/prompt_powerlevel10k_setup +++ /dev/null @@ -1 +0,0 @@ -prompt_powerlevel9k_setup \ No newline at end of file diff --git a/prompt_powerlevel10k_setup b/prompt_powerlevel10k_setup new file mode 100644 index 00000000..328cd838 --- /dev/null +++ b/prompt_powerlevel10k_setup @@ -0,0 +1 @@ +'builtin' 'source' "${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}}/powerlevel10k.zsh-theme" diff --git a/prompt_powerlevel9k_setup b/prompt_powerlevel9k_setup deleted file mode 120000 index 311575f4..00000000 --- a/prompt_powerlevel9k_setup +++ /dev/null @@ -1 +0,0 @@ -powerlevel9k.zsh-theme \ No newline at end of file diff --git a/prompt_powerlevel9k_setup b/prompt_powerlevel9k_setup new file mode 100644 index 00000000..328cd838 --- /dev/null +++ b/prompt_powerlevel9k_setup @@ -0,0 +1 @@ +'builtin' 'source' "${POWERLEVEL9K_INSTALLATION_DIR:-${${(%):-%x}:A:h}}/powerlevel10k.zsh-theme" -- cgit v1.2.3 From 3db63ee611e626f5eac47121f725ffa079ba80d6 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 7 Oct 2019 10:05:50 +0200 Subject: Revert "add POWERLEVEL9K_DEBUG_DUMP_STATE to aid in debugging #244" This reverts commit 55a27c1f07f2f1d8225fce6935fc0d5503d63f34. --- internal/p10k.zsh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index cd67dcf6..2dd51fa9 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3359,10 +3359,6 @@ _p9k_save_status() { function _p9k_dump_state() { is-at-least 5.4 || return # `typeset -g` doesn't roundtrip in zsh prior to 5.4. - if [[ $POWERLEVEL9K_DEBUG_DUMP_STATE == true && -z $__p9k_debug_dump_state ]]; then - __p9k_debug_dump_state=done - setopt xtrace - fi local dir=${__p9k_dump_file:h} [[ -d $dir ]] || mkdir -pm 0700 $dir || return [[ -w $dir ]] || return -- cgit v1.2.3 From 7fb12160d8551fc6c236a70bffb42438ef7d7d6b Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 7 Oct 2019 10:13:13 +0200 Subject: doc cleanup --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e42d551a..2fe9270f 100644 --- a/README.md +++ b/README.md @@ -319,7 +319,7 @@ theme (so that you end up with no theme) and then installing Powerlevel10k manua - **oh-my-zsh:** Open `~/.zshrc` and remove the line that sets `ZSH_THEME`, such as `ZSH_THEME=powerlevel9k/powerlevel9k`. - **antigen:** Open `~/.zshrc` and remove the line that sets `antigen theme`, such as - `antigen theme bhilburn/powerlevel9k powerlevel9k`. + `antigen theme powerlevel9k/powerlevel9k`. 2. Install Powerlevel10k manually. -- cgit v1.2.3 From 3896120d164fc4d8880d4e8a0327b65d90af82b8 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 7 Oct 2019 10:15:34 +0200 Subject: remove git flag that has no effect --- gitstatus/pull-upstream.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitstatus/pull-upstream.zsh b/gitstatus/pull-upstream.zsh index 05995da4..0ec22438 100755 --- a/gitstatus/pull-upstream.zsh +++ b/gitstatus/pull-upstream.zsh @@ -12,7 +12,7 @@ readonly -a IGNORE=(pull-upstream.zsh README.md) () { local repo && repo="$(mktemp -d ${TMPDIR:-/tmp}/gitstatus-pull-upstream.XXXXXXXXXX)" trap "rm -rf ${(q)repo}" EXIT - git clone --depth 1 --single-branch $GITSTATUS_URL $repo + git clone --depth 1 $GITSTATUS_URL $repo local dst for dst in $GITSTATUS_DIR/**/*(.,@); do -- cgit v1.2.3 From f5a548441269a6f0baf2ecb75e163d60d4ca236a Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 7 Oct 2019 10:35:27 +0200 Subject: update docs to recommend cloning powerlevel10k git repo with --depth=1 --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2fe9270f..af7c767f 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ it will generate the same prompt. ### Manual ```zsh -git clone https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k +git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>! ~/.zshrc ``` @@ -73,7 +73,7 @@ somewhere after it. ### Zplug -Add `zplug "romkatv/powerlevel10k", as:theme` to your `~/.zshrc`. +Add `zplug romkatv/powerlevel10k, as:theme, depth:1` to your `~/.zshrc`. ### Zgen @@ -85,9 +85,10 @@ Add `antibody bundle romkatv/powerlevel10k` to your `~/.zshrc`. ### Zplugin -Add `zplugin light romkatv/powerlevel10k` to your `~/.zshrc`. +Add `zplugin ice depth=1; zplugin light romkatv/powerlevel10k` to your `~/.zshrc`. -The use of `zplugin ice` with Powerlevel10k is neither recommended nor officially supported. +The use of `depth` ice is optional. Other types of ice are neither recommended nor officially +supported by Powerlevel10k. ## Configuration -- cgit v1.2.3 From 1b0ac8a623463fe135050886f5ff19f978e06a5b Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 7 Oct 2019 11:32:00 +0200 Subject: bug fix: respect POWERLEVEL9K_DISABLE_GITSTATUS; see #246 --- internal/p10k.zsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 2dd51fa9..629735c0 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -4530,7 +4530,10 @@ _p9k_init_vcs() { (( $+GITSTATUS_DAEMON_PID_POWERLEVEL9K )) && gitstatus_start POWERLEVEL9K || _p9k_gitstatus_disabled=1 return fi - (( _POWERLEVEL9K_DISABLE_GITSTATUS )) && return + if (( _POWERLEVEL9K_DISABLE_GITSTATUS )); then + _p9k_gitstatus_disabled=1 + return + fi (( $_POWERLEVEL9K_VCS_BACKENDS[(I)git] )) || return local gitstatus_dir=${_POWERLEVEL9K_GITSTATUS_DIR:-${__p9k_root_dir}/gitstatus} -- cgit v1.2.3 From 2fd59f5acd332ff64e569e9213d3ded93417aa0f Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 7 Oct 2019 12:03:54 +0200 Subject: replace expansion-based Git status formatter with a function --- config/p10k-classic.zsh | 127 ++++++++++++++++++++++++++++++++---------------- config/p10k-lean.zsh | 127 ++++++++++++++++++++++++++++++++---------------- 2 files changed, 168 insertions(+), 86 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 8c1e36f1..52ba6a7d 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -314,65 +314,107 @@ #####################################[ vcs: git status ]###################################### # Branch icon. Set this parameter to '\uF126 ' for the popular Powerline branch icon. typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= + POWERLEVEL9K_VCS_BRANCH_ICON=${(g::)POWERLEVEL9K_VCS_BRANCH_ICON} # Untracked files icon. It's really a question mark, your font isn't broken. # Change the value of this parameter to show a different icon. typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' + POWERLEVEL9K_VCS_UNTRACKED_ICON=${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON} - # Git status: feature:master#tag ⇣42⇡42 *42 merge ~42 +42 !42 ?42. + # Formatter for Git status. # - # You can edit the lines below to customize how Git status looks. + # Example output: master ⇣42⇡42 *42 merge ~42 +42 !42 ?42. # - # VCS_STATUS parameters are set by gitstatus plugin. See reference: + # You can edit the function to customize how Git status looks. + # + # VCS_STATUS_* parameters are set by gitstatus plugin. See reference: # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. - local vcs='' - # If on a branch... - vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON} - # If local branch name is at most 32 characters long, show it in full. - # This is the equivalent of POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=32. - vcs+='${${${$(( ${#VCS_STATUS_LOCAL_BRANCH}<=32 )):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' - # If local branch name is over 32 characters long, show the first 12 … the last 12. The same as - # POWERLEVEL9K_VCS_SHORTEN_LENGTH=12 with POWERLEVEL9K_VCS_SHORTEN_STRATEGY=truncate_middle. - vcs+=':-${${VCS_STATUS_LOCAL_BRANCH:0:12}//\%/%%}%28F…%76F${${VCS_STATUS_LOCAL_BRANCH: -12}//\%/%%}}}' - # '@72f5c8a' if not on a branch. - vcs+=':-%f@%76F${VCS_STATUS_COMMIT:0:8}}' - # ':master' if the tracking branch name differs from local branch. - vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%f:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}' - # '#tag' if on a tag. - vcs+='${VCS_STATUS_TAG:+%f#%76F${VCS_STATUS_TAG//\%/%%}}' - # ⇣42 if behind the remote. - vcs+='${${VCS_STATUS_COMMITS_BEHIND:#0}:+ %76F⇣${VCS_STATUS_COMMITS_BEHIND}}' - # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. - # If you want '⇣42 ⇡42' instead, replace '${${(M)VCS_STATUS_COMMITS_BEHIND:#0}:+ }' with ' '. - vcs+='${${VCS_STATUS_COMMITS_AHEAD:#0}:+${${(M)VCS_STATUS_COMMITS_BEHIND:#0}:+ }%76F⇡${VCS_STATUS_COMMITS_AHEAD}}' - # *42 if have stashes. - vcs+='${${VCS_STATUS_STASHES:#0}:+ %76F*${VCS_STATUS_STASHES}}' - # 'merge' if the repo is in an unusual state. - vcs+='${VCS_STATUS_ACTION:+ %196F${VCS_STATUS_ACTION//\%/%%}}' - # ~42 if have merge conflicts. - vcs+='${${VCS_STATUS_NUM_CONFLICTED:#0}:+ %196F~${VCS_STATUS_NUM_CONFLICTED}}' - # +42 if have staged changes. - vcs+='${${VCS_STATUS_NUM_STAGED:#0}:+ %178F+${VCS_STATUS_NUM_STAGED}}' - # !42 if have unstaged changes. - vcs+='${${VCS_STATUS_NUM_UNSTAGED:#0}:+ %178F!${VCS_STATUS_NUM_UNSTAGED}}' - # ?42 if have untracked files. It's really a question mark, your font isn't broken. - # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. - # Remove the next line if you don't want to see untracked files at all. - vcs+='${${VCS_STATUS_NUM_UNTRACKED:#0}:+ %39F'${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}'${VCS_STATUS_NUM_UNTRACKED}}' - # If P9K_CONTENT is not empty, leave it unchanged. It's either "loading" or from vcs_info. - vcs="\${P9K_CONTENT:-$vcs}" + function my_git_formatter() { + emulate -L zsh + + if [[ -n $P9K_CONTENT ]]; then + # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from + # gitstatus plugin). VCS_STATUS_* parameters are not available in this case. + typeset -g my_git_format=$P9K_CONTENT + return + fi + + if (( $1 )); then + # Styling for up-to-date Git status. + local meta='%f' # default foreground + local clean='%76F' # green foreground + local modified='%178F' # yellow foreground + local untracked='%39F' # blue foreground + local conflicted='%196F' # red foreground + local loading='%244F' # grey foreground + else + # Styling for incomplete and stale Git status. + local meta='%244F' # grey foreground + local clean='%244F' # grey foreground + local modified='%244F' # grey foreground + local untracked='%244F' # grey foreground + local conflicted='%244F' # grey foreground + local loading='%244F' # grey foreground + fi + + local res + local where # branch name, tag or commit + if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then + res+="${clean}${POWERLEVEL9K_VCS_BRANCH_ICON}" + where=${(V)VCS_STATUS_LOCAL_BRANCH} + elif [[ -n $VCS_STATUS_TAG ]]; then + res+="${meta}#" + where=${(V)VCS_STATUS_TAG} + else + res+="${meta}@" + where=${VCS_STATUS_COMMIT[1,8]} + fi + + # If local branch name or tag is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + (( $#where > 32 )) && where[13,-13]="…" + res+="${clean}${where//\%/%%}" # escape % + + # Show tracking branch name if it differs from local branch. + if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then + res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape % + fi + + # ⇣42 if behind the remote. + (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" + # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. + (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " + (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}" + # *42 if have stashes. + (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" + # 'merge' if the repo is in an unusual state. + [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" + # ~42 if have merge conflicts. + (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" + # +42 if have staged changes. + (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" + # !42 if have unstaged changes. + (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" + # ?42 if have untracked files. It's really a question mark, your font isn't broken. + # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. + # Remove the next line if you don't want to see untracked files at all. + (( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" + + typeset -g my_git_format=$res + } + functions +M -m my_git_formatter && functions -M my_git_formatter # Disable the default Git status formatting. typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true # Install our own Git status formatter. - typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION=$vcs - # When Git status is being refreshed asynchronously, display the last known repo status in grey. - typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION=${${${vcs//\%f}//\%<->F}//\%F\{(\#|)[[:xdigit:]]#(\\|)\}} + typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}' + typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter(0)))+${my_git_format}}' # Enable counters for staged, unstaged, etc. typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 # Icon color. typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76 + typeset -g POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR=244 # Custom icon. # typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION='⭐' # Custom prefix. @@ -383,7 +425,6 @@ # isn't in an svn or hg reposotiry. typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) - typeset -g POWERLEVEL9K_VCS_LOADING_FOREGROUND=246 # These settings are used for respositories other than Git or when gitstatusd fails and # Powerlevel10k has to fall back to using vcs_info. typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76 diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 4693b363..5e7d5fab 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -294,65 +294,107 @@ #####################################[ vcs: git status ]###################################### # Branch icon. Set this parameter to '\uF126 ' for the popular Powerline branch icon. typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= + POWERLEVEL9K_VCS_BRANCH_ICON=${(g::)POWERLEVEL9K_VCS_BRANCH_ICON} # Untracked files icon. It's really a question mark, your font isn't broken. # Change the value of this parameter to show a different icon. typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' + POWERLEVEL9K_VCS_UNTRACKED_ICON=${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON} - # Git status: feature:master#tag ⇣42⇡42 *42 merge ~42 +42 !42 ?42. + # Formatter for Git status. # - # You can edit the lines below to customize how Git status looks. + # Example output: master ⇣42⇡42 *42 merge ~42 +42 !42 ?42. # - # VCS_STATUS parameters are set by gitstatus plugin. See reference: + # You can edit the function to customize how Git status looks. + # + # VCS_STATUS_* parameters are set by gitstatus plugin. See reference: # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. - local vcs='' - # If on a branch... - vcs+='${${VCS_STATUS_LOCAL_BRANCH:+%76F'${(g::)POWERLEVEL9K_VCS_BRANCH_ICON} - # If local branch name is at most 32 characters long, show it in full. - # This is the equivalent of POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH=32. - vcs+='${${${$(( ${#VCS_STATUS_LOCAL_BRANCH}<=32 )):#0}:+${VCS_STATUS_LOCAL_BRANCH//\%/%%}}' - # If local branch name is over 32 characters long, show the first 12 … the last 12. The same as - # POWERLEVEL9K_VCS_SHORTEN_LENGTH=12 with POWERLEVEL9K_VCS_SHORTEN_STRATEGY=truncate_middle. - vcs+=':-${${VCS_STATUS_LOCAL_BRANCH:0:12}//\%/%%}%28F…%76F${${VCS_STATUS_LOCAL_BRANCH: -12}//\%/%%}}}' - # '@72f5c8a' if not on a branch. - vcs+=':-%f@%76F${VCS_STATUS_COMMIT:0:8}}' - # ':master' if the tracking branch name differs from local branch. - vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%f:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}' - # '#tag' if on a tag. - vcs+='${VCS_STATUS_TAG:+%f#%76F${VCS_STATUS_TAG//\%/%%}}' - # ⇣42 if behind the remote. - vcs+='${${VCS_STATUS_COMMITS_BEHIND:#0}:+ %76F⇣${VCS_STATUS_COMMITS_BEHIND}}' - # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. - # If you want '⇣42 ⇡42' instead, replace '${${(M)VCS_STATUS_COMMITS_BEHIND:#0}:+ }' with ' '. - vcs+='${${VCS_STATUS_COMMITS_AHEAD:#0}:+${${(M)VCS_STATUS_COMMITS_BEHIND:#0}:+ }%76F⇡${VCS_STATUS_COMMITS_AHEAD}}' - # *42 if have stashes. - vcs+='${${VCS_STATUS_STASHES:#0}:+ %76F*${VCS_STATUS_STASHES}}' - # 'merge' if the repo is in an unusual state. - vcs+='${VCS_STATUS_ACTION:+ %196F${VCS_STATUS_ACTION//\%/%%}}' - # ~42 if have merge conflicts. - vcs+='${${VCS_STATUS_NUM_CONFLICTED:#0}:+ %196F~${VCS_STATUS_NUM_CONFLICTED}}' - # +42 if have staged changes. - vcs+='${${VCS_STATUS_NUM_STAGED:#0}:+ %178F+${VCS_STATUS_NUM_STAGED}}' - # !42 if have unstaged changes. - vcs+='${${VCS_STATUS_NUM_UNSTAGED:#0}:+ %178F!${VCS_STATUS_NUM_UNSTAGED}}' - # ?42 if have untracked files. It's really a question mark, your font isn't broken. - # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. - # Remove the next line if you don't want to see untracked files at all. - vcs+='${${VCS_STATUS_NUM_UNTRACKED:#0}:+ %39F'${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}'${VCS_STATUS_NUM_UNTRACKED}}' - # If P9K_CONTENT is not empty, leave it unchanged. It's either "loading" or from vcs_info. - vcs="\${P9K_CONTENT:-$vcs}" + function my_git_formatter() { + emulate -L zsh + + if [[ -n $P9K_CONTENT ]]; then + # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from + # gitstatus plugin). VCS_STATUS_* parameters are not available in this case. + typeset -g my_git_format=$P9K_CONTENT + return + fi + + if (( $1 )); then + # Styling for up-to-date Git status. + local meta='%f' # default foreground + local clean='%76F' # green foreground + local modified='%178F' # yellow foreground + local untracked='%39F' # blue foreground + local conflicted='%196F' # red foreground + local loading='%244F' # grey foreground + else + # Styling for incomplete and stale Git status. + local meta='%244F' # grey foreground + local clean='%244F' # grey foreground + local modified='%244F' # grey foreground + local untracked='%244F' # grey foreground + local conflicted='%244F' # grey foreground + local loading='%244F' # grey foreground + fi + + local res + local where # branch name, tag or commit + if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then + res+="${clean}${POWERLEVEL9K_VCS_BRANCH_ICON}" + where=${(V)VCS_STATUS_LOCAL_BRANCH} + elif [[ -n $VCS_STATUS_TAG ]]; then + res+="${meta}#" + where=${(V)VCS_STATUS_TAG} + else + res+="${meta}@" + where=${VCS_STATUS_COMMIT[1,8]} + fi + + # If local branch name or tag is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + (( $#where > 32 )) && where[13,-13]="…" + res+="${clean}${where//\%/%%}" # escape % + + # Show tracking branch name if it differs from local branch. + if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then + res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape % + fi + + # ⇣42 if behind the remote. + (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" + # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. + (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " + (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}" + # *42 if have stashes. + (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" + # 'merge' if the repo is in an unusual state. + [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" + # ~42 if have merge conflicts. + (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" + # +42 if have staged changes. + (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" + # !42 if have unstaged changes. + (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" + # ?42 if have untracked files. It's really a question mark, your font isn't broken. + # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. + # Remove the next line if you don't want to see untracked files at all. + (( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" + + typeset -g my_git_format=$res + } + functions +M -m my_git_formatter && functions -M my_git_formatter # Disable the default Git status formatting. typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true # Install our own Git status formatter. - typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION=$vcs - # When Git status is being refreshed asynchronously, display the last known repo status in grey. - typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION=${${${vcs//\%f}//\%<->F}//\%F\{(\#|)[[:xdigit:]]#(\\|)\}} + typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}' + typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter(0)))+${my_git_format}}' # Enable counters for staged, unstaged, etc. typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 # Icon color. typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76 + typeset -g POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR=244 # Custom icon. # typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION='⭐' # Custom prefix. @@ -363,7 +405,6 @@ # isn't in an svn or hg reposotiry. typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) - typeset -g POWERLEVEL9K_VCS_LOADING_FOREGROUND=244 # These settings are used for respositories other than Git or when gitstatusd fails and # Powerlevel10k has to fall back to using vcs_info. typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76 -- cgit v1.2.3 From 1888d2cee563cdb289d0804143994fb7e429f6b1 Mon Sep 17 00:00:00 2001 From: romkatv Date: Mon, 7 Oct 2019 21:54:32 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index 7fc0a58e..21feba53 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -60,6 +60,8 @@ autoload -Uz add-zsh-hook zmodload zsh/datetime zsh/system +typeset -g _gitstatus_plugin_dir=${${(%):-%x}:A:h} + # Retrives status of a git repo from a directory under its working tree. # ## Usage: gitstatus_query [OPTION]... NAME @@ -338,8 +340,7 @@ function gitstatus_start() { os="$(uname -s)" && [[ -n $os ]] [[ $os != Linux || "$(uname -o)" != Android ]] || os=Android local arch && arch="$(uname -m)" && [[ -n $arch ]] - local dir && dir=${${(%):-%x}:A:h} - daemon=$dir/bin/gitstatusd-${os:l}-${arch:l} + daemon=$_gitstatus_plugin_dir/bin/gitstatusd-${os:l}-${arch:l} } [[ -x $daemon ]] -- cgit v1.2.3 From b7bd643ae688d9e35de4b3fda8aaaade748491bc Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 8 Oct 2019 09:20:15 +0200 Subject: clarify comments for POWERLEVEL9K_DIR_MAX_LENGTH Make it explicit that POWERLEVEL9K_DIR_MAX_LENGTH isn't the only constraint that may cause directory truncation. See the original description of #250 before this issue was repurposed for something unrelated. --- config/p10k-classic.zsh | 3 ++- config/p10k-lean.zsh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 52ba6a7d..1c910039 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -252,7 +252,8 @@ typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 # Shorten directory if it's longer than this even if there is space for it. The value can # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty, - # directory will be shortened only when prompt doesn't fit. + # directory will be shortened only when prompt doesn't fit or when other parameters demand it + # (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below). typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80 # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this # many columns for typing commands. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 5e7d5fab..7d3d6cba 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -232,7 +232,8 @@ typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 # Shorten directory if it's longer than this even if there is space for it. The value can # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty, - # directory will be shortened only when prompt doesn't fit. + # directory will be shortened only when prompt doesn't fit or when other parameters demand it + # (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below). typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80 # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this # many columns for typing commands. -- cgit v1.2.3 From 6cd22e24e27003181b4b9878a91cc99c6d48eaf1 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 8 Oct 2019 09:46:24 +0200 Subject: avoid spurious console output where is more more than one dir segment --- internal/p10k.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 629735c0..c20a1108 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3251,7 +3251,7 @@ function _p9k_set_prompt() { PROMPT+='${${_p9k_g::=0}+}' fi if [[ $_POWERLEVEL9K_DIR_MAX_LENGTH == <->('%'|) ]]; then - local lim + local lim= if [[ $_POWERLEVEL9K_DIR_MAX_LENGTH[-1] == '%' ]]; then lim="$_p9k_dir_len-$((0.01*$_POWERLEVEL9K_DIR_MAX_LENGTH[1,-2]))*_p9k_clm" else -- cgit v1.2.3 From d4cbe14f066720710fb75fef1fa8e558696345fb Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 8 Oct 2019 13:02:44 +0200 Subject: check for gitstatus.plugin.zsh existence in preinit --- internal/p10k.zsh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index c20a1108..c6a5aff7 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -4585,16 +4585,17 @@ _p9k_init_vcs() { (( threads <= 32 )) || threads=32 fi typeset -g _p9k_preinit="function _p9k_preinit() { - source ${(q)gitstatus_dir}/gitstatus.plugin.zsh - GITSTATUS_DAEMON=${(q)daemon} GITSTATUS_NUM_THREADS=$threads \ - GITSTATUS_LOG_LEVEL=${(q)GITSTATUS_LOG_LEVEL} \ - GITSTATUS_ENABLE_LOGGING=${(q)GITSTATUS_ENABLE_LOGGING} gitstatus_start \ - -s $_POWERLEVEL9K_VCS_STAGED_MAX_NUM \ - -u $_POWERLEVEL9K_VCS_UNSTAGED_MAX_NUM \ - -d $_POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM \ - -c $_POWERLEVEL9K_VCS_CONFLICTED_MAX_NUM \ - -m $_POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY \ - -a POWERLEVEL9K + [[ -r ${(q)gitstatus_dir}/gitstatus.plugin.zsh ]] || return + source ${(q)gitstatus_dir}/gitstatus.plugin.zsh || return + GITSTATUS_DAEMON=${(q)daemon} GITSTATUS_NUM_THREADS=$threads \ + GITSTATUS_LOG_LEVEL=${(q)GITSTATUS_LOG_LEVEL} \ + GITSTATUS_ENABLE_LOGGING=${(q)GITSTATUS_ENABLE_LOGGING} gitstatus_start \ + -s $_POWERLEVEL9K_VCS_STAGED_MAX_NUM \ + -u $_POWERLEVEL9K_VCS_UNSTAGED_MAX_NUM \ + -d $_POWERLEVEL9K_VCS_UNTRACKED_MAX_NUM \ + -c $_POWERLEVEL9K_VCS_CONFLICTED_MAX_NUM \ + -m $_POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY \ + -a POWERLEVEL9K }" source ${gitstatus_dir}/gitstatus.plugin.zsh GITSTATUS_DAEMON=$daemon GITSTATUS_NUM_THREADS=$threads gitstatus_start \ -- cgit v1.2.3 From a891b3c2d1c9837eb3c8a35a92a9183d9798e43f Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 8 Oct 2019 13:05:43 +0200 Subject: bump state version --- internal/p10k.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index c6a5aff7..7993fe7a 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -4368,7 +4368,7 @@ _p9k_must_init() { '${ZSH_VERSION}' '${ZSH_PATCHLEVEL}' '${(%):-%n}' '${GITSTATUS_LOG_LEVEL}' '${GITSTATUS_ENABLE_LOGGING}' '${GITSTATUS_DAEMON}' '${GITSTATUS_NUM_THREADS}' '${DEFAULT_USER}' '${ZLE_RPROMPT_INDENT}' '${P9K_SSH}' '${__p9k_ksh_arrays}' - '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v1') + '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v2') IFS=$'\2' param_sig="${(e)param_sig}" [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit -- cgit v1.2.3 From 4ef1a9bbdd21a2935eb94780b2cb43c6bc042b9e Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 8 Oct 2019 13:46:39 +0200 Subject: add azure prompt segment --- config/p10k-classic.zsh | 7 +++++++ config/p10k-lean.zsh | 7 +++++++ internal/icons.zsh | 5 +++++ internal/p10k.zsh | 15 +++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 1c910039..54d90755 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -59,6 +59,7 @@ kubecontext # current kubernetes context (https://kubernetes.io/) terraform # terraform workspace (https://www.terraform.io) aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) + # azure # azure account name (https://docs.microsoft.com/en-us/cli/azure) context # user@hostname nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) @@ -658,6 +659,12 @@ # Custom icon. # typeset -g POWERLEVEL9K_AWS_VISUAL_IDENTIFIER_EXPANSION='⭐' + ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## + # Azure account name color. + typeset -g POWERLEVEL9K_AZURE_FOREGROUND=32 + # Custom icon. + # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# # Kubernetes context classes for the purpose of using different colors, icons and expansions with # different contexts. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 7d3d6cba..68c34dbd 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -59,6 +59,7 @@ kubecontext # current kubernetes context (https://kubernetes.io/) terraform # terraform workspace (https://www.terraform.io) aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) + # azure # azure account name (https://docs.microsoft.com/en-us/cli/azure) context # user@hostname nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) @@ -718,6 +719,12 @@ # Custom icon. # typeset -g POWERLEVEL9K_AWS_VISUAL_IDENTIFIER_EXPANSION='⭐' + ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## + # Azure account name color. + typeset -g POWERLEVEL9K_AZURE_FOREGROUND=32 + # Custom icon. + # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' + ###############################[ public_ip: public IP address ]############################### # Public IP color. typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=94 diff --git a/internal/icons.zsh b/internal/icons.zsh index 718e1663..b93bbb53 100755 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -114,6 +114,7 @@ function _p9k_init_icons() { TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ DOTNET_ICON '.NET' + AZURE_ICON '\u2601' # ☁ ) ;; 'awesome-fontconfig') @@ -215,6 +216,7 @@ function _p9k_init_icons() { TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ DOTNET_ICON '.NET' + AZURE_ICON '\u2601' # ☁ ) ;; 'awesome-mapped-fontconfig') @@ -320,6 +322,7 @@ function _p9k_init_icons() { TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ DOTNET_ICON '.NET' + AZURE_ICON '\u2601' # ☁ ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -422,6 +425,7 @@ function _p9k_init_icons() { TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ DOTNET_ICON '\uE77F' #  + AZURE_ICON '\uFD03' # ﴃ ) ;; *) @@ -523,6 +527,7 @@ function _p9k_init_icons() { TERRAFORM_ICON '\U1F6E0\u00A0' # 🛠️ PROXY_ICON '\u2B82' # ⮂ DOTNET_ICON '.NET' + AZURE_ICON '\u2601' # ☁ ) ;; esac diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 7993fe7a..24239e27 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3035,6 +3035,21 @@ prompt_java_version() { _p9k_prompt_segment "$0" "red" "white" "JAVA_ICON" 0 '' "${v//\%/%%}" } +prompt_azure() { + (( $+commands[az] )) || return + local cfg=${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json + local -H stat + zstat -H stat -- $cfg 2>/dev/null || return + local sig="$stat[inode].$stat[mtime].$stat[size].$stat[mode]" + if ! _p9k_cache_get $0 || [[ $_p9k_cache_val[1] != $sig ]]; then + local name + name="$(az account show --query name --output tsv 2>/dev/null)" || name= + _p9k_cache_set "$sig" "$name" + fi + [[ -n $_p9k_cache_val[2] ]] || return + _p9k_prompt_segment "$0" "blue" "white" "AZURE_ICON" 0 '' "${_p9k_cache_val[2]//\%/%%}" +} + typeset -gra __p9k_nordvpn_tag=( P9K_NORDVPN_STATUS P9K_NORDVPN_TECHNOLOGY -- cgit v1.2.3 From bbaf6107c3be5f264c6835753ae705b46a056e28 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 8 Oct 2019 13:47:55 +0200 Subject: avoid calling 'functions +M' as it sometimes crashes zsh --- config/p10k-classic.zsh | 2 +- config/p10k-lean.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 54d90755..5ea2cdba 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -404,7 +404,7 @@ typeset -g my_git_format=$res } - functions +M -m my_git_formatter && functions -M my_git_formatter + functions -M my_git_formatter 2>/dev/null # Disable the default Git status formatting. typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 68c34dbd..999738d9 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -384,7 +384,7 @@ typeset -g my_git_format=$res } - functions +M -m my_git_formatter && functions -M my_git_formatter + functions -M my_git_formatter 2>/dev/null # Disable the default Git status formatting. typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true -- cgit v1.2.3 From 0525188402c8e45560cad7e16108d808dfd4f659 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 8 Oct 2019 14:41:48 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index 21feba53..783e7e2b 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -39,6 +39,7 @@ # VCS_STATUS_NUM_CONFLICTED=0 # VCS_STATUS_NUM_STAGED=0 # VCS_STATUS_NUM_UNSTAGED=1 +# VCS_STATUS_NUM_UNSTAGED_DELETED=0 # VCS_STATUS_NUM_UNTRACKED=1 # VCS_STATUS_REMOTE_BRANCH=master # VCS_STATUS_REMOTE_NAME=origin @@ -115,6 +116,11 @@ typeset -g _gitstatus_plugin_dir=${${(%):-%x}:A:h} # VCS_STATUS_TAG The last tag (in lexicographical order) that points to the same # commit as HEAD. # +# Experimental variables. May disappear or have their semantics changed without notice: +# +# VCS_STATUS_NUM_UNSTAGED_DELETED The number of unstaged deleted files. Note that renamed files +# are reported as deleted plus added. +# # The point of reporting -1 as unstaged and untracked is to allow the command to skip scanning # files in large repos. See -m flag of gitstatus_start. # @@ -210,6 +216,7 @@ function _gitstatus_process_response() { typeset -gi VCS_STATUS_COMMITS_BEHIND="${resp[16]}" typeset -gi VCS_STATUS_STASHES="${resp[17]}" typeset -g VCS_STATUS_TAG="${resp[18]}" + typeset -gi VCS_STATUS_NUM_UNSTAGED_DELETED="${resp[19]:-0}" typeset -gi VCS_STATUS_HAS_STAGED=$((VCS_STATUS_NUM_STAGED > 0)) (( dirty_max_index_size >= 0 && VCS_STATUS_INDEX_SIZE > dirty_max_index_size )) && { typeset -gi VCS_STATUS_HAS_UNSTAGED=-1 @@ -242,6 +249,7 @@ function _gitstatus_process_response() { unset VCS_STATUS_COMMITS_BEHIND unset VCS_STATUS_STASHES unset VCS_STATUS_TAG + unset VCS_STATUS_NUM_UNSTAGED_DELETED } (( ! ours )) && (( #header )) && emulate -L zsh && "${header[@]}" || true -- cgit v1.2.3 From 53ce6eb71dc9f5544d527e86058b059647332b16 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 8 Oct 2019 14:42:07 +0200 Subject: save and restore VCS_STATUS_NUM_UNSTAGED_DELETED --- internal/p10k.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 24239e27..87bfc7f9 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -2460,7 +2460,7 @@ $z$VCS_STATUS_HAS_STAGED$z$VCS_STATUS_HAS_UNSTAGED$z$VCS_STATUS_HAS_UNTRACKED\ $z$VCS_STATUS_INDEX_SIZE$z$VCS_STATUS_LOCAL_BRANCH$z$VCS_STATUS_NUM_CONFLICTED\ $z$VCS_STATUS_NUM_STAGED$z$VCS_STATUS_NUM_UNSTAGED$z$VCS_STATUS_NUM_UNTRACKED\ $z$VCS_STATUS_REMOTE_BRANCH$z$VCS_STATUS_REMOTE_NAME$z$VCS_STATUS_REMOTE_URL\ -$z$VCS_STATUS_RESULT$z$VCS_STATUS_STASHES$z$VCS_STATUS_TAG +$z$VCS_STATUS_RESULT$z$VCS_STATUS_STASHES$z$VCS_STATUS_TAG$VCS_STATUS_NUM_UNSTAGED_DELETED } function _p9k_vcs_status_restore() { @@ -2470,6 +2470,7 @@ function _p9k_vcs_status_restore() { VCS_STATUS_NUM_CONFLICTED VCS_STATUS_NUM_STAGED VCS_STATUS_NUM_UNSTAGED \ VCS_STATUS_NUM_UNTRACKED VCS_STATUS_REMOTE_BRANCH VCS_STATUS_REMOTE_NAME \ VCS_STATUS_REMOTE_URL VCS_STATUS_RESULT VCS_STATUS_STASHES VCS_STATUS_TAG \ + VCS_STATUS_NUM_UNSTAGED_DELETED in "${(@0)1}"; do done } @@ -2564,6 +2565,7 @@ function _p9k_vcs_render() { "$VCS_STATUS_COMMITS_BEHIND" "$VCS_STATUS_STASHES" "$VCS_STATUS_TAG" + "$VCS_STATUS_NUM_UNSTAGED_DELETED" ) if [[ $_POWERLEVEL9K_SHOW_CHANGESET == 1 || -z $VCS_STATUS_LOCAL_BRANCH ]]; then cache_key+=$VCS_STATUS_COMMIT -- cgit v1.2.3 From d48ebac02f287bd03053249860722c74d3c1459f Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 8 Oct 2019 14:42:41 +0200 Subject: bump state version --- internal/p10k.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 87bfc7f9..b3df445f 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -4385,7 +4385,7 @@ _p9k_must_init() { '${ZSH_VERSION}' '${ZSH_PATCHLEVEL}' '${(%):-%n}' '${GITSTATUS_LOG_LEVEL}' '${GITSTATUS_ENABLE_LOGGING}' '${GITSTATUS_DAEMON}' '${GITSTATUS_NUM_THREADS}' '${DEFAULT_USER}' '${ZLE_RPROMPT_INDENT}' '${P9K_SSH}' '${__p9k_ksh_arrays}' - '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v2') + '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v3') IFS=$'\2' param_sig="${(e)param_sig}" [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit -- cgit v1.2.3 From eb603f0e7521d0a3cf1cc028cdb3432dca3f6102 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 8 Oct 2019 14:51:16 +0200 Subject: typo --- internal/p10k.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index b3df445f..93c11b3b 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -2460,7 +2460,7 @@ $z$VCS_STATUS_HAS_STAGED$z$VCS_STATUS_HAS_UNSTAGED$z$VCS_STATUS_HAS_UNTRACKED\ $z$VCS_STATUS_INDEX_SIZE$z$VCS_STATUS_LOCAL_BRANCH$z$VCS_STATUS_NUM_CONFLICTED\ $z$VCS_STATUS_NUM_STAGED$z$VCS_STATUS_NUM_UNSTAGED$z$VCS_STATUS_NUM_UNTRACKED\ $z$VCS_STATUS_REMOTE_BRANCH$z$VCS_STATUS_REMOTE_NAME$z$VCS_STATUS_REMOTE_URL\ -$z$VCS_STATUS_RESULT$z$VCS_STATUS_STASHES$z$VCS_STATUS_TAG$VCS_STATUS_NUM_UNSTAGED_DELETED +$z$VCS_STATUS_RESULT$z$VCS_STATUS_STASHES$z$VCS_STATUS_TAG$z$VCS_STATUS_NUM_UNSTAGED_DELETED } function _p9k_vcs_status_restore() { @@ -4385,7 +4385,7 @@ _p9k_must_init() { '${ZSH_VERSION}' '${ZSH_PATCHLEVEL}' '${(%):-%n}' '${GITSTATUS_LOG_LEVEL}' '${GITSTATUS_ENABLE_LOGGING}' '${GITSTATUS_DAEMON}' '${GITSTATUS_NUM_THREADS}' '${DEFAULT_USER}' '${ZLE_RPROMPT_INDENT}' '${P9K_SSH}' '${__p9k_ksh_arrays}' - '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v3') + '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v4') IFS=$'\2' param_sig="${(e)param_sig}" [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit -- cgit v1.2.3 From b56ab6400c8f86ffe6bfeba29d04d5d4388ae463 Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 8 Oct 2019 16:03:39 +0200 Subject: revamp aws_eb_env. it returns the starred entry from the output of "eb list" --- config/p10k-classic.zsh | 7 +++++++ config/p10k-lean.zsh | 7 +++++++ internal/p10k.zsh | 24 ++++++++++++++++++++---- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 5ea2cdba..7b9ae002 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -59,6 +59,7 @@ kubecontext # current kubernetes context (https://kubernetes.io/) terraform # terraform workspace (https://www.terraform.io) aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) + # aws_eb_env # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) # azure # azure account name (https://docs.microsoft.com/en-us/cli/azure) context # user@hostname nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) @@ -659,6 +660,12 @@ # Custom icon. # typeset -g POWERLEVEL9K_AWS_VISUAL_IDENTIFIER_EXPANSION='⭐' + #[ aws_eb_env: aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) ]# + # AWS Elastic Beanstalk environment color. + typeset -g POWERLEVEL9K_AWS_EB_ENV_FOREGROUND=70 + # Custom icon. + # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## # Azure account name color. typeset -g POWERLEVEL9K_AZURE_FOREGROUND=32 diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 999738d9..d350785b 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -59,6 +59,7 @@ kubecontext # current kubernetes context (https://kubernetes.io/) terraform # terraform workspace (https://www.terraform.io) aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) + # aws_eb_env # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) # azure # azure account name (https://docs.microsoft.com/en-us/cli/azure) context # user@hostname nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) @@ -719,6 +720,12 @@ # Custom icon. # typeset -g POWERLEVEL9K_AWS_VISUAL_IDENTIFIER_EXPANSION='⭐' + #[ aws_eb_env: aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) ]# + # AWS Elastic Beanstalk environment color. + typeset -g POWERLEVEL9K_AWS_EB_ENV_FOREGROUND=70 + # Custom icon. + # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## # Azure account name color. typeset -g POWERLEVEL9K_AZURE_FOREGROUND=32 diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 93c11b3b..bf5fd840 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -885,10 +885,26 @@ prompt_aws() { ################################################################ # Current Elastic Beanstalk environment prompt_aws_eb_env() { - [[ -r .elasticbeanstalk/config.yml ]] || return - local v=($(grep environment .elasticbeanstalk/config.yml 2>/dev/null)) - [[ $#v > 1 && -n $v[2] ]] || return - [[ -n $v ]] && _p9k_prompt_segment "$0" black green 'AWS_EB_ICON' 0 '' "${v[2]//\%/%%}" + (( $+commands[eb] )) || return + + local dir=$_p9k_pwd + while true; do + [[ $dir == / ]] && return + [[ -d $dir/.elasticbeanstalk ]] && break + dir=${dir:h} + done + + local -H stat + zstat -H stat -- $dir/.elasticbeanstalk/config.yml 2>/dev/null || return + local sig="$stat[inode].$stat[mtime].$stat[size].$stat[mode]" + if ! _p9k_cache_get $0 $dir || [[ $_p9k_cache_val[1] != $sig ]]; then + local env + env="$(command eb list 2>/dev/null)" || env= + env="${${(@M)${(@f)env}:#\* *}#\* }" + _p9k_cache_set "$sig" "$env" + fi + [[ -n $_p9k_cache_val[2] ]] || return + _p9k_prompt_segment "$0" black green 'AWS_EB_ICON' 0 '' "${_p9k_cache_val[2]//\%/%%}" } ################################################################ -- cgit v1.2.3 From cf8d2414651da5df2cce00b37d6fcb5c584f427f Mon Sep 17 00:00:00 2001 From: romkatv Date: Tue, 8 Oct 2019 16:05:17 +0200 Subject: cleanup --- internal/p10k.zsh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index bf5fd840..1c2b6104 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3055,9 +3055,8 @@ prompt_java_version() { prompt_azure() { (( $+commands[az] )) || return - local cfg=${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json local -H stat - zstat -H stat -- $cfg 2>/dev/null || return + zstat -H stat -- ${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json 2>/dev/null || return local sig="$stat[inode].$stat[mtime].$stat[size].$stat[mode]" if ! _p9k_cache_get $0 || [[ $_p9k_cache_val[1] != $sig ]]; then local name -- cgit v1.2.3 From e02d3f1156c047102f455f6b0086ccbb3879ec79 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 9 Oct 2019 16:24:23 +0200 Subject: don't persist Git state --- internal/p10k.zsh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 1c2b6104..60f06673 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -2470,7 +2470,7 @@ _p9k_vcs_info_init() { function _p9k_vcs_status_save() { local z=$'\0' - _p9k_last_git_prompt[$VCS_STATUS_WORKDIR]=$VCS_STATUS_ACTION$z$VCS_STATUS_COMMIT\ + _p9k_gitstatus_last[$VCS_STATUS_WORKDIR]=$VCS_STATUS_ACTION$z$VCS_STATUS_COMMIT\ $z$VCS_STATUS_COMMITS_AHEAD$z$VCS_STATUS_COMMITS_BEHIND$z$VCS_STATUS_HAS_CONFLICTED\ $z$VCS_STATUS_HAS_STAGED$z$VCS_STATUS_HAS_UNSTAGED$z$VCS_STATUS_HAS_UNTRACKED\ $z$VCS_STATUS_INDEX_SIZE$z$VCS_STATUS_LOCAL_BRANCH$z$VCS_STATUS_NUM_CONFLICTED\ @@ -2493,7 +2493,7 @@ function _p9k_vcs_status_restore() { function _p9k_vcs_status_for_dir() { local dir=$1 while true; do - _p9k_ret=$_p9k_last_git_prompt[$dir] + _p9k_ret=$_p9k_gitstatus_last[$dir] [[ -n $_p9k_ret ]] && return 0 [[ $dir == / ]] && return 1 dir=${dir:h} @@ -2504,7 +2504,7 @@ function _p9k_vcs_status_purge() { local dir=$1 while true; do # unset doesn't work if $dir contains weird shit - _p9k_last_git_prompt[$dir]="" + _p9k_gitstatus_last[$dir]="" _p9k_git_slow[$dir]="" [[ $dir == / ]] && break dir=${dir:h} @@ -3729,10 +3729,10 @@ _p9k_init_vars() { typeset -ga _p9k_right_join typeset -g _p9k_public_ip typeset -g _p9k_todo_file - # git workdir => the last prompt we've shown for it - typeset -gA _p9k_last_git_prompt # git workdir => 1 if gitstatus is slow on it, 0 if it's fast. typeset -gA _p9k_git_slow + # git workdir => the last state we've seen for it + typeset -gA _p9k_gitstatus_last typeset -gi _p9k_gitstatus_disabled typeset -gF _p9k_gitstatus_start_time typeset -g _p9k_prompt @@ -4400,7 +4400,7 @@ _p9k_must_init() { '${ZSH_VERSION}' '${ZSH_PATCHLEVEL}' '${(%):-%n}' '${GITSTATUS_LOG_LEVEL}' '${GITSTATUS_ENABLE_LOGGING}' '${GITSTATUS_DAEMON}' '${GITSTATUS_NUM_THREADS}' '${DEFAULT_USER}' '${ZLE_RPROMPT_INDENT}' '${P9K_SSH}' '${__p9k_ksh_arrays}' - '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v4') + '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v5') IFS=$'\2' param_sig="${(e)param_sig}" [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit -- cgit v1.2.3 From 7f3637ee0d89f8dea6ae4068a21c6f2fcd4bd216 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 9 Oct 2019 17:45:30 +0200 Subject: persist cache more aggressively --- internal/p10k.zsh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 60f06673..9427de14 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -260,6 +260,7 @@ _p9k_cache_set() { # echo "caching: ${(@0q)_p9k_cache_key} => (${(q)@})" >&2 _p9k_cache[$_p9k_cache_key]="${(pj:\0:)*}0" _p9k_cache_val=("$@") + _p9k_dump_scheduled=1 } _p9k_cache_get() { @@ -3399,7 +3400,7 @@ function _p9k_dump_state() { sysopen -a -m 600 -o creat,trunc -u fd $tmp || return { local include='_POWERLEVEL9K_*|_p9k_*|icons|OS|DEFAULT_COLOR|DEFAULT_COLOR_INVERTED' - local exclude='_p9k_gitstatus_*|_p9k_param_sig|_p9k_public_ip|_p9k_prompt|_p9k_prompt_idx|_p9k_async_pump_*' + local exclude='_p9k_gitstatus_*|_p9k_param_sig|_p9k_public_ip|_p9k_prompt|_p9k_prompt_idx|_p9k_dump_pid|_p9k_dump_scheduled|_p9k_async_pump_*' typeset -g __p9k_cached_param_sig=$_p9k_param_sig typeset -p __p9k_cached_param_sig >&$fd || return unset __p9k_cached_param_sig @@ -3498,8 +3499,16 @@ _p9k_precmd_impl() { _p9k_set_prompt _p9k_refresh_reason='' - if ! zle && (( _p9k_prompt_idx == 1 && !_p9k_state_restored || _p9k_prompt_idx == 2 )); then - _p9k_dump_state + if ! zle && { (( ! _p9k_dump_pid )) || ! kill -0 $_p9k_dump_pid 2>/dev/null }; then + _p9k_dump_pid=0 + if (( _p9k_prompt_idx == 1 && !_p9k_state_restored )); then + _p9k_dump_state + _p9k_dump_scheduled=0 + elif (( _p9k_dump_scheduled )); then + _p9k_dump_state &! + _p9k_dump_pid=$! + _p9k_dump_scheduled=0 + fi fi } @@ -3710,6 +3719,8 @@ function _p9k_prompt_overflow_bug() { } _p9k_init_vars() { + typeset -gi _p9k_dump_scheduled + typeset -gi _p9k_dump_pid typeset -gi _p9k_prompt_idx typeset -gi _p9k_state_restored typeset -gi _p9k_reset_on_line_finish @@ -4687,6 +4698,7 @@ _p9k_init() { _p9k_deinit() { (( $+functions[gitstatus_stop] )) && gitstatus_stop POWERLEVEL9K _p9k_deinit_async_pump + (( _p9k_dump_pid )) && wait $_p9k_dump_pid 2>/dev/null unset -m '(_POWERLEVEL9K_|P9K_|_p9k_)*~P9K_SSH' } -- cgit v1.2.3 From ab160b49f54cec5faf91934c3e5b09b37f2f2425 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 9 Oct 2019 19:57:18 +0200 Subject: add two-level fs cache and use it everywhere instead of the one-level cache --- internal/p10k.zsh | 122 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 80 insertions(+), 42 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 9427de14..c3b0a322 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -269,6 +269,63 @@ _p9k_cache_get() { [[ -n $v ]] && _p9k_cache_val=("${(@0)${v[1,-2]}}") } +_p9k_cache_stat_get() { + local -H stat + local label=$1 f + shift + + _p9k_cache_stat_meta= + _p9k_cache_stat_fprint= + + for f; do + if zstat -H stat -- $f 2>/dev/null; then + _p9k_cache_stat_meta+="${(q)f} $stat[inode] $stat[mtime] $stat[size] $stat[mode]; " + fi + done + + if _p9k_cache_get $0 $label meta "$@" && [[ $_p9k_cache_val[1] == $_p9k_cache_stat_meta ]]; then + _p9k_cache_stat_fprint=$_p9k_cache_val[2] + local -a key=($0 $label fprint "$@" "$_p9k_cache_stat_fprint") + _p9k_cache_fprint_key="${(pj:\0:)key}" + shift 2 _p9k_cache_val + return + fi + + if (( $+commands[md5] )); then + local -a md5=(md5 -q) + elif (( $+commands[md5sum] )); then + local -a md5=(md5sum -b) + else + return 1 + fi + + local fprint + for f; do + if fprint="$($md5 $f 2>/dev/null)"; then + _p9k_cache_stat_fprint+="${(q)fprint} " + fi + done + + local meta_key=$_p9k_cache_key + if _p9k_cache_get $0 $label fprint "$@" "$_p9k_cache_stat_fprint"; then + _p9k_cache_fprint_key=$_p9k_cache_key + _p9k_cache_key=$meta_key + _p9k_cache_set "$_p9k_cache_stat_meta" "$_p9k_cache_stat_fprint" "$_p9k_cache_val[@]" + shift 2 _p9k_cache_val + return + fi + + _p9k_cache_fprint_key=$_p9k_cache_key + _p9k_cache_key=$meta_key + return 1 +} + +_p9k_cache_stat_set() { + _p9k_cache_set "$_p9k_cache_stat_meta" "$_p9k_cache_stat_fprint" "$@" + _p9k_cache_key=$_p9k_cache_fprint_key + _p9k_cache_set "$@" +} + # _p9k_param prompt_foo_BAR BACKGROUND red _p9k_param() { local key="_p9k_param ${(pj:\0:)*}" @@ -895,17 +952,14 @@ prompt_aws_eb_env() { dir=${dir:h} done - local -H stat - zstat -H stat -- $dir/.elasticbeanstalk/config.yml 2>/dev/null || return - local sig="$stat[inode].$stat[mtime].$stat[size].$stat[mode]" - if ! _p9k_cache_get $0 $dir || [[ $_p9k_cache_val[1] != $sig ]]; then + if ! _p9k_cache_stat_get $0 $dir/.elasticbeanstalk/config.yml; then local env env="$(command eb list 2>/dev/null)" || env= env="${${(@M)${(@f)env}:#\* *}#\* }" - _p9k_cache_set "$sig" "$env" + _p9k_cache_stat_set "$env" fi - [[ -n $_p9k_cache_val[2] ]] || return - _p9k_prompt_segment "$0" black green 'AWS_EB_ICON' 0 '' "${_p9k_cache_val[2]//\%/%%}" + [[ -n $_p9k_cache_val[1] ]] || return + _p9k_prompt_segment "$0" black green 'AWS_EB_ICON' 0 '' "${_p9k_cache_val[1]//\%/%%}" } ################################################################ @@ -1294,12 +1348,10 @@ prompt_dir() { for pat in $_POWERLEVEL9K_DIR_PACKAGE_FILES; do for pkg_file in $markers; do [[ $pkg_file == $dir/${~pat} ]] || continue - local -H stat=() - zstat -H stat -- $pkg_file 2>/dev/null || continue - if ! _p9k_cache_get $0_pkg $stat[inode] $stat[mtime] $stat[size]; then + if ! _p9k_cache_stat_get $0_pkg $pkg_file; then local pkg_name='' pkg_name="$(jq -j '.name | select(. != null)' <$pkg_file 2>/dev/null)" || pkg_name='' - _p9k_cache_set "$pkg_name" + _p9k_cache_stat_set "$pkg_name" fi [[ -n $_p9k_cache_val[1] ]] || continue parts[1,i]=($_p9k_cache_val[1]) @@ -1667,12 +1719,10 @@ function _p9k_cached_cmd_stdout() { local cmd=${commands[$1]:A} [[ -n $cmd ]] || return shift - local -H stat - zstat -H stat -- $cmd 2>/dev/null || return - if ! _p9k_cache_get $0 $stat[inode] $stat[mtime] $stat[size] $stat[mode] $cmd "$@"; then + if ! _p9k_cache_stat_get $0" ${(q)*}" $cmd; then local out out="$($cmd "$@" 2>/dev/null)" - _p9k_cache_set $(( ! $? )) "$out" + _p9k_cache_stat_set $(( ! $? )) "$out" fi (( $_p9k_cache_val[1] )) || return _p9k_ret=$_p9k_cache_val[2] @@ -1682,12 +1732,10 @@ function _p9k_cached_cmd_stdout_stderr() { local cmd=${commands[$1]:A} [[ -n $cmd ]] || return shift - local -H stat - zstat -H stat -- $cmd 2>/dev/null || return - if ! _p9k_cache_get $0 $stat[inode] $stat[mtime] $stat[size] $stat[mode] $cmd "$@"; then + if ! _p9k_cache_stat_get $0" ${(q)*}" $cmd; then local out out="$($cmd "$@" 2>&1)" # this line is the only diff with _p9k_cached_cmd_stdout - _p9k_cache_set $(( ! $? )) "$out" + _p9k_cache_stat_set $(( ! $? )) "$out" fi (( $_p9k_cache_val[1] )) || return _p9k_ret=$_p9k_cache_val[2] @@ -2232,14 +2280,12 @@ prompt_date() { prompt_todo() { local todo=$commands[todo.sh] [[ -n $todo && -r $_p9k_todo_file ]] || return - local -H stat - zstat -H stat -- $_p9k_todo_file 2>/dev/null || return - if ! _p9k_cache_get $0 $stat[inode] $stat[mtime] $stat[size]; then + if ! _p9k_cache_stat_get $0 $_p9k_todo_file; then local count="$($todo -p ls | tail -1)" if [[ $count == (#b)'TODO: '[[:digit:]]##' of '([[:digit:]]##)' '* ]]; then - _p9k_cache_set 1 $match[1] + _p9k_cache_stat_set 1 $match[1] else - _p9k_cache_set 0 0 + _p9k_cache_stat_set 0 0 fi fi (( $_p9k_cache_val[1] )) || return @@ -2944,15 +2990,7 @@ prompt_dir_writable() { prompt_kubecontext() { (( $+commands[kubectl] )) || return - local cfg - local -a key - for cfg in ${(s.:.)${KUBECONFIG:-$HOME/.kube/config}}; do - local -H stat - zstat -H stat -- $cfg 2>/dev/null || continue - key+=($cfg $stat[inode] $stat[mtime] $stat[size] $stat[mode]) - done - - if ! _p9k_cache_get $0 "${key[@]}"; then + if ! _p9k_cache_stat_get $0 ${(s.:.)${KUBECONFIG:-$HOME/.kube/config}}; then local name namespace cluster cloud_name cloud_account cloud_zone cloud_cluster text state () { local cfg && cfg=(${(f)"$(kubectl config view -o=yaml 2>/dev/null)"}) || return @@ -3012,7 +3050,7 @@ prompt_kubecontext() { fi done fi - _p9k_cache_set "$name" "$namespace" "$cluster" "$cloud_name" "$cloud_account" "$cloud_zone" "$cloud_cluster" "$text" "$state" + _p9k_cache_stat_set "$name" "$namespace" "$cluster" "$cloud_name" "$cloud_account" "$cloud_zone" "$cloud_cluster" "$text" "$state" fi typeset -g P9K_KUBECONTEXT_NAME=$_p9k_cache_val[1] @@ -3056,16 +3094,13 @@ prompt_java_version() { prompt_azure() { (( $+commands[az] )) || return - local -H stat - zstat -H stat -- ${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json 2>/dev/null || return - local sig="$stat[inode].$stat[mtime].$stat[size].$stat[mode]" - if ! _p9k_cache_get $0 || [[ $_p9k_cache_val[1] != $sig ]]; then + if ! _p9k_cache_stat_get $0 ${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json; then local name name="$(az account show --query name --output tsv 2>/dev/null)" || name= - _p9k_cache_set "$sig" "$name" + _p9k_cache_stat_set "$name" fi - [[ -n $_p9k_cache_val[2] ]] || return - _p9k_prompt_segment "$0" "blue" "white" "AZURE_ICON" 0 '' "${_p9k_cache_val[2]//\%/%%}" + [[ -n $_p9k_cache_val[1] ]] || return + _p9k_prompt_segment "$0" "blue" "white" "AZURE_ICON" 0 '' "${_p9k_cache_val[1]//\%/%%}" } typeset -gra __p9k_nordvpn_tag=( @@ -3400,7 +3435,7 @@ function _p9k_dump_state() { sysopen -a -m 600 -o creat,trunc -u fd $tmp || return { local include='_POWERLEVEL9K_*|_p9k_*|icons|OS|DEFAULT_COLOR|DEFAULT_COLOR_INVERTED' - local exclude='_p9k_gitstatus_*|_p9k_param_sig|_p9k_public_ip|_p9k_prompt|_p9k_prompt_idx|_p9k_dump_pid|_p9k_dump_scheduled|_p9k_async_pump_*' + local exclude='_p9k_gitstatus_*|_p9k_cache_stat_meta|_p9k_cache_stat_fprint|_p9k_cache_fprint_key|_p9k_param_sig|_p9k_public_ip|_p9k_prompt|_p9k_prompt_idx|_p9k_dump_pid|_p9k_dump_scheduled|_p9k_async_pump_*' typeset -g __p9k_cached_param_sig=$_p9k_param_sig typeset -p __p9k_cached_param_sig >&$fd || return unset __p9k_cached_param_sig @@ -3731,6 +3766,9 @@ _p9k_init_vars() { typeset -g _p9k_ret typeset -g _p9k_cache_key typeset -ga _p9k_cache_val + typeset -g _p9k_cache_stat_meta + typeset -g _p9k_cache_stat_fprint + typeset -g _p9k_cache_fprint_key typeset -gA _p9k_cache typeset -ga _p9k_t typeset -g _p9k_n -- cgit v1.2.3 From 6724f3ae5d6138f007942c69faf45042d33ea7fe Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 9 Oct 2019 20:04:09 +0200 Subject: md5 -q => md5 --- internal/p10k.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index c3b0a322..3c08ab87 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -292,7 +292,7 @@ _p9k_cache_stat_get() { fi if (( $+commands[md5] )); then - local -a md5=(md5 -q) + local -a md5=(md5) elif (( $+commands[md5sum] )); then local -a md5=(md5sum -b) else -- cgit v1.2.3 From 9a01aeb673f69dc64cdfdaf3b7fe39971a07831b Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 9 Oct 2019 23:31:33 +0200 Subject: use jq in azure if available --- internal/p10k.zsh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 3c08ab87..64919f64 100755 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3094,9 +3094,14 @@ prompt_java_version() { prompt_azure() { (( $+commands[az] )) || return - if ! _p9k_cache_stat_get $0 ${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json; then + local cfg=${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json + if ! _p9k_cache_stat_get $0 $cfg; then local name - name="$(az account show --query name --output tsv 2>/dev/null)" || name= + if (( $+commands[jq] )) && name="$(jq -r '[.subscriptions[]|select(.isDefault==true)|.name][]|strings' $cfg 2>/dev/null)"; then + name=${name%%$'\n'*} + elif ! name="$(az account show --query name --output tsv 2>/dev/null)"; then + name= + fi _p9k_cache_stat_set "$name" fi [[ -n $_p9k_cache_val[1] ]] || return @@ -4449,7 +4454,7 @@ _p9k_must_init() { '${ZSH_VERSION}' '${ZSH_PATCHLEVEL}' '${(%):-%n}' '${GITSTATUS_LOG_LEVEL}' '${GITSTATUS_ENABLE_LOGGING}' '${GITSTATUS_DAEMON}' '${GITSTATUS_NUM_THREADS}' '${DEFAULT_USER}' '${ZLE_RPROMPT_INDENT}' '${P9K_SSH}' '${__p9k_ksh_arrays}' - '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v5') + '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v6') IFS=$'\2' param_sig="${(e)param_sig}" [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit -- cgit v1.2.3 From bb6540ae6ec8617a67167b505db5718436d3f6b8 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 9 Oct 2019 23:32:41 +0200 Subject: remove spurious execute permissions --- internal/icons.zsh | 0 internal/p10k.zsh | 0 powerlevel9k.zsh-theme | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 internal/icons.zsh mode change 100755 => 100644 internal/p10k.zsh mode change 100755 => 100644 powerlevel9k.zsh-theme diff --git a/internal/icons.zsh b/internal/icons.zsh old mode 100755 new mode 100644 diff --git a/internal/p10k.zsh b/internal/p10k.zsh old mode 100755 new mode 100644 diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme old mode 100755 new mode 100644 -- cgit v1.2.3 From e31abb850bb04284a044709f9b4abd40c1787cb7 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 9 Oct 2019 23:54:47 +0200 Subject: bug fix: wrap zle-line-finish even on hot start --- internal/p10k.zsh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 64919f64..f1aaa2b4 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3440,7 +3440,7 @@ function _p9k_dump_state() { sysopen -a -m 600 -o creat,trunc -u fd $tmp || return { local include='_POWERLEVEL9K_*|_p9k_*|icons|OS|DEFAULT_COLOR|DEFAULT_COLOR_INVERTED' - local exclude='_p9k_gitstatus_*|_p9k_cache_stat_meta|_p9k_cache_stat_fprint|_p9k_cache_fprint_key|_p9k_param_sig|_p9k_public_ip|_p9k_prompt|_p9k_prompt_idx|_p9k_dump_pid|_p9k_dump_scheduled|_p9k_async_pump_*' + local exclude='_p9k_gitstatus_*|_p9k_cache_stat_meta|_p9k_cache_stat_fprint|_p9k_cache_fprint_key|_p9k_param_sig|_p9k_public_ip|_p9k_prompt|_p9k_prompt_idx|_p9k_dump_pid|_p9k_dump_scheduled|_p9k_line_finished|_p9k_preexec_cmd|_p9k_status|_p9k_pipestatus|_p9k_timer_start|_p9k_region_active|_p9k_keymap|_p9k_zle_state|_p9k_async_pump_*' typeset -g __p9k_cached_param_sig=$_p9k_param_sig typeset -p __p9k_cached_param_sig >&$fd || return unset __p9k_cached_param_sig @@ -4411,10 +4411,6 @@ _p9k_init_prompt() { [[ -o transient_rprompt && -n "$_p9k_line_segments_right[1,-2]" ]] || ( _p9k_segment_in_use time && (( _POWERLEVEL9K_TIME_UPDATE_ON_COMMAND )) ) _p9k_reset_on_line_finish=$((!$?)) - - if (( _p9k_reset_on_line_finish )) || _p9k_segment_in_use status; then - _p9k_wrap_zle_widget zle-line-finish _p9k_zle_line_finish - fi } _p9k_init_ssh() { @@ -4454,7 +4450,7 @@ _p9k_must_init() { '${ZSH_VERSION}' '${ZSH_PATCHLEVEL}' '${(%):-%n}' '${GITSTATUS_LOG_LEVEL}' '${GITSTATUS_ENABLE_LOGGING}' '${GITSTATUS_DAEMON}' '${GITSTATUS_NUM_THREADS}' '${DEFAULT_USER}' '${ZLE_RPROMPT_INDENT}' '${P9K_SSH}' '${__p9k_ksh_arrays}' - '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v6') + '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v7') IFS=$'\2' param_sig="${(e)param_sig}" [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit @@ -4714,6 +4710,10 @@ _p9k_init() { fi fi + if (( _p9k_reset_on_line_finish )) || _p9k_segment_in_use status; then + _p9k_wrap_zle_widget zle-line-finish _p9k_zle_line_finish + fi + if _p9k_segment_in_use vi_mode || _p9k_segment_in_use prompt_char; then _p9k_wrap_zle_widget zle-keymap-select _p9k_zle_keymap_select fi -- cgit v1.2.3 From 6b8009103905240e6ea30c789b4e86b9cb1fc88e Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 10 Oct 2019 09:58:14 +0200 Subject: make p10k-pure work without gitstatus --- config/p10k-pure.zsh | 78 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 29 deletions(-) diff --git a/config/p10k-pure.zsh b/config/p10k-pure.zsh index a7ce1f5b..c5031b4d 100644 --- a/config/p10k-pure.zsh +++ b/config/p10k-pure.zsh @@ -6,13 +6,13 @@ # - `@c4d3ec2c` instead of something like `v1.4.0~11` when in detached HEAD state. # - No automatic `git fetch` (the same as in Pure with `PURE_GIT_PULL=0`). # -# The replication of Pure prompt achieved with this config is almost exact. Apart from the -# differences listed above, prompt is identical to Pure. This includes even the bad parts. -# For example, just like in Pure, prompt will provide no indication of Git status being stale. -# When prompt doesn't fit on one line, it'll wrap around with no attempt to shorten anything. -# This is likely to make user experience worse than with any other Powerlevel10k config. If -# you like the general style of Pure but not particularly attached to all its quirks, type -# `p10k configure` while having Powerlevel10k theme active and pick lean style. +# Apart from the differences listed above, the replication of Pure prompt is exact. This includes +# even the bad parts. For example, just like in Pure, prompt provides no indication of Git status +# being stale; prompt symbol is the same in command, visual and overwrite vi modes; when prompt +# doesn't fit on one line, it wraps around with no attempt to shorten anything. This behavior is +# likely to make user experience worse than with any other Powerlevel10k config. If you like the +# general style of Pure but not particularly attached to all its quirks, type `p10k configure` +# while having Powerlevel10k theme active and pick lean style. # Temporarily change options. 'builtin' 'local' '-a' 'p10k_config_opts' @@ -25,6 +25,9 @@ emulate -L zsh setopt no_unset + # Unset all configuration options. + unset -m 'POWERLEVEL9K_*' + typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( dir # current directory vcs # git status @@ -36,14 +39,15 @@ ) typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=() - # Basic style options that define the overall look of your prompt. + # Basic style options that define the overall prompt look. typeset -g POWERLEVEL9K_BACKGROUND= # transparent background typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR= # no end-of-line symbol typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION= # disable segment icons - # Add an empty line before each prompt. + # Add an empty line before each prompt except the first. This doesn't emulate the bug + # in Pure that makes prompt drift down whenever you use the ALT-C binding from fzf or similar. typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true # Magenta prompt symbol if the last command succeeded. @@ -57,38 +61,54 @@ # Prompt symbol in visual vi mode is the same as in command mode. This is unlikely # to be desired by anyone but that's how Pure does it. typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='❮' + # Prompt symbol in overwrite vi mode is the same as in command mode. This is unlikely + # to be desired by anyone but that's how Pure does it. + typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=false # Grey Python Virtual Environment. typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=242 + # Don't show Python version. + typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false + typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER= # Blue current directory. typeset -g POWERLEVEL9K_DIR_FOREGROUND=blue - # Make Git prompt grey in all states. Also make stale prompts appear indistinguishable from - # fresh ones. This is unlikely to be desired by anyone but that's how Pure does it. + # Grey Git prompt. This makes stale prompts indistinguishable from up-to-date ones. This is + # unlikely to be desired by anyone but that's how Pure does it. typeset -g POWERLEVEL9K_VCS_FOREGROUND=242 - # Disable async loading indicator to make directories that aren't Git repositories - # indistinguishable from large Git repositories without known state. This is unlikely + # Disable async loading indicator to make directories that aren't git repositories + # indistinguishable from large git repositories without known state. This is unlikely # to be desired by anyone but that's how Pure does it. - local vcs='${${P9K_CONTENT:#loading}:+' - # 'feature' or '@72f5c8a' if not on a branch. - vcs+='${${VCS_STATUS_LOCAL_BRANCH//\%/%%}:-%f@${VCS_STATUS_COMMIT[1,8]}}' - # '*' if dirty. - vcs+='${${${:-$VCS_STATUS_HAS_STAGED$VCS_STATUS_HAS_UNSTAGED$VCS_STATUS_HAS_UNTRACKED}:#000}:+*}' - # ⇣ if behind the remote. - vcs+='${${VCS_STATUS_COMMITS_BEHIND:#0}:+ %6F⇣}' - # ⇡ if ahead of the remote; no leading space if also behind the remote: ⇣⇡. - vcs+='${${VCS_STATUS_COMMITS_AHEAD:#0}:+${${(M)VCS_STATUS_COMMITS_BEHIND:#0}:+ }%6F⇡}}' - typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION=$vcs + typeset -g POWERLEVEL9K_VCS_LOADING_TEXT= + # Cyan ahead/behind arrows. + typeset -g POWERLEVEL9K_VCS_{INCOMING,OUTGOING}_CHANGESFORMAT_FOREGROUND=cyan + # Don't show remote branch, current tag or stashes. + typeset -g POWERLEVEL9K_VCS_GIT_HOOKS=(vcs-detect-changes git-untracked git-aheadbehind) + # Don't show the branh icon. + typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= + # When in detached HEAD state, show @commit where branch normally goes. + typeset -g POWERLEVEL9K_VCS_COMMIT_ICON='@' + # Don't show staged, unstaged, untracked indicators. + typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED}_ICON=$'\b' + # Show '*' when there are staged, unstaged or untracked files. + typeset -g POWERLEVEL9K_VCS_DIRTY_ICON='*' + # Show '⇣' if local branch is behind remote. + typeset -g POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON='⇣' + # Show '⇡' if local branch is ahead of remote. + typeset -g POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON='⇡' + # Don't show the number of commits next to the ahead/behind arrows. + typeset -g POWERLEVEL9K_VCS_{COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=1 + # Remove space between '⇣' and '⇡', and get rid of $' \b'. + typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION=$'${${P9K_CONTENT/⇣* ⇡/⇣⇡}// \b}' # Context format when root: user@host. The first part white, the rest grey. - typeset -g POWERLEVEL9K_CONTEXT_ROOT_CONTENT_EXPANSION='%7F%n%f%242F@%m%f' - # Context format when connected over SSH: user@host. The whole thing grey. - typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_CONTENT_EXPANSION='%242F%n@%m%f' - # Don't show context when not rood and not connected over SSH. - typeset -g POWERLEVEL9K_CONTEXT_CONTENT_EXPANSION= - typeset -g POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true + typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%7F%n%f%242F@%m%f' + # Context format when not root: user@host. The whole thing grey. + typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%242F%n@%m%f' + # Don't show context unless root or in SSH. + typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_CONTENT_EXPANSION= # Show previous command duration only if it's >= 5s. typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=5 -- cgit v1.2.3 From d827b5f0a358e0efddf0b248b1dd679bb35858d8 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 10 Oct 2019 10:11:03 +0200 Subject: define POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS=0 in p10k-pure --- config/p10k-pure.zsh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/config/p10k-pure.zsh b/config/p10k-pure.zsh index c5031b4d..50f5f3fc 100644 --- a/config/p10k-pure.zsh +++ b/config/p10k-pure.zsh @@ -78,10 +78,15 @@ # unlikely to be desired by anyone but that's how Pure does it. typeset -g POWERLEVEL9K_VCS_FOREGROUND=242 - # Disable async loading indicator to make directories that aren't git repositories - # indistinguishable from large git repositories without known state. This is unlikely + # Disable async loading indicator to make directories that aren't Git repositories + # indistinguishable from large Git repositories without known state. This is unlikely # to be desired by anyone but that's how Pure does it. typeset -g POWERLEVEL9K_VCS_LOADING_TEXT= + + # Don't wait for Git status even for a millisecond, so that prompt always updates asynchronously + # when Git state changes. This is unlikely to be desired by anyone but that's how Pure does it. + typeset -g POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS=0 + # Cyan ahead/behind arrows. typeset -g POWERLEVEL9K_VCS_{INCOMING,OUTGOING}_CHANGESFORMAT_FOREGROUND=cyan # Don't show remote branch, current tag or stashes. -- cgit v1.2.3 From f1d295ca65e3df07a0368f7e21536d1d40c0b72c Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 10 Oct 2019 10:23:10 +0200 Subject: docs --- config/p10k-pure.zsh | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/config/p10k-pure.zsh b/config/p10k-pure.zsh index 50f5f3fc..a98b3fd8 100644 --- a/config/p10k-pure.zsh +++ b/config/p10k-pure.zsh @@ -1,5 +1,7 @@ # Config file for Powerlevel10k with the style of Pure (https://github.com/sindresorhus/pure). # +# Installation: simply source this file from ~/.zshrc. +# # Differences from Pure: # # - Git: @@ -10,9 +12,10 @@ # even the bad parts. For example, just like in Pure, prompt provides no indication of Git status # being stale; prompt symbol is the same in command, visual and overwrite vi modes; when prompt # doesn't fit on one line, it wraps around with no attempt to shorten anything. This behavior is -# likely to make user experience worse than with any other Powerlevel10k config. If you like the -# general style of Pure but not particularly attached to all its quirks, type `p10k configure` -# while having Powerlevel10k theme active and pick lean style. +# likely to make user experience worse than with any other Powerlevel10k config. +# +# If you like the general style of Pure but not particularly attached to all its quirks, +# type `p10k configure` while having Powerlevel10k theme active and pick lean style. # Temporarily change options. 'builtin' 'local' '-a' 'p10k_config_opts' @@ -28,6 +31,7 @@ # Unset all configuration options. unset -m 'POWERLEVEL9K_*' + # Left prompt segments. typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( dir # current directory vcs # git status @@ -37,6 +41,8 @@ virtualenv # python virtual environment prompt_char # prompt symbol ) + + # Right prompt segments. typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=() # Basic style options that define the overall prompt look. @@ -44,7 +50,7 @@ typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR= # no end-of-line symbol - typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION= # disable segment icons + typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION= # no segment icons # Add an empty line before each prompt except the first. This doesn't emulate the bug # in Pure that makes prompt drift down whenever you use the ALT-C binding from fzf or similar. @@ -74,6 +80,22 @@ # Blue current directory. typeset -g POWERLEVEL9K_DIR_FOREGROUND=blue + # Context format when root: user@host. The first part white, the rest grey. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%7F%n%f%242F@%m%f' + # Context format when not root: user@host. The whole thing grey. + typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%242F%n@%m%f' + # Don't show context unless root or in SSH. + typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_CONTENT_EXPANSION= + + # Show previous command duration only if it's >= 5s. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=5 + # Don't show fractional seconds. Thus, 7s rather than 7.3s. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 + # Duration format: 1d 2h 3m 4s. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s' + # Yellow previous command duration. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=yellow + # Grey Git prompt. This makes stale prompts indistinguishable from up-to-date ones. This is # unlikely to be desired by anyone but that's how Pure does it. typeset -g POWERLEVEL9K_VCS_FOREGROUND=242 @@ -107,22 +129,6 @@ typeset -g POWERLEVEL9K_VCS_{COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=1 # Remove space between '⇣' and '⇡', and get rid of $' \b'. typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION=$'${${P9K_CONTENT/⇣* ⇡/⇣⇡}// \b}' - - # Context format when root: user@host. The first part white, the rest grey. - typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%7F%n%f%242F@%m%f' - # Context format when not root: user@host. The whole thing grey. - typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%242F%n@%m%f' - # Don't show context unless root or in SSH. - typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_CONTENT_EXPANSION= - - # Show previous command duration only if it's >= 5s. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=5 - # Don't show fractional seconds. Thus, 7s rather than 7.3s. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 - # Duration format: 1d 2h 3m 4s. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s' - # Yellow previous command duration. - typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=yellow } (( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} -- cgit v1.2.3 From 40c062c3b95a7bd08e6cb89a38d902e4758dd1e1 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 10 Oct 2019 14:13:47 +0200 Subject: tone down the downsides of pure --- config/p10k-pure.zsh | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/config/p10k-pure.zsh b/config/p10k-pure.zsh index a98b3fd8..20f5b3f2 100644 --- a/config/p10k-pure.zsh +++ b/config/p10k-pure.zsh @@ -1,7 +1,5 @@ # Config file for Powerlevel10k with the style of Pure (https://github.com/sindresorhus/pure). # -# Installation: simply source this file from ~/.zshrc. -# # Differences from Pure: # # - Git: @@ -9,13 +7,12 @@ # - No automatic `git fetch` (the same as in Pure with `PURE_GIT_PULL=0`). # # Apart from the differences listed above, the replication of Pure prompt is exact. This includes -# even the bad parts. For example, just like in Pure, prompt provides no indication of Git status +# even the questionable parts. For example, just like in Pure, there is no indication of Git status # being stale; prompt symbol is the same in command, visual and overwrite vi modes; when prompt -# doesn't fit on one line, it wraps around with no attempt to shorten anything. This behavior is -# likely to make user experience worse than with any other Powerlevel10k config. +# doesn't fit on one line, it wraps around with no attempt to shorten it. # -# If you like the general style of Pure but not particularly attached to all its quirks, -# type `p10k configure` while having Powerlevel10k theme active and pick lean style. +# If you like the general style of Pure but not particularly attached to all its quirks, type +# `p10k configure` while having Powerlevel10k theme active and pick "Lean" style. # Temporarily change options. 'builtin' 'local' '-a' 'p10k_config_opts' @@ -96,17 +93,15 @@ # Yellow previous command duration. typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=yellow - # Grey Git prompt. This makes stale prompts indistinguishable from up-to-date ones. This is - # unlikely to be desired by anyone but that's how Pure does it. + # Grey Git prompt. This makes stale prompts indistinguishable from up-to-date ones. typeset -g POWERLEVEL9K_VCS_FOREGROUND=242 # Disable async loading indicator to make directories that aren't Git repositories - # indistinguishable from large Git repositories without known state. This is unlikely - # to be desired by anyone but that's how Pure does it. + # indistinguishable from large Git repositories without known state. typeset -g POWERLEVEL9K_VCS_LOADING_TEXT= - # Don't wait for Git status even for a millisecond, so that prompt always updates asynchronously - # when Git state changes. This is unlikely to be desired by anyone but that's how Pure does it. + # Don't wait for Git status even for a millisecond, so that prompt always updates + # asynchronously when Git state changes. typeset -g POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS=0 # Cyan ahead/behind arrows. -- cgit v1.2.3 From 640d513554c5534009408326066dd0e8eebc586c Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 10 Oct 2019 14:14:08 +0200 Subject: add pure style to the configuration wizard --- internal/wizard.zsh | 52 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index a2e078eb..5c25f6a5 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -80,6 +80,16 @@ typeset -ra classic_right=( '' '%$frame_color[$color]F─╯%f' ) +typeset -ra pure_left=( + '' '%4F~/src%f %242Fmaster%f' + '' '%5F❯%f █' +) + +typeset -ra pure_right=( + '' '' + '' '' +) + function prompt_length() { local COLUMNS=1024 local -i x y=$#1 m @@ -531,17 +541,22 @@ function ask_style() { print -P "" style=classic print_prompt print -P "" + print -P "%B(3) Pure.%b" + print -P "" + style=pure print_prompt + print -P "" print -P "(r) Restart from the beginning." print -P "(q) Quit and do nothing." print -P "" local key= - read -k key${(%):-"?%BChoice [12rq]: %b"} || quit -c + read -k key${(%):-"?%BChoice [123rq]: %b"} || quit -c case $key in q) quit;; r) return 1;; 1) style=lean; options+=lean; break;; 2) style=classic; options+=classic; break;; + 3) style=pure; options+=pure; break;; esac done } @@ -1190,6 +1205,14 @@ function ask_config_overwrite() { } function generate_config() { + if [[ $style == pure ]]; then + if [[ -e $__p9k_cfg_path ]]; then + unlink $__p9k_cfg_path || return + fi + cp $__p9k_root_dir/config/p10k-$style.zsh $__p9k_cfg_path || return + return + fi + local base && base="$(<$__p9k_root_dir/config/p10k-$style.zsh)" || return local lines=("${(@f)base}") @@ -1444,17 +1467,22 @@ while true; do _p9k_init_icons ask_narrow_icons || continue ask_style || continue - ask_color || continue - ask_time || continue - ask_separators || continue - ask_heads || continue - ask_tails || continue - ask_num_lines || continue - ask_gap_char || continue - ask_frame || continue - ask_empty_line || continue - ask_extra_icons || continue - ask_prefixes || continue + if [[ $style == pure ]]; then + empty_line=1 + options+='sparse' + else + ask_color || continue + ask_time || continue + ask_separators || continue + ask_heads || continue + ask_tails || continue + ask_num_lines || continue + ask_gap_char || continue + ask_frame || continue + ask_empty_line || continue + ask_extra_icons || continue + ask_prefixes || continue + fi ask_confirm || continue ask_config_overwrite || continue break -- cgit v1.2.3 From 0c59d87f0853b42cf075e4dc7b176ad3c49fe1c0 Mon Sep 17 00:00:00 2001 From: romkatv Date: Thu, 10 Oct 2019 17:36:40 +0200 Subject: add the default powerlevel9k style to the wizard --- config/p10k-p9k.zsh | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ internal/wizard.zsh | 79 +++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 141 insertions(+), 12 deletions(-) create mode 100644 config/p10k-p9k.zsh diff --git a/config/p10k-p9k.zsh b/config/p10k-p9k.zsh new file mode 100644 index 00000000..c14be784 --- /dev/null +++ b/config/p10k-p9k.zsh @@ -0,0 +1,74 @@ +# Config for Powerlevel10k with the default style of Powerlevel9k. + +# Temporarily change options. +'builtin' 'local' '-a' 'p10k_config_opts' +[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') +'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' + +() { + emulate -L zsh + + # Unset all configuration options. This allows you to apply configiguration changes without + # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. + unset -m 'POWERLEVEL9K_*' + + # To disable default icons for all segments, set POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION=''. + # + # To enable default icons for all segments, don't define POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION + # or set it to '${P9K_VISUAL_IDENTIFIER}'. + # + # To remove trailing space from all default icons, set POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION + # to '${P9K_VISUAL_IDENTIFIER% }'. + # + # To enable default icons for one segment (e.g., dir), set + # POWERLEVEL9K_DIR_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}'. + # + # To assign a specific icon to one segment (e.g., dir), set + # POWERLEVEL9K_DIR_VISUAL_IDENTIFIER_EXPANSION='⭐'. + # + # To assign a specific icon to a segment in a given state (e.g., dir in state NOT_WRITABLE), + # set POWERLEVEL9K_DIR_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐'. + # + # Note: You can use $'\u2B50' instead of '⭐'. It's especially convenient when specifying + # icons that your text editor cannot render. Don't forget to put $ and use single quotes when + # defining icons via Unicode codepoints. + # + # Note: Many default icons cannot be displayed with system fonts. You'll need to install a + # capable font to use them. See POWERLEVEL9K_MODE below. + # typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' + + # This option makes a difference only when default icons are enabled for all or some prompt + # segments (see POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION above). LOCK_ICON can be printed as + # $'\uE0A2', $'\uE138' or $'\uF023' depending on POWERLEVEL9K_MODE. The correct value of this + # parameter depends on the provider of the font your terminal is using. + # + # Font Provider | POWERLEVEL9K_MODE + # ---------------------------------+------------------- + # Powerline | powerline + # Font Awesome | awesome-fontconfig + # Adobe Source Code Pro | awesome-fontconfig + # Source Code Pro | awesome-fontconfig + # Awesome-Terminal Fonts (regular) | awesome-fontconfig + # Awesome-Terminal Fonts (patched) | awesome-patched + # Nerd Fonts | nerdfont-complete + # Other | compatible + # + # If this looks overwhelming, either stick with a preinstalled system font and set + # POWERLEVEL9K_MODE=compatible, or install the recommended Powerlevel10k font from + # https://github.com/romkatv/powerlevel10k/#recommended-meslo-nerd-font-patched-for-powerlevel10k + # and set POWERLEVEL9K_MODE=nerdfont-complete. + typeset -g POWERLEVEL9K_MODE=nerdfont-complete + + # typeset -g POWERLEVEL9K_PYTHON_ICON= + # typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON= + # typeset -g POWERLEVEL9K_VCS_UNSTAGED_ICON= + # typeset -g POWERLEVEL9K_VCS_STAGED_ICON= + # typeset -g POWERLEVEL9K_VCS_STASH_ICON= + # typeset -g POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON= + # typeset -g POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON= +} + +(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} +'builtin' 'unset' 'p10k_config_opts' diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 5c25f6a5..22f0a4b6 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -90,6 +90,16 @@ typeset -ra pure_right=( '' '' ) +typeset -ra p9k_left=( + '' '%K{0}%F{3} user@host %K{4}%F{0}$right_triangle%F{0} $extra_icons[2]~/src %K{2}%F{4}$right_triangle%F{0} $extra_icons[3]master %k%F{2}$right_triangle%f' + '' ' █' +) + +typeset -ra p9k_right=( + '%F{0}$left_triangle%K{0}%F{2} ${(g::)icons[OK_ICON]} %F{8}$left_triangle%K{8}%F{0} 42 %F{7}$left_triangle%K{7}%F{0} 16:23:42 $extra_icons[5]%k%f' '' + '' '' +) + function prompt_length() { local COLUMNS=1024 local -i x y=$#1 m @@ -529,34 +539,67 @@ function ask_narrow_icons() { } function ask_style() { + if (( cap_diamond && LINES < 25 )); then + local nl='' + else + local nl=$'\n' + fi while true; do clear + local extra= flowing -c "%BPrompt Style%b" - print -P "" - print -P "%B(1) Lean.%b" - print -P "" + print -n $nl + print -P "%B(1) Lean (recommended).%b" + print -n $nl style=lean print_prompt print -P "" - print -P "%B(2) Classic.%b" - print -P "" + print -P "%B(2) Classic (recommended).%b" + print -n $nl style=classic print_prompt print -P "" print -P "%B(3) Pure.%b" - print -P "" + print -n $nl style=pure print_prompt print -P "" + if (( cap_diamond )); then + extra+=4 + print -P "%B(4) Powerlevel9k.%b" + print -P "" + local dir_icon=${(g::)icons[HOME_SUB_ICON]} + local vcs_icon=${(g::)icons[VCS_GIT_GITHUB_ICON]} + local branch_icon=${(g::)icons[VCS_BRANCH_ICON]} + local time_icon=${(g::)icons[TIME_ICON]} + if (( cap_narrow_icons )); then + dir_icon=${dir_icon// } + vcs_icon=${vcs_icon// } + duration_icon=${duration_icon// } + time_icon=${time_icon// } + fi + branch_icon=${branch_icon// } + local many_icons=("" "$dir_icon " "$vcs_icon $branch_icon " " " "$time_icon ") + extra_icons=("$many_icons[@]") style=p9k num_lines=1 print_prompt + print -P "" + fi print -P "(r) Restart from the beginning." print -P "(q) Quit and do nothing." print -P "" local key= - read -k key${(%):-"?%BChoice [123rq]: %b"} || quit -c + read -k key${(%):-"?%BChoice [123${extra}rq]: %b"} || quit -c case $key in q) quit;; r) return 1;; 1) style=lean; options+=lean; break;; 2) style=classic; options+=classic; break;; - 3) style=pure; options+=pure; break;; + 3) style=pure; empty_line=1; options+=pure; break;; + 4) if [[ $extra == *4* ]]; then + style=p9k + num_lines=1 + extra_icons=("$many_icons[@]") + options+=p9k + break + fi + ;; esac done } @@ -1231,9 +1274,22 @@ function generate_config() { sub MODE $POWERLEVEL9K_MODE if (( cap_narrow_icons )); then + uncomment 'typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION' sub VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER// }'" sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER// }'" sub OS_ICON_CONTENT_EXPANSION "'%B\${P9K_CONTENT// }'" + uncomment 'typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON' + uncomment 'typeset -g POWERLEVEL9K_VCS_UNSTAGED_ICON' + uncomment 'typeset -g POWERLEVEL9K_VCS_STAGED_ICON' + uncomment 'typeset -g POWERLEVEL9K_VCS_STASH_ICON' + uncomment 'typeset -g POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON' + uncomment 'typeset -g POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON' + sub VCS_UNTRACKED_ICON "'${icons[VCS_UNTRACKED_ICON]// }'" + sub VCS_UNSTAGED_ICON "'${icons[VCS_UNSTAGED_ICON]// }'" + sub VCS_STAGED_ICON "'${icons[VCS_STAGED_ICON]// }'" + sub VCS_STASH_ICON "'${icons[VCS_STASH_ICON]// }'" + sub VCS_INCOMING_CHANGES_ICON "'${icons[VCS_INCOMING_CHANGES_ICON]// }'" + sub VCS_OUTGOING_CHANGES_ICON "'${icons[VCS_OUTGOING_CHANGES_ICON]// }'" else sub VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER}'" sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER}'" @@ -1250,9 +1306,11 @@ function generate_config() { uncomment 'typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION' uncomment 'typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION' uncomment 'typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION' + uncomment 'typeset -g POWERLEVEL9K_PYTHON_ICON' sub VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION "'🐍'" sub ANACONDA_VISUAL_IDENTIFIER_EXPANSION "'🐍'" sub PYENV_VISUAL_IDENTIFIER_EXPANSION "'🐍'" + sub PYTHON_ICON "'🐍'" fi if [[ $POWERLEVEL9K_MODE == nerdfont-complete ]]; then @@ -1467,10 +1525,7 @@ while true; do _p9k_init_icons ask_narrow_icons || continue ask_style || continue - if [[ $style == pure ]]; then - empty_line=1 - options+='sparse' - else + if [[ $style == (lean|classic) ]]; then ask_color || continue ask_time || continue ask_separators || continue -- cgit v1.2.3 From 5b9e75be3a6fc4a866ca0289b8697c71259045f2 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 11 Oct 2019 10:33:49 +0200 Subject: add POWERLEVEL9K_BATTERY_LEVEL_FOREGROUND; fixes #256 --- internal/p10k.zsh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index f1aaa2b4..0f63b76c 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1115,7 +1115,14 @@ prompt_battery() { bg=$_POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND[idx] fi - _p9k_prompt_segment $0_$state "$bg" "$_p9k_battery_states[$state]" $icon 0 '' $msg + local fg=$_p9k_battery_states[$state] + if (( $#_POWERLEVEL9K_BATTERY_LEVEL_FOREGROUND )); then + local -i idx=$#_POWERLEVEL9K_BATTERY_LEVEL_FOREGROUND + (( bat_percent < 100 )) && idx=$((bat_percent * $#_POWERLEVEL9K_BATTERY_LEVEL_FOREGROUND / 100 + 1)) + fg=$_POWERLEVEL9K_BATTERY_LEVEL_FOREGROUND[idx] + fi + + _p9k_prompt_segment $0_$state "$bg" "$fg" $icon 0 '' $msg } ################################################################ @@ -3893,6 +3900,7 @@ _p9k_init_params() { _p9k_declare -i POWERLEVEL9K_BATTERY_LOW_THRESHOLD 10 _p9k_declare -i POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD 999 _p9k_declare -a POWERLEVEL9K_BATTERY_LEVEL_BACKGROUND -- + _p9k_declare -a POWERLEVEL9K_BATTERY_LEVEL_FOREGROUND -- _p9k_declare -b POWERLEVEL9K_BATTERY_VERBOSE 1 if [[ $parameters[POWERLEVEL9K_BATTERY_STAGES] == scalar ]]; then _p9k_declare -e POWERLEVEL9K_BATTERY_STAGES -- cgit v1.2.3 From 90bf4c3fef4c0c61d7b4f43bacc17886d30dbf83 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 11 Oct 2019 13:24:20 +0200 Subject: restore "?" as VCS_UNTRACKED_ICON in lean and classic styles --- internal/wizard.zsh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 22f0a4b6..5b396aa1 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -1278,18 +1278,20 @@ function generate_config() { sub VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER// }'" sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER// }'" sub OS_ICON_CONTENT_EXPANSION "'%B\${P9K_CONTENT// }'" - uncomment 'typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON' - uncomment 'typeset -g POWERLEVEL9K_VCS_UNSTAGED_ICON' - uncomment 'typeset -g POWERLEVEL9K_VCS_STAGED_ICON' - uncomment 'typeset -g POWERLEVEL9K_VCS_STASH_ICON' - uncomment 'typeset -g POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON' - uncomment 'typeset -g POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON' - sub VCS_UNTRACKED_ICON "'${icons[VCS_UNTRACKED_ICON]// }'" - sub VCS_UNSTAGED_ICON "'${icons[VCS_UNSTAGED_ICON]// }'" - sub VCS_STAGED_ICON "'${icons[VCS_STAGED_ICON]// }'" - sub VCS_STASH_ICON "'${icons[VCS_STASH_ICON]// }'" - sub VCS_INCOMING_CHANGES_ICON "'${icons[VCS_INCOMING_CHANGES_ICON]// }'" - sub VCS_OUTGOING_CHANGES_ICON "'${icons[VCS_OUTGOING_CHANGES_ICON]// }'" + if [[ $style == p9k ]]; then + uncomment 'typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON' + uncomment 'typeset -g POWERLEVEL9K_VCS_UNSTAGED_ICON' + uncomment 'typeset -g POWERLEVEL9K_VCS_STAGED_ICON' + uncomment 'typeset -g POWERLEVEL9K_VCS_STASH_ICON' + uncomment 'typeset -g POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON' + uncomment 'typeset -g POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON' + sub VCS_UNTRACKED_ICON "'${icons[VCS_UNTRACKED_ICON]// }'" + sub VCS_UNSTAGED_ICON "'${icons[VCS_UNSTAGED_ICON]// }'" + sub VCS_STAGED_ICON "'${icons[VCS_STAGED_ICON]// }'" + sub VCS_STASH_ICON "'${icons[VCS_STASH_ICON]// }'" + sub VCS_INCOMING_CHANGES_ICON "'${icons[VCS_INCOMING_CHANGES_ICON]// }'" + sub VCS_OUTGOING_CHANGES_ICON "'${icons[VCS_OUTGOING_CHANGES_ICON]// }'" + fi else sub VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER}'" sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER}'" -- cgit v1.2.3 From 1ac9c771f76a477cfd5c9cd0b6ae29d64bd01514 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 11 Oct 2019 16:53:28 +0200 Subject: cleanup --- config/p10k-classic.zsh | 13 ++++----- config/p10k-lean.zsh | 6 ++-- config/p10k-p9k.zsh | 74 ------------------------------------------------- 3 files changed, 7 insertions(+), 86 deletions(-) delete mode 100644 config/p10k-p9k.zsh diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 7b9ae002..88b8ec88 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -25,7 +25,7 @@ unset -m 'POWERLEVEL9K_*' # The list of segments shown on the left. Fill it with the most important segments. - typeset -ga POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( + typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( # =========================[ Line #1 ]========================= # os_icon # os identifier dir # current directory @@ -344,12 +344,11 @@ if (( $1 )); then # Styling for up-to-date Git status. - local meta='%f' # default foreground + local meta='%248F' # grey foreground local clean='%76F' # green foreground local modified='%178F' # yellow foreground local untracked='%39F' # blue foreground local conflicted='%196F' # red foreground - local loading='%244F' # grey foreground else # Styling for incomplete and stale Git status. local meta='%244F' # grey foreground @@ -357,7 +356,6 @@ local modified='%244F' # grey foreground local untracked='%244F' # grey foreground local conflicted='%244F' # grey foreground - local loading='%244F' # grey foreground fi local res @@ -471,7 +469,6 @@ typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='↵' ###################[ command_execution_time: duration of the last command ]################### - # Background color. # Show duration of the last command if takes longer than this many seconds. typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3 # Show this many fractional digits. Zero means round to seconds. @@ -534,7 +531,7 @@ # Context color when running with privileges. typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178 - # Context format when running with privileges: bold user@hostname. + # Context format when running with privileges: %n is username, %m is hostname, %B for bold. typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%B%n@%m' # Don't show context unless running with privileges or in SSH. @@ -767,8 +764,8 @@ # Regular expression for the VPN network interface. Run ifconfig while on VPN to see the # name of the interface. typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(wg|(.*tun))[0-9]*' - # Custom icon. - # typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Icon to show when on VPN. + typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' #########################[ proxy: system-wide http/https/ftp proxy ]########################## # Proxy color. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index d350785b..b57a9094 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -329,7 +329,6 @@ local modified='%178F' # yellow foreground local untracked='%39F' # blue foreground local conflicted='%196F' # red foreground - local loading='%244F' # grey foreground else # Styling for incomplete and stale Git status. local meta='%244F' # grey foreground @@ -337,7 +336,6 @@ local modified='%244F' # grey foreground local untracked='%244F' # grey foreground local conflicted='%244F' # grey foreground - local loading='%244F' # grey foreground fi local res @@ -746,8 +744,8 @@ # Regular expression for the VPN network interface. Run ifconfig while on VPN to see the # name of the interface. typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(wg|(.*tun))[0-9]*' - # Custom icon. - # typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Icon to show when on VPN. + typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' #########################[ proxy: system-wide http/https/ftp proxy ]########################## # Proxy color. diff --git a/config/p10k-p9k.zsh b/config/p10k-p9k.zsh deleted file mode 100644 index c14be784..00000000 --- a/config/p10k-p9k.zsh +++ /dev/null @@ -1,74 +0,0 @@ -# Config for Powerlevel10k with the default style of Powerlevel9k. - -# Temporarily change options. -'builtin' 'local' '-a' 'p10k_config_opts' -[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') -[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') -[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') -'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' - -() { - emulate -L zsh - - # Unset all configuration options. This allows you to apply configiguration changes without - # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. - unset -m 'POWERLEVEL9K_*' - - # To disable default icons for all segments, set POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION=''. - # - # To enable default icons for all segments, don't define POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION - # or set it to '${P9K_VISUAL_IDENTIFIER}'. - # - # To remove trailing space from all default icons, set POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION - # to '${P9K_VISUAL_IDENTIFIER% }'. - # - # To enable default icons for one segment (e.g., dir), set - # POWERLEVEL9K_DIR_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}'. - # - # To assign a specific icon to one segment (e.g., dir), set - # POWERLEVEL9K_DIR_VISUAL_IDENTIFIER_EXPANSION='⭐'. - # - # To assign a specific icon to a segment in a given state (e.g., dir in state NOT_WRITABLE), - # set POWERLEVEL9K_DIR_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐'. - # - # Note: You can use $'\u2B50' instead of '⭐'. It's especially convenient when specifying - # icons that your text editor cannot render. Don't forget to put $ and use single quotes when - # defining icons via Unicode codepoints. - # - # Note: Many default icons cannot be displayed with system fonts. You'll need to install a - # capable font to use them. See POWERLEVEL9K_MODE below. - # typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' - - # This option makes a difference only when default icons are enabled for all or some prompt - # segments (see POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION above). LOCK_ICON can be printed as - # $'\uE0A2', $'\uE138' or $'\uF023' depending on POWERLEVEL9K_MODE. The correct value of this - # parameter depends on the provider of the font your terminal is using. - # - # Font Provider | POWERLEVEL9K_MODE - # ---------------------------------+------------------- - # Powerline | powerline - # Font Awesome | awesome-fontconfig - # Adobe Source Code Pro | awesome-fontconfig - # Source Code Pro | awesome-fontconfig - # Awesome-Terminal Fonts (regular) | awesome-fontconfig - # Awesome-Terminal Fonts (patched) | awesome-patched - # Nerd Fonts | nerdfont-complete - # Other | compatible - # - # If this looks overwhelming, either stick with a preinstalled system font and set - # POWERLEVEL9K_MODE=compatible, or install the recommended Powerlevel10k font from - # https://github.com/romkatv/powerlevel10k/#recommended-meslo-nerd-font-patched-for-powerlevel10k - # and set POWERLEVEL9K_MODE=nerdfont-complete. - typeset -g POWERLEVEL9K_MODE=nerdfont-complete - - # typeset -g POWERLEVEL9K_PYTHON_ICON= - # typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON= - # typeset -g POWERLEVEL9K_VCS_UNSTAGED_ICON= - # typeset -g POWERLEVEL9K_VCS_STAGED_ICON= - # typeset -g POWERLEVEL9K_VCS_STASH_ICON= - # typeset -g POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON= - # typeset -g POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON= -} - -(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} -'builtin' 'unset' 'p10k_config_opts' -- cgit v1.2.3 From e85a07aad9c55aa25576810dbf193caaa1f1b75c Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 11 Oct 2019 16:53:50 +0200 Subject: bug fix: normalize colors --- internal/p10k.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 0f63b76c..67316cc3 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -387,9 +387,9 @@ _p9k_get_icon() { _p9k_translate_color() { if [[ $1 == <-> ]]; then # decimal color code: 255 - _p9k_ret=$1 + _p9k_ret=${(l.3..0.)1} elif [[ $1 == '#'[[:xdigit:]]## ]]; then # hexademical color code: #ffffff - _p9k_ret=$1 + _p9k_ret=${(L)1} else # named color: red # Strip prifixes if there are any. _p9k_ret=$__p9k_colors[${${${1#bg-}#fg-}#br}] -- cgit v1.2.3 From 09130614ecbe65f0ad7bfa2bcfa9bc36d0d2a659 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 11 Oct 2019 16:55:15 +0200 Subject: add rainbow style; delete p9k style --- config/p10k-rainbow.zsh | 844 ++++++++++++++++++++++++++++++++++++++++++++++++ internal/wizard.zsh | 181 ++++++----- 2 files changed, 947 insertions(+), 78 deletions(-) create mode 100644 config/p10k-rainbow.zsh diff --git a/config/p10k-rainbow.zsh b/config/p10k-rainbow.zsh new file mode 100644 index 00000000..35c7e91d --- /dev/null +++ b/config/p10k-rainbow.zsh @@ -0,0 +1,844 @@ +# Config for Powerlevel10k with powerline prompt style with colorful background. +# Type `p10k configure` to generate your own config based on it. +# +# Tip: Looking for a nice color? Here's a one-liner to print colormap. +# +# for i in {0..255}; do print -Pn "%${i}F${(l:3::0:)i}%f " ${${(M)$((i%8)):#7}:+$'\n'}; done + +# Temporarily change options. +'builtin' 'local' '-a' 'p10k_config_opts' +[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases') +[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob') +[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand') +'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand' + +() { + emulate -L zsh + setopt no_unset extended_glob + zmodload zsh/langinfo + if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then + local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8} + fi + + # Unset all configuration options. This allows you to apply configiguration changes without + # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`. + unset -m 'POWERLEVEL9K_*' + + # The list of segments shown on the left. Fill it with the most important segments. + typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( + # =========================[ Line #1 ]========================= + # os_icon # os identifier + dir # current directory + vcs # git status + # =========================[ Line #2 ]========================= + newline + # prompt_char # prompt symbol + ) + + # The list of segments shown on the right. Fill it with less important segments. + # Right prompt on the last prompt line (where you are typing your commands) gets + # automatically hidden when the input line reaches it. Right prompt above the + # last prompt line gets hidden if it would overlap with left prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( + # =========================[ Line #1 ]========================= + status # exit code of the last command + command_execution_time # duration of the last command + background_jobs # presence of background jobs + virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html) + anaconda # conda environment (https://conda.io/) + pyenv # python environment (https://github.com/pyenv/pyenv) + nodenv # node.js version from nodenv (https://github.com/nodenv/nodenv) + nvm # node.js version from nvm (https://github.com/nvm-sh/nvm) + nodeenv # node.js environment (https://github.com/ekalinin/nodeenv) + # node_version # node.js version + # go_version # go version (https://golang.org) + # rust_version # rustc version (https://www.rust-lang.org) + # dotnet_version # .NET version (https://dotnet.microsoft.com) + rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) + rvm # ruby version from rvm (https://rvm.io) + kubecontext # current kubernetes context (https://kubernetes.io/) + terraform # terraform workspace (https://www.terraform.io) + aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) + # aws_eb_env # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) + # azure # azure account name (https://docs.microsoft.com/en-us/cli/azure) + context # user@hostname + nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) + ranger # ranger shell (https://github.com/ranger/ranger) + # vpn_ip # virtual private network indicator + # ram # free RAM + # load # CPU load + # time # current time + # =========================[ Line #2 ]========================= + newline + # public_ip # public IP address + # proxy # system-wide http/https/ftp proxy + # battery # internal battery + # example # example user-defined segment (see prompt_example function below) + ) + + # To disable default icons for all segments, set POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION=''. + # + # To enable default icons for all segments, don't define POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION + # or set it to '${P9K_VISUAL_IDENTIFIER}'. + # + # To remove trailing space from all default icons, set POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION + # to '${P9K_VISUAL_IDENTIFIER% }'. + # + # To enable default icons for one segment (e.g., dir), set + # POWERLEVEL9K_DIR_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}'. + # + # To assign a specific icon to one segment (e.g., dir), set + # POWERLEVEL9K_DIR_VISUAL_IDENTIFIER_EXPANSION='⭐'. + # + # To assign a specific icon to a segment in a given state (e.g., dir in state NOT_WRITABLE), + # set POWERLEVEL9K_DIR_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐'. + # + # Note: You can use $'\u2B50' instead of '⭐'. It's especially convenient when specifying + # icons that your text editor cannot render. Don't forget to put $ and use single quotes when + # defining icons via Unicode codepoints. + # + # Note: Many default icons cannot be displayed with system fonts. You'll need to install a + # capable font to use them. See POWERLEVEL9K_MODE below. + typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' + + # This option makes a difference only when default icons are enabled for all or some prompt + # segments (see POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION above). LOCK_ICON can be printed as + # $'\uE0A2', $'\uE138' or $'\uF023' depending on POWERLEVEL9K_MODE. The correct value of this + # parameter depends on the provider of the font your terminal is using. + # + # Font Provider | POWERLEVEL9K_MODE + # ---------------------------------+------------------- + # Powerline | powerline + # Font Awesome | awesome-fontconfig + # Adobe Source Code Pro | awesome-fontconfig + # Source Code Pro | awesome-fontconfig + # Awesome-Terminal Fonts (regular) | awesome-fontconfig + # Awesome-Terminal Fonts (patched) | awesome-patched + # Nerd Fonts | nerdfont-complete + # Other | compatible + # + # If this looks overwhelming, either stick with a preinstalled system font and set + # POWERLEVEL9K_MODE=compatible, or install the recommended Powerlevel10k font from + # https://github.com/romkatv/powerlevel10k/#recommended-meslo-nerd-font-patched-for-powerlevel10k + # and set POWERLEVEL9K_MODE=nerdfont-complete. + typeset -g POWERLEVEL9K_MODE=nerdfont-complete + + # When set to true, icons appear before content on both sides of the prompt. When set + # to false, icons go after content. If empty or not set, icons go before content in the left + # prompt and after content in the right prompt. + # + # You can also override it for a specific segment: + # + # POWERLEVEL9K_STATUS_ICON_BEFORE_CONTENT=false + # + # Or for a specific segment in specific state: + # + # POWERLEVEL9K_DIR_NOT_WRITABLE_ICON_BEFORE_CONTENT=false + typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT= + + # Add an empty line before each prompt. + typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true + + # Connect left prompt lines with these symbols. You'll probably want to use the same color + # as POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND below. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX='%242F╭─' + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX='%242F├─' + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX='%242F╰─' + # Connect right prompt lines with these symbols. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX='%242F─╮' + typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX='%242F─┤' + typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX='%242F─╯' + + # Filler between left and right prompt on the first prompt line. You can set it to ' ', '·' or + # '─'. The last two make it easier to see the alignment between left and right prompt and to + # separate prompt from command output. You might want to set POWERLEVEL9K_PROMPT_ADD_NEWLINE=false + # for more compact prompt if using using this option. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_BACKGROUND= + if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then + # The color of the filler. You'll probably want to match the color of POWERLEVEL9K_MULTILINE + # ornaments defined above. + typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=242 + # Start filler from the edge of the screen if there are no left segments on the first line. + typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_FIRST_SEGMENT_END_SYMBOL='%{%}' + # End filler on the edge of the screen if there are no right segments on the first line. + typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}' + fi + + # Separator between same-color segments on the left. + typeset -g POWERLEVEL9K_LEFT_SUBSEGMENT_SEPARATOR='\uE0B1' + # Separator between same-color segments on the right. + typeset -g POWERLEVEL9K_RIGHT_SUBSEGMENT_SEPARATOR='\uE0B3' + # Separator between different-color segments on the left. + typeset -g POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\uE0B0' + # Separator between different-color segments on the right. + typeset -g POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR='\uE0B2' + # The right end of left prompt. + typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='\uE0B0' + # The left end of right prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='\uE0B2' + # The left end of left prompt. + typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= + # The right end of right prompt. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL= + # Left prompt terminator for lines without any segments. + typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL= + + #################################[ os_icon: os identifier ]################################## + # OS identifier color. + typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND=255 + # typeset -g POWERLEVEL9K_OS_ICON_BACKGROUND=0 + # Make the icon bold. + typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='%B${P9K_CONTENT}' + + ################################[ prompt_char: prompt symbol ]################################ + # Transparent background. + typeset -g POWERLEVEL9K_PROMPT_CHAR_BACKGROUND= + # Green prompt symbol if the last command succeeded. + typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS}_FOREGROUND=76 + # Red prompt symbol if the last command failed. + typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS}_FOREGROUND=196 + # Default prompt symbol. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='❯' + # Prompt symbol in command vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮' + # Prompt symbol in visual vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='Ⅴ' + # Prompt symbol in overwrite vi mode. + typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶' + typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true + # No line terminator if prompt_char is the last segment. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL= + # No line introducer if prompt_char is the first segment. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL= + # No surrounding whitespace. + typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_{LEFT,RIGHT}_WHITESPACE= + + ##################################[ dir: current directory ]################################## + # Current directory background color. + # typeset -g POWERLEVEL9K_DIR_BACKGROUND=4 + # Default current directory foreground color. + typeset -g POWERLEVEL9K_DIR_FOREGROUND=0 + # If directory is too long, shorten some of its segments to the shortest possible unique + # prefix. The shortened directory can be tab-completed to the original. + typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique + # Replace removed segment suffixes with this symbol. + typeset -g POWERLEVEL9K_SHORTEN_DELIMITER= + # Color of the shortened directory segments. + typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=8 + # Color of the anchor directory segments. Anchor segments are never shortened. The first + # segment is always an anchor. + typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=0 + # Display anchor directory segments in bold. + typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true + # Don't shorten directories that contain any of these files. They are anchors. + local anchor_files=( + .bzr + .citc + .git + .hg + .node-version + .python-version + .ruby-version + .shorten_folder_marker + .svn + .terraform + CVS + Cargo.toml + composer.json + go.mod + package.json + ) + typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})" + # Don't shorten this many last directory segments. They are anchors. + typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 + # Shorten directory if it's longer than this even if there is space for it. The value can + # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty, + # directory will be shortened only when prompt doesn't fit or when other parameters demand it + # (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below). + typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this + # many columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40 + # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least + # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands. + typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50 + # If set to true, embed a hyperlink into the directory. Useful for quickly + # opening a directory in the file manager simply by clicking the link. + # Can also be handy when the directory is shortened, as it allows you to see + # the full directory that was used in previous commands. + typeset -g POWERLEVEL9K_DIR_HYPERLINK=false + + # Enable special styling for non-writable directories. + typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=true + # Show this icon when the current directory is not writable. POWERLEVEL9K_DIR_SHOW_WRITABLE + # above must be set to true for this parameter to have effect. + # typeset -g POWERLEVEL9K_DIR_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Custom prefix. + # typeset -g POWERLEVEL9K_DIR_PREFIX='in ' + + # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons for different directories. + # It must be an array with 3 * N elements. Each triplet consists of: + # + # 1. A pattern against which the current directory is matched. Matching is done with + # extended_glob option enabled. + # 2. Directory class for the purpose of styling. + # 3. Icon. + # + # Triplets are tried in order. The first triplet whose pattern matches $PWD wins. If there + # are no matches, the directory will have no icon. + # + # Example: + # + # typeset -g POWERLEVEL9K_DIR_CLASSES=( + # '~/work(/*)#' WORK '(╯°□°)╯︵ ┻━┻' + # '~(/*)#' HOME '⌂' + # '*' DEFAULT '') + # + # With these settings, the current directory in the prompt may look like this: + # + # (╯°□°)╯︵ ┻━┻ ~/work/projects/important/urgent + # + # Or like this: + # + # ⌂ ~/best/powerlevel10k + # + # You can also set different colors for directories of different classes. Remember to override + # FOREGROUND, SHORTENED_FOREGROUND and ANCHOR_FOREGROUND for every directory class that you wish + # to have its own color. + # + # typeset -g POWERLEVEL9K_DIR_WORK_BACKGROUND=4 + # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=0 + # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=8 + # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=0 + # + # typeset -g POWERLEVEL9K_DIR_CLASSES=() + + #####################################[ vcs: git status ]###################################### + # Versio control system colors. + # typeset -g POWERLEVEL9K_VCS_CLEAN_BACKGROUND=2 + # typeset -g POWERLEVEL9K_VCS_MODIFIED_BACKGROUND=3 + # typeset -g POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND=2 + # typeset -g POWERLEVEL9K_VCS_CONFLICTED_BACKGROUND=3 + # typeset -g POWERLEVEL9K_VCS_LOADING_BACKGROUND=8 + + # Branch icon. Set this parameter to '\uF126 ' for the popular Powerline branch icon. + typeset -g POWERLEVEL9K_VCS_BRANCH_ICON= + POWERLEVEL9K_VCS_BRANCH_ICON=${(g::)POWERLEVEL9K_VCS_BRANCH_ICON} + + # Untracked files icon. It's really a question mark, your font isn't broken. + # Change the value of this parameter to show a different icon. + typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' + POWERLEVEL9K_VCS_UNTRACKED_ICON=${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON} + + # Formatter for Git status. + # + # Example output: master ⇣42⇡42 *42 merge ~42 +42 !42 ?42. + # + # You can edit the function to customize how Git status looks. + # + # VCS_STATUS_* parameters are set by gitstatus plugin. See reference: + # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. + function my_git_formatter() { + emulate -L zsh + + if [[ -n $P9K_CONTENT ]]; then + # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from + # gitstatus plugin). VCS_STATUS_* parameters are not available in this case. + typeset -g my_git_format=$P9K_CONTENT + return + fi + + # Styling for different parts of Git status. + local meta='%7F' # white foreground + local clean='%0F' # black foreground + local modified='%0F' # black foreground + local untracked='%0F' # black foreground + local conflicted='%1F' # red foreground + + local res + local where # branch name, tag or commit + if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then + res+="${clean}${POWERLEVEL9K_VCS_BRANCH_ICON}" + where=${(V)VCS_STATUS_LOCAL_BRANCH} + elif [[ -n $VCS_STATUS_TAG ]]; then + res+="${meta}#" + where=${(V)VCS_STATUS_TAG} + else + res+="${meta}@" + where=${VCS_STATUS_COMMIT[1,8]} + fi + + # If local branch name or tag is at most 32 characters long, show it in full. + # Otherwise show the first 12 … the last 12. + (( $#where > 32 )) && where[13,-13]="…" + res+="${clean}${where//\%/%%}" # escape % + + # Show tracking branch name if it differs from local branch. + if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then + res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape % + fi + + # ⇣42 if behind the remote. + (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" + # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. + (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " + (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}" + # *42 if have stashes. + (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" + # 'merge' if the repo is in an unusual state. + [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" + # ~42 if have merge conflicts. + (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" + # +42 if have staged changes. + (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" + # !42 if have unstaged changes. + (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" + # ?42 if have untracked files. It's really a question mark, your font isn't broken. + # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon. + # Remove the next line if you don't want to see untracked files at all. + (( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}" + + typeset -g my_git_format=$res + } + functions -M my_git_formatter 2>/dev/null + + # Disable the default Git status formatting. + typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true + # Install our own Git status formatter. + typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}' + # Enable counters for staged, unstaged, etc. + typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1 + + # Custom icon. + # typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_VCS_PREFIX='on ' + + # Show status of repositories of these types. You can add svn and/or hg if you are + # using them. If you do, your prompt may become slow even when your current directory + # isn't in an svn or hg reposotiry. + typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) + + ##########################[ status: exit code of the last command ]########################### + # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and + # style them independently from the regular OK and ERROR state. + typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true + + # Status on success. No content, just an icon. No need to show it if prompt_char is enabled as + # it will signify success by turning green. + typeset -g POWERLEVEL9K_STATUS_OK=true + typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION='✔' + # typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=2 + # typeset -g POWERLEVEL9K_STATUS_OK_BACKGROUND=0 + + # Status when some part of a pipe command fails but the overall exit status is zero. It may look + # like this: 1|0. + typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true + typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION='✔' + # typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=2 + # typeset -g POWERLEVEL9K_STATUS_OK_PIPE_BACKGROUND=0 + + # Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as + # it will signify error by turning red. + typeset -g POWERLEVEL9K_STATUS_ERROR=true + typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='↵' + # typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=3 + # typeset -g POWERLEVEL9K_STATUS_ERROR_BACKGROUND=1 + + # Status when the last command was terminated by a signal. + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true + # Use terse signal names: "INT" instead of "SIGINT(2)". + typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=false + typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION='↵' + # typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=3 + # typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_BACKGROUND=1 + + # Status when some part of a pipe command fails and the overall exit status is also non-zero. + # It may look like this: 1|0. + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true + typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='↵' + # typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=3 + # typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_BACKGROUND=1 + + ###################[ command_execution_time: duration of the last command ]################### + # Execution time color. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=0 + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND=3 + # Show duration of the last command if takes longer than this many seconds. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3 + # Show this many fractional digits. Zero means round to seconds. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0 + # Duration format: 1d 2h 3m 4s. + typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s' + # Custom icon. + # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PREFIX='took ' + + #######################[ background_jobs: presence of background jobs ]####################### + # Background jobs color. + # typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=6 + # typeset -g POWERLEVEL9K_BACKGROUND_JOBS_BACKGROUND=0 + # Don't show the number of background jobs. + typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false + # Icon to show when there are background jobs. + typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' + + ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### + # NordVPN connection indicator color. + # typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=7 + # typeset -g POWERLEVEL9K_NORDVPN_BACKGROUND=4 + # Hide NordVPN connection indicator when not connected. + typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_CONTENT_EXPANSION= + typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_VISUAL_IDENTIFIER_EXPANSION= + # Custom icon. + # typeset -g POWERLEVEL9K_NORDVPN_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]################## + # Ranger shell color. + # typeset -g POWERLEVEL9K_RANGER_FOREGROUND=3 + # typeset -g POWERLEVEL9K_RANGER_BACKGROUND=0 + # Custom icon. + # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################################[ ram: free RAM ]####################################### + # RAM color. + # typeset -g POWERLEVEL9K_RAM_FOREGROUND=0 + # typeset -g POWERLEVEL9K_RAM_BACKGROUND=3 + # Custom icon. + # typeset -g POWERLEVEL9K_RAM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ######################################[ load: CPU load ]###################################### + # Show average CPU load over this many last minutes. Valid values are 1, 5 and 15. + typeset -g POWERLEVEL9K_LOAD_WHICH=5 + # Load color when load is under 50%. + # typeset -g POWERLEVEL9K_LOAD_NORMAL_FOREGROUND=0 + # typeset -g POWERLEVEL9K_LOAD_NORMAL_BACKGROUND=2 + # Load color when load is between 50% and 70%. + # typeset -g POWERLEVEL9K_LOAD_WARNING_FOREGROUND=0 + # typeset -g POWERLEVEL9K_LOAD_WARNING_BACKGROUND=3 + # Load color when load is over 70%. + # typeset -g POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND=0 + # typeset -g POWERLEVEL9K_LOAD_CRITICAL_BACKGROUND=1 + # Custom icon. + # typeset -g POWERLEVEL9K_LOAD_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##################################[ context: user@hostname ]################################## + # Default context color. + typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=3 + typeset -g POWERLEVEL9K_CONTEXT_BACKGROUND=0 + # Default context format: %n is username, %m is hostname. + typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m' + + # Context color when running with privileges. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=1 + typeset -g POWERLEVEL9K_CONTEXT_ROOT_BACKGROUND=0 + # Context format when running with privileges: %n is username, %m is hostname. + typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%n@%m' + + # Don't show context unless running with privileges or in SSH. + # Tip: Remove the next line to always show context. + typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION= + + # Custom icon. + # typeset -g POWERLEVEL9K_CONTEXT_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_CONTEXT_PREFIX='with ' + + ###[ virtualenv: python virtual environment (https://docs.python.org/3/library/venv.html) ]### + # Python virtual environment color. + # typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=0 + # typeset -g POWERLEVEL9K_VIRTUALENV_BACKGROUND=4 + # Don't show Python version next to the virtual environment name. + typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false + # Separate environment name from Python version only with a space. + typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + # typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #####################[ anaconda: conda environment (https://conda.io/) ]###################### + # Anaconda environment color. + # typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=0 + # typeset -g POWERLEVEL9K_ANACONDA_BACKGROUND=4 + # Don't show Python version next to the anaconda environment name. + typeset -g POWERLEVEL9K_ANACONDA_SHOW_PYTHON_VERSION=false + # Separate environment name from Python version only with a space. + typeset -g POWERLEVEL9K_ANACONDA_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + # typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ pyenv: python environment (https://github.com/pyenv/pyenv) ]################ + # Pyenv color. + # typeset -g POWERLEVEL9K_PYENV_FOREGROUND=0 + # typeset -g POWERLEVEL9K_PYENV_BACKGROUND=4 + # Don't show the current Python version if it's the same as global. + typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false + # Custom icon. + # typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ nodenv: node.js version from nodenv (https://github.com/nodenv/nodenv) ]########## + # Nodenv color. + # typeset -g POWERLEVEL9K_NODENV_FOREGROUND=2 + # typeset -g POWERLEVEL9K_NODENV_BACKGROUND=0 + # Don't show node version if it's the same as global: $(nodenv version-name) == $(nodenv global). + typeset -g POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW=false + # Custom icon. + # typeset -g POWERLEVEL9K_NODENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### + # Nvm color. + # typeset -g POWERLEVEL9K_NVM_FOREGROUND=70 + # Custom icon. + # typeset -g POWERLEVEL9K_NVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ############[ nodeenv: node.js environment (https://github.com/ekalinin/nodeenv) ]############ + # Nodeenv color. + # typeset -g POWERLEVEL9K_NODEENV_FOREGROUND=2 + # typeset -g POWERLEVEL9K_NODEENV_BACKGROUND=0 + # Don't show Node version next to the environment name. + typeset -g POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION=false + # Separate environment name from Node version only with a space. + typeset -g POWERLEVEL9K_NODEENV_{LEFT,RIGHT}_DELIMITER= + # Custom icon. + # typeset -g POWERLEVEL9K_NODEENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##############################[ node_version: node.js version ]############################### + # Node version color. + # typeset -g POWERLEVEL9K_NODE_VERSION_FOREGROUND=7 + # typeset -g POWERLEVEL9K_NODE_VERSION_BACKGROUND=2 + # Show node version only when in a directory tree containing package.json. + typeset -g POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_NODE_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ go_version: go version (https://golang.org) ]######################## + # Go version color. + # typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=255 + # typeset -g POWERLEVEL9K_GO_VERSION_BACKGROUND=2 + # Show go version only when in a go project subdirectory. + typeset -g POWERLEVEL9K_GO_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #################[ rust_version: rustc version (https://www.rust-lang.org) ]################## + # Rust version color. + # typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=0 + # typeset -g POWERLEVEL9K_RUST_VERSION_BACKGROUND=208 + # Show rust version only when in a rust project subdirectory. + typeset -g POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################ + # .NET version color. + # typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=7 + # typeset -g POWERLEVEL9K_DOTNET_VERSION_BACKGROUND=5 + # Show .NET version only when in a .NET project subdirectory. + typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## + # Rbenv color. + # typeset -g POWERLEVEL9K_RBENV_FOREGROUND=0 + # typeset -g POWERLEVEL9K_RBENV_BACKGROUND=1 + # Don't show ruby version if it's the same as global: $(rbenv version-name) == $(rbenv global). + typeset -g POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW=false + # Custom icon. + # typeset -g POWERLEVEL9K_RBENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #######################[ rvm: ruby version from rvm (https://rvm.io) ]######################## + # Rvm color. + # typeset -g POWERLEVEL9K_RVM_FOREGROUND=0 + # typeset -g POWERLEVEL9K_RVM_BACKGROUND=240 + # Don't show @gemset at the end. + typeset -g POWERLEVEL9K_RVM_SHOW_GEMSET=false + # Don't show ruby- at the front. + typeset -g POWERLEVEL9K_RVM_SHOW_PREFIX=false + # Custom icon. + # typeset -g POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################[ terraform: terraform workspace (https://www.terraform.io) ]################# + # Terraform color. + # typeset -g POWERLEVEL9K_TERRAFORM_FOREGROUND=4 + # typeset -g POWERLEVEL9K_TERRAFORM_BACKGROUND=0 + # Custom icon. + # typeset -g POWERLEVEL9K_TERRAFORM_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]# + # AWS profile color. + # typeset -g POWERLEVEL9K_AWS_FOREGROUND=7 + # typeset -g POWERLEVEL9K_AWS_BACKGROUND=1 + # Custom icon. + # typeset -g POWERLEVEL9K_AWS_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #[ aws_eb_env: aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) ]# + # AWS Elastic Beanstalk environment color. + # typeset -g POWERLEVEL9K_AWS_EB_ENV_FOREGROUND=2 + # typeset -g POWERLEVEL9K_AWS_EB_ENV_BACKGROUND=0 + # Custom icon. + # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## + # Azure account name color. + # typeset -g POWERLEVEL9K_AZURE_FOREGROUND=7 + # typeset -g POWERLEVEL9K_AZURE_BACKGROUND=4 + # Custom icon. + # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' + + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# + # Kubernetes context classes for the purpose of using different colors, icons and expansions with + # different contexts. + # + # POWERLEVEL9K_KUBECONTEXT_CLASSES is an array with even number of elements. The first element + # in each pair defines a pattern against which the current kubernetes context gets matched. + # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below) + # that gets matched. If you unset all POWERLEVEL9K_KUBECONTEXT_*CONTENT_EXPANSION parameters, + # you'll see this value in your prompt. The second element of each pair in + # POWERLEVEL9K_KUBECONTEXT_CLASSES defines the context class. Patterns are tried in order. The + # first match wins. + # + # For example, given these settings: + # + # typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( + # '*prod*' PROD + # '*test*' TEST + # '*' DEFAULT) + # + # If your current kubernetes context is "deathray-testing/default", its class is TEST + # because "deathray-testing/default" doesn't match the pattern '*prod*' but does match '*test*'. + # + # You can define different colors, icons and content expansions for different classes: + # + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_FOREGROUND=0 + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_BACKGROUND=2 + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' + typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=( + # '*prod*' PROD # These values are examples that are unlikely + # '*test*' TEST # to match your needs. Customize them as needed. + '*' DEFAULT) + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_FOREGROUND=7 + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_BACKGROUND=5 + # typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' + + # Use POWERLEVEL9K_KUBECONTEXT_CONTENT_EXPANSION to specify the content displayed by kubecontext + # segment. Parameter expansions are very flexible and fast, too. See reference: + # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion. + # + # Within the expansion the following parameters are always available: + # + # - P9K_CONTENT The content that would've been displayed if there was no content + # expansion defined. + # - P9K_KUBECONTEXT_NAME The current context's name. Corresponds to column NAME in the + # output of `kubectl config get-contexts`. + # - P9K_KUBECONTEXT_CLUSTER The current context's cluster. Corresponds to column CLUSTER in the + # output of `kubectl config get-contexts`. + # - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE + # in the output of `kubectl config get-contexts`. If there is no + # namespace, the parameter is set to "default". + # + # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS), + # the following extra parameters are available: + # + # - P9K_KUBECONTEXT_CLOUD_NAME Either "gke" or "eks". + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT Account/project ID. + # - P9K_KUBECONTEXT_CLOUD_ZONE Availability zone. + # - P9K_KUBECONTEXT_CLOUD_CLUSTER Cluster. + # + # P9K_KUBECONTEXT_CLOUD_* parameters are derived from P9K_KUBECONTEXT_CLUSTER. For example, + # if P9K_KUBECONTEXT_CLUSTER is "gke_my-account_us-east1-a_my-cluster-01": + # + # - P9K_KUBECONTEXT_CLOUD_NAME=gke + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=my-account + # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east1-a + # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 + # + # If P9K_KUBECONTEXT_CLUSTER is "arn:aws:eks:us-east-1:123456789012:cluster/my-cluster-01": + # + # - P9K_KUBECONTEXT_CLOUD_NAME=eks + # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=123456789012 + # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east-1 + # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01 + typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION= + # Show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back to P9K_KUBECONTEXT_NAME. + POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}' + # Append the current context's namespace if it's not "default". + POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${${:-/$P9K_KUBECONTEXT_NAMESPACE}:#/default}' + + # Custom prefix. + # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='at ' + + ###############################[ public_ip: public IP address ]############################### + # Public IP color. + # typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=7 + # typeset -g POWERLEVEL9K_PUBLIC_IP_BACKGROUND=0 + # Custom icon. + # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ########################[ vpn_ip: virtual private network indicator ]######################### + # VPN IP color. + # typeset -g POWERLEVEL9K_VPN_IP_FOREGROUND=0 + # typeset -g POWERLEVEL9K_VPN_IP_BACKGROUND=6 + # When on VPN, show just an icon without the IP address. + typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION= + # Regular expression for the VPN network interface. Run ifconfig while on VPN to see the + # name of the interface. + typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(wg|(.*tun))[0-9]*' + # Icon to show when on VPN. + typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' + + #########################[ proxy: system-wide http/https/ftp proxy ]########################## + # Proxy color. + # typeset -g POWERLEVEL9K_PROXY_FOREGROUND=4 + # typeset -g POWERLEVEL9K_PROXY_BACKGROUND=0 + # Custom icon. + # typeset -g POWERLEVEL9K_PROXY_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ################################[ battery: internal battery ]################################# + # Show battery in red when it's below this level and not connected to power supply. + typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20 + typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=1 + # Show battery in green when it's charging or fully charged. + typeset -g POWERLEVEL9K_BATTERY_{CHARGING,CHARGED}_FOREGROUND=2 + # Show battery in yellow when it's discharging. + typeset -g POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND=3 + # Battery pictograms going from low to high level of charge. + typeset -g POWERLEVEL9K_BATTERY_STAGES=('%K{232}▁' '%K{232}▂' '%K{232}▃' '%K{232}▄' '%K{232}▅' '%K{232}▆' '%K{232}▇' '%K{232}█') + # Don't show the remaining time to charge/discharge. + typeset -g POWERLEVEL9K_BATTERY_VERBOSE=false + # typeset -g POWERLEVEL9K_BATTERY_BACKGROUND=0 + + ####################################[ time: current time ]#################################### + # Current time color. + # typeset -g POWERLEVEL9K_TIME_FOREGROUND=0 + # typeset -g POWERLEVEL9K_TIME_BACKGROUND=7 + # Format for the current time: 09:51:02. See `man 3 strftime`. + typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}' + # If set to true, time will update when you hit enter. This way prompts for the past + # commands will contain the start times of their commands as opposed to the default + # behavior where they contain the end times of their preceding commands. + typeset -g POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=false + # Custom icon. + # typeset -g POWERLEVEL9K_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐' + # Custom prefix. + # typeset -g POWERLEVEL9K_TIME_PREFIX='at ' + + # Example of a user-defined prompt segment. Function prompt_example will be called on every + # prompt if `example` prompt segment is added to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or + # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and orange text greeting the user. + # + # Type `p10k help segment` for documentation and a more sophisticated example. + function prompt_example() { + p10k segment -b red -f yellow -i '⭐' -t 'hello, %n' + } + + # User-defined prompt segments can be customized the same way as built-in segments. + # typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=4 + typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='${P9K_VISUAL_IDENTIFIER}' +} + +(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} +'builtin' 'unset' 'p10k_config_opts' diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 5b396aa1..3d809256 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -66,7 +66,7 @@ typeset -ra lean_left=( ) typeset -ra lean_right=( - ' $prefixes[2]%101F$extra_icons[4]3s%f${show_time:+ $prefixes[3]%66F$extra_icons[5]16:23:42%f}' '' + ' $prefixes[2]%101F$extra_icons[4]5s%f${show_time:+ $prefixes[3]%66F$extra_icons[5]16:23:42%f}' '' '' '' ) @@ -76,12 +76,12 @@ typeset -ra classic_left=( ) typeset -ra classic_right=( - '%$bg_color[$color]F$right_head%K{$bg_color[$color]}%f %$prefix_color[$color]F$prefixes[2]%101F3s $extra_icons[4]${show_time:+%$sep_color[$color]F$right_subsep %$prefix_color[$color]F$prefixes[3]%66F16:23:42 $extra_icons[5]}%k%F{$bg_color[$color]}$right_tail%f' '%$frame_color[$color]F─╮%f' + '%$bg_color[$color]F$right_head%K{$bg_color[$color]}%f %$prefix_color[$color]F$prefixes[2]%101F5s $extra_icons[4]${show_time:+%$sep_color[$color]F$right_subsep %$prefix_color[$color]F$prefixes[3]%66F16:23:42 $extra_icons[5]}%k%F{$bg_color[$color]}$right_tail%f' '%$frame_color[$color]F─╮%f' '' '%$frame_color[$color]F─╯%f' ) typeset -ra pure_left=( - '' '%4F~/src%f %242Fmaster%f' + '' '%4F~/src%f %242Fmaster%f %3F5s%f' '' '%5F❯%f █' ) @@ -90,14 +90,14 @@ typeset -ra pure_right=( '' '' ) -typeset -ra p9k_left=( - '' '%K{0}%F{3} user@host %K{4}%F{0}$right_triangle%F{0} $extra_icons[2]~/src %K{2}%F{4}$right_triangle%F{0} $extra_icons[3]master %k%F{2}$right_triangle%f' - '' ' █' +typeset -ra rainbow_left=( + '%$frame_color[$color]F╭─' '%F{${${extra_icons[1]:+0}:-4}}$left_tail${extra_icons[1]:+%K{0\} $extra_icons[1] %K{4\}%0F$left_sep}%K{4}%0F $extra_icons[2]%B~%b%K{4}%0F/%Bsrc%b%K{4} %K{2}%4F$left_sep %0F$prefixes[1]$extra_icons[3]master %k%2F$left_head%f' + '%$frame_color[$color]F╰─' '%f █' ) -typeset -ra p9k_right=( - '%F{0}$left_triangle%K{0}%F{2} ${(g::)icons[OK_ICON]} %F{8}$left_triangle%K{8}%F{0} 42 %F{7}$left_triangle%K{7}%F{0} 16:23:42 $extra_icons[5]%k%f' '' - '' '' +typeset -ra rainbow_right=( + '%3F$right_head%K{3} %0F$prefixes[2]5s $extra_icons[4]%1F${show_time:+%7F$right_sep%K{7\} %0F$prefixes[3]16:23:42 $extra_icons[5]%7F}%k$right_tail%f' '%$frame_color[$color]F─╮%f' + '' '%$frame_color[$color]F─╯%f' ) function prompt_length() { @@ -539,67 +539,44 @@ function ask_narrow_icons() { } function ask_style() { - if (( cap_diamond && LINES < 25 )); then + if (( cap_diamond && LINES < 26 )); then local nl='' else local nl=$'\n' fi while true; do clear - local extra= flowing -c "%BPrompt Style%b" print -n $nl - print -P "%B(1) Lean (recommended).%b" + print -P "%B(1) Lean.%b" print -n $nl style=lean print_prompt print -P "" - print -P "%B(2) Classic (recommended).%b" + print -P "%B(2) Classic.%b" print -n $nl style=classic print_prompt print -P "" - print -P "%B(3) Pure.%b" + print -P "%B(3) Rainbow.%b" + print -n $nl + style=rainbow print_prompt + print -P "" + print -P "%B(4) Pure.%b" print -n $nl style=pure print_prompt print -P "" - if (( cap_diamond )); then - extra+=4 - print -P "%B(4) Powerlevel9k.%b" - print -P "" - local dir_icon=${(g::)icons[HOME_SUB_ICON]} - local vcs_icon=${(g::)icons[VCS_GIT_GITHUB_ICON]} - local branch_icon=${(g::)icons[VCS_BRANCH_ICON]} - local time_icon=${(g::)icons[TIME_ICON]} - if (( cap_narrow_icons )); then - dir_icon=${dir_icon// } - vcs_icon=${vcs_icon// } - duration_icon=${duration_icon// } - time_icon=${time_icon// } - fi - branch_icon=${branch_icon// } - local many_icons=("" "$dir_icon " "$vcs_icon $branch_icon " " " "$time_icon ") - extra_icons=("$many_icons[@]") style=p9k num_lines=1 print_prompt - print -P "" - fi print -P "(r) Restart from the beginning." print -P "(q) Quit and do nothing." print -P "" local key= - read -k key${(%):-"?%BChoice [123${extra}rq]: %b"} || quit -c + read -k key${(%):-"?%BChoice [1234rq]: %b"} || quit -c case $key in q) quit;; r) return 1;; 1) style=lean; options+=lean; break;; 2) style=classic; options+=classic; break;; - 3) style=pure; empty_line=1; options+=pure; break;; - 4) if [[ $extra == *4* ]]; then - style=p9k - num_lines=1 - extra_icons=("$many_icons[@]") - options+=p9k - break - fi - ;; + 3) style=rainbow; options+=rainbow; break;; + 4) style=pure; empty_line=1; options+=pure; break;; esac done } @@ -648,6 +625,51 @@ function ask_color() { done } +function ask_frame_color() { + [[ $style != rainbow || $num_lines == 1 ]] && return + [[ $gap_char == ' ' && $left_frame == 0 && $right_frame == 0 ]] && return + if [[ $LINES -lt 26 ]]; then + local nl='' + else + local nl=$'\n' + fi + while true; do + clear + flowing -c "%BFrame Color%b" + print -n $nl + print -P "%B(1) Lightest.%b" + print -n $nl + color=1 print_prompt + print -P "" + print -P "%B(2) Light.%b" + print -n $nl + color=2 print_prompt + print -P "" + print -P "%B(3) Dark.%b" + print -n $nl + color=3 print_prompt + print -P "" + print -P "%B(4) Darkest.%b" + print -n $nl + color=4 print_prompt + print -P "" + print -P "(r) Restart from the beginning." + print -P "(q) Quit and do nothing." + print -P "" + + local key= + read -k key${(%):-"?%BChoice [1234rq]: %b"} || quit -c + case $key in + q) quit;; + r) return 1;; + 1) color=1; options+=lightest; break;; + 2) color=2; options+=light; break;; + 3) color=3; options+=dark; break;; + 4) color=4; options+=darkest; break;; + esac + done +} + function ask_time() { if (( wizard_columns < 80 )); then show_time= @@ -743,7 +765,7 @@ function ask_extra_icons() { time_icon=${time_icon// } fi branch_icon=${branch_icon// } - if [[ $style == classic ]]; then + if [[ $style == (classic|rainbow) ]]; then os_icon="%255F$os_icon%f" else os_icon="%f$os_icon" @@ -814,7 +836,7 @@ function ask_prefixes() { } function ask_separators() { - if [[ $style != classic || $cap_diamond != 1 ]]; then + if [[ $style != (classic|rainbow) || $cap_diamond != 1 ]]; then return fi if [[ $POWERLEVEL9K_MODE == nerdfont-complete && $LINES -lt 26 ]]; then @@ -901,7 +923,7 @@ function ask_separators() { } function ask_heads() { - if [[ $style != classic || $cap_diamond != 1 ]]; then + if [[ $style != (classic|rainbow) || $cap_diamond != 1 ]]; then return fi if [[ $POWERLEVEL9K_MODE == nerdfont-complete && $LINES -lt 26 ]]; then @@ -970,7 +992,7 @@ function ask_heads() { } function ask_tails() { - if [[ $style != classic ]]; then + if [[ $style != (classic|rainbow) ]]; then return fi if [[ $POWERLEVEL9K_MODE == nerdfont-complete && $LINES -lt 31 ]]; then @@ -1116,7 +1138,7 @@ function ask_gap_char() { } function ask_frame() { - if [[ $style != classic || $num_lines != 2 ]]; then + if [[ $style != (classic|rainbow) || $num_lines != 2 ]]; then return fi @@ -1277,24 +1299,12 @@ function generate_config() { uncomment 'typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION' sub VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER// }'" sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER// }'" + sub VPN_IP_VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER// }'" sub OS_ICON_CONTENT_EXPANSION "'%B\${P9K_CONTENT// }'" - if [[ $style == p9k ]]; then - uncomment 'typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON' - uncomment 'typeset -g POWERLEVEL9K_VCS_UNSTAGED_ICON' - uncomment 'typeset -g POWERLEVEL9K_VCS_STAGED_ICON' - uncomment 'typeset -g POWERLEVEL9K_VCS_STASH_ICON' - uncomment 'typeset -g POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON' - uncomment 'typeset -g POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON' - sub VCS_UNTRACKED_ICON "'${icons[VCS_UNTRACKED_ICON]// }'" - sub VCS_UNSTAGED_ICON "'${icons[VCS_UNSTAGED_ICON]// }'" - sub VCS_STAGED_ICON "'${icons[VCS_STAGED_ICON]// }'" - sub VCS_STASH_ICON "'${icons[VCS_STASH_ICON]// }'" - sub VCS_INCOMING_CHANGES_ICON "'${icons[VCS_INCOMING_CHANGES_ICON]// }'" - sub VCS_OUTGOING_CHANGES_ICON "'${icons[VCS_OUTGOING_CHANGES_ICON]// }'" - fi else sub VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER}'" sub BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER}'" + sub VPN_IP_VISUAL_IDENTIFIER_EXPANSION "'\${P9K_VISUAL_IDENTIFIER}'" fi if [[ $POWERLEVEL9K_MODE == compatible ]]; then @@ -1319,8 +1329,17 @@ function generate_config() { sub BATTERY_STAGES "\$'\uf58d\uf579\uf57a\uf57b\uf57c\uf57d\uf57e\uf57f\uf580\uf581\uf578'" fi - if [[ $style == classic ]]; then - sub BACKGROUND $bg_color[$color] + if [[ $style == (classic|rainbow) ]]; then + if [[ $style == classic ]]; then + sub BACKGROUND $bg_color[$color] + sub LEFT_SUBSEGMENT_SEPARATOR "'%$sep_color[$color]F$left_subsep'" + sub RIGHT_SUBSEGMENT_SEPARATOR "'%$sep_color[$color]F$right_subsep'" + sub VCS_LOADING_FOREGROUND $sep_color[$color] + rep '%248F' "%$prefix_color[$color]F" + else + sub LEFT_SUBSEGMENT_SEPARATOR "'$left_subsep'" + sub RIGHT_SUBSEGMENT_SEPARATOR "'$right_subsep'" + fi sub MULTILINE_FIRST_PROMPT_GAP_FOREGROUND $frame_color[$color] sub MULTILINE_FIRST_PROMPT_PREFIX "'%$frame_color[$color]F╭─'" sub MULTILINE_NEWLINE_PROMPT_PREFIX "'%$frame_color[$color]F├─'" @@ -1328,16 +1347,12 @@ function generate_config() { sub MULTILINE_FIRST_PROMPT_SUFFIX "'%$frame_color[$color]F─╮'" sub MULTILINE_NEWLINE_PROMPT_SUFFIX "'%$frame_color[$color]F─┤'" sub MULTILINE_LAST_PROMPT_SUFFIX "'%$frame_color[$color]F─╯'" - sub LEFT_SUBSEGMENT_SEPARATOR "'%$sep_color[$color]F$left_subsep'" - sub RIGHT_SUBSEGMENT_SEPARATOR "'%$sep_color[$color]F$right_subsep'" sub LEFT_SEGMENT_SEPARATOR "'$left_sep'" sub RIGHT_SEGMENT_SEPARATOR "'$right_sep'" sub LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL "'$left_tail'" sub LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL "'$left_head'" sub RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL "'$right_head'" sub RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL "'$right_tail'" - sub VCS_LOADING_FOREGROUND $sep_color[$color] - rep '%248F' "%$prefix_color[$color]F" fi if [[ -n $show_time ]]; then @@ -1364,14 +1379,19 @@ function generate_config() { uncomment 'typeset -g POWERLEVEL9K_CONTEXT_PREFIX' uncomment 'typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX' uncomment 'typeset -g POWERLEVEL9K_TIME_PREFIX' - [[ $style == classic ]] && local fg="%$prefix_color[$color]F" || local fg="%f" - sub VCS_PREFIX "'${fg}on '" - sub COMMAND_EXECUTION_TIME_PREFIX "'${fg}took '" - sub CONTEXT_PREFIX "'${fg}with '" - sub KUBECONTEXT_PREFIX "'${fg}at '" - sub TIME_PREFIX "'${fg}at '" - sub CONTEXT_TEMPLATE "'%n$fg at %180F%m'" - sub CONTEXT_ROOT_TEMPLATE "'%n$fg at %227F%m'" + if [[ $style == (lean|classic) ]]; then + [[ $style == classic ]] && local fg="%$prefix_color[$color]F" || local fg="%f" + sub VCS_PREFIX "'${fg}on '" + sub COMMAND_EXECUTION_TIME_PREFIX "'${fg}took '" + sub CONTEXT_PREFIX "'${fg}with '" + sub KUBECONTEXT_PREFIX "'${fg}at '" + sub TIME_PREFIX "'${fg}at '" + sub CONTEXT_TEMPLATE "'%n$fg at %180F%m'" + sub CONTEXT_ROOT_TEMPLATE "'%n$fg at %227F%m'" + else + sub CONTEXT_TEMPLATE "'%n at %m'" + sub CONTEXT_ROOT_TEMPLATE "'%n at %m'" + fi fi if (( num_lines == 1 )); then @@ -1385,7 +1405,7 @@ function generate_config() { sub MULTILINE_FIRST_PROMPT_GAP_CHAR "'$gap_char'" - if [[ $style == classic && $num_lines == 2 ]]; then + if [[ $style == (classic|rainbow) && $num_lines == 2 ]]; then if (( ! right_frame )); then sub MULTILINE_FIRST_PROMPT_SUFFIX '' sub MULTILINE_NEWLINE_PROMPT_SUFFIX '' @@ -1514,11 +1534,15 @@ while true; do fi (( cap_python )) && options[-1]+=' + python' if (( cap_diamond )); then + left_sep=$right_triangle + right_sep=$left_triangle left_subsep=$right_angle right_subsep=$left_angle left_head=$right_triangle right_head=$left_triangle else + left_sep= + right_sep= left_subsep=$vertical_bar right_subsep=$vertical_bar left_head=$fade_out @@ -1527,7 +1551,7 @@ while true; do _p9k_init_icons ask_narrow_icons || continue ask_style || continue - if [[ $style == (lean|classic) ]]; then + if [[ $style != pure ]]; then ask_color || continue ask_time || continue ask_separators || continue @@ -1536,6 +1560,7 @@ while true; do ask_num_lines || continue ask_gap_char || continue ask_frame || continue + ask_frame_color || continue ask_empty_line || continue ask_extra_icons || continue ask_prefixes || continue -- cgit v1.2.3 From 765de21920cc485f29fa457da21f35c8fed72fb1 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 11 Oct 2019 17:05:27 +0200 Subject: bug fix: wrong tail color for rainbow in the wizard --- internal/wizard.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 3d809256..03fb9473 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -96,7 +96,7 @@ typeset -ra rainbow_left=( ) typeset -ra rainbow_right=( - '%3F$right_head%K{3} %0F$prefixes[2]5s $extra_icons[4]%1F${show_time:+%7F$right_sep%K{7\} %0F$prefixes[3]16:23:42 $extra_icons[5]%7F}%k$right_tail%f' '%$frame_color[$color]F─╮%f' + '%3F$right_head%K{3} %0F$prefixes[2]5s $extra_icons[4]%3F${show_time:+%7F$right_sep%K{7\} %0F$prefixes[3]16:23:42 $extra_icons[5]%7F}%k$right_tail%f' '%$frame_color[$color]F─╮%f' '' '%$frame_color[$color]F─╯%f' ) -- cgit v1.2.3 From d7b79a39d52a3ab45fde79f794708698a510d581 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 11 Oct 2019 17:39:57 +0200 Subject: bug fix: set correct gitstatusd path on android --- internal/p10k.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/p10k.zsh b/internal/p10k.zsh index 67316cc3..144f1a33 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -4458,7 +4458,7 @@ _p9k_must_init() { '${ZSH_VERSION}' '${ZSH_PATCHLEVEL}' '${(%):-%n}' '${GITSTATUS_LOG_LEVEL}' '${GITSTATUS_ENABLE_LOGGING}' '${GITSTATUS_DAEMON}' '${GITSTATUS_NUM_THREADS}' '${DEFAULT_USER}' '${ZLE_RPROMPT_INDENT}' '${P9K_SSH}' '${__p9k_ksh_arrays}' - '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v7') + '${__p9k_sh_glob}' '${parameters[transient_rprompt]}' 'v8') IFS=$'\2' param_sig="${(e)param_sig}" [[ $param_sig == $_p9k_param_sig ]] && return 1 [[ -n $_p9k_param_sig ]] && _p9k_deinit @@ -4665,7 +4665,7 @@ _p9k_init_vcs() { local daemon=${GITSTATUS_DAEMON} if [[ -z $daemon ]]; then daemon=$gitstatus_dir/bin/gitstatusd- - [[ _p9k_uname_o == Android ]] && daemon+=android || daemon+=${_p9k_uname:l} + [[ $_p9k_uname_o == Android ]] && daemon+=android || daemon+=${_p9k_uname:l} daemon+=-${_p9k_uname_m:l} fi local -i threads=${GITSTATUS_NUM_THREADS:-0} -- cgit v1.2.3 From dcc4fbce22ec99ba68c50bff8f778a00b97e71ea Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 11 Oct 2019 17:40:37 +0200 Subject: pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 66 +++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index 783e7e2b..6e603ae3 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -91,38 +91,37 @@ typeset -g _gitstatus_plugin_dir=${${(%):-%x}:A:h} # # If VCS_STATUS_RESULT is ok-sync or ok-async, additional variables are set: # -# VCS_STATUS_WORKDIR Git repo working directory. Not empty. -# VCS_STATUS_COMMIT Commit hash that HEAD is pointing to. Either 40 hex digits or empty -# if there is no HEAD (empty repo). -# VCS_STATUS_LOCAL_BRANCH Local branch name or empty if not on a branch. -# VCS_STATUS_REMOTE_NAME The remote name, e.g. "upstream" or "origin". -# VCS_STATUS_REMOTE_BRANCH Upstream branch name. Can be empty. -# VCS_STATUS_REMOTE_URL Remote URL. Can be empty. -# VCS_STATUS_ACTION Repository state, A.K.A. action. Can be empty. -# VCS_STATUS_INDEX_SIZE The number of files in the index. -# VCS_STATUS_NUM_STAGED The number of staged changes. -# VCS_STATUS_NUM_CONFLICTED The number of unstaged changes. -# VCS_STATUS_NUM_UNSTAGED The number of unstaged changes. -# VCS_STATUS_NUM_UNTRACKED The number of untracked files. -# VCS_STATUS_HAS_STAGED 1 if there are staged changes, 0 otherwise. -# VCS_STATUS_HAS_CONFLICTED 1 if there are conflicted changes, 0 otherwise. -# VCS_STATUS_HAS_UNSTAGED 1 if there are unstaged changes, 0 if there aren't, -1 if unknown. -# VCS_STATUS_HAS_UNTRACKED 1 if there are untracked files, 0 if there aren't, -1 if unknown. -# VCS_STATUS_COMMITS_AHEAD Number of commits the current branch is ahead of upstream. -# Non-negative integer. -# VCS_STATUS_COMMITS_BEHIND Number of commits the current branch is behind upstream. Non-negative -# integer. -# VCS_STATUS_STASHES Number of stashes. Non-negative integer. -# VCS_STATUS_TAG The last tag (in lexicographical order) that points to the same -# commit as HEAD. -# -# Experimental variables. May disappear or have their semantics changed without notice: -# +# VCS_STATUS_WORKDIR Git repo working directory. Not empty. +# VCS_STATUS_COMMIT Commit hash that HEAD is pointing to. Either 40 hex digits or +# empty if there is no HEAD (empty repo). +# VCS_STATUS_LOCAL_BRANCH Local branch name or empty if not on a branch. +# VCS_STATUS_REMOTE_NAME The remote name, e.g. "upstream" or "origin". +# VCS_STATUS_REMOTE_BRANCH Upstream branch name. Can be empty. +# VCS_STATUS_REMOTE_URL Remote URL. Can be empty. +# VCS_STATUS_ACTION Repository state, A.K.A. action. Can be empty. +# VCS_STATUS_INDEX_SIZE The number of files in the index. +# VCS_STATUS_NUM_STAGED The number of staged changes. +# VCS_STATUS_NUM_CONFLICTED The number of conflicted changes. +# VCS_STATUS_NUM_UNSTAGED The number of unstaged changes. +# VCS_STATUS_NUM_UNTRACKED The number of untracked files. +# VCS_STATUS_HAS_STAGED 1 if there are staged changes, 0 otherwise. +# VCS_STATUS_HAS_CONFLICTED 1 if there are conflicted changes, 0 otherwise. +# VCS_STATUS_HAS_UNSTAGED 1 if there are unstaged changes, 0 if there aren't, -1 if +# unknown. # VCS_STATUS_NUM_UNSTAGED_DELETED The number of unstaged deleted files. Note that renamed files # are reported as deleted plus added. -# -# The point of reporting -1 as unstaged and untracked is to allow the command to skip scanning -# files in large repos. See -m flag of gitstatus_start. +# VCS_STATUS_HAS_UNTRACKED 1 if there are untracked files, 0 if there aren't, -1 if +# unknown. +# VCS_STATUS_COMMITS_AHEAD Number of commits the current branch is ahead of upstream. +# Non-negative integer. +# VCS_STATUS_COMMITS_BEHIND Number of commits the current branch is behind upstream. +# Non-negative integer. +# VCS_STATUS_STASHES Number of stashes. Non-negative integer. +# VCS_STATUS_TAG The last tag (in lexicographical order) that points to the same +# commit as HEAD. +# +# The point of reporting -1 via VCS_STATUS_HAS_* is to allow the command to skip scanning files in +# large repos. See -m flag of gitstatus_start. # # gitstatus_query returns an error if gitstatus_start hasn't been called in the same shell or # the call had failed. @@ -468,6 +467,13 @@ function gitstatus_start() { rm -f $lock_file $req_fifo $resp_fifo unset -f gitstatus_start_impl + unset GITSTATUS_DAEMON_PID_${name} + unset _GITSTATUS_REQ_FD_${name} + unset _GITSTATUS_RESP_FD_${name} + unset _GITSTATUS_LOCK_FD_${name} + unset _GITSTATUS_CLIENT_PID_${name} + unset _GITSTATUS_DIRTY_MAX_INDEX_SIZE_${name} + >&2 print -P '[%F{red}ERROR%f]: gitstatus failed to initialize.' >&2 echo -E '' >&2 echo -E ' Your git prompt may disappear or become slow.' -- cgit v1.2.3 From 0302e68913458a2d961b2dcdd0dfc670f308fe29 Mon Sep 17 00:00:00 2001 From: romkatv Date: Fri, 11 Oct 2019 19:00:47 +0200 Subject: change dir foreground from black to white in rainbow style; looks a bit less ugly --- config/p10k-rainbow.zsh | 12 ++++++------ internal/wizard.zsh | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/config/p10k-rainbow.zsh b/config/p10k-rainbow.zsh index 35c7e91d..49f6ffba 100644 --- a/config/p10k-rainbow.zsh +++ b/config/p10k-rainbow.zsh @@ -218,17 +218,17 @@ # Current directory background color. # typeset -g POWERLEVEL9K_DIR_BACKGROUND=4 # Default current directory foreground color. - typeset -g POWERLEVEL9K_DIR_FOREGROUND=0 + typeset -g POWERLEVEL9K_DIR_FOREGROUND=254 # If directory is too long, shorten some of its segments to the shortest possible unique # prefix. The shortened directory can be tab-completed to the original. typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique # Replace removed segment suffixes with this symbol. typeset -g POWERLEVEL9K_SHORTEN_DELIMITER= # Color of the shortened directory segments. - typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=8 + typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=250 # Color of the anchor directory segments. Anchor segments are never shortened. The first # segment is always an anchor. - typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=0 + typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=255 # Display anchor directory segments in bold. typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true # Don't shorten directories that contain any of these files. They are anchors. @@ -309,9 +309,9 @@ # to have its own color. # # typeset -g POWERLEVEL9K_DIR_WORK_BACKGROUND=4 - # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=0 - # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=8 - # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=0 + # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=254 + # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=250 + # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=255 # # typeset -g POWERLEVEL9K_DIR_CLASSES=() diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 03fb9473..9ea8abcf 100755 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -91,7 +91,7 @@ typeset -ra pure_right=( ) typeset -ra rainbow_left=( - '%$frame_color[$color]F╭─' '%F{${${extra_icons[1]:+0}:-4}}$left_tail${extra_icons[1]:+%K{0\} $extra_icons[1] %K{4\}%0F$left_sep}%K{4}%0F $extra_icons[2]%B~%b%K{4}%0F/%Bsrc%b%K{4} %K{2}%4F$left_sep %0F$prefixes[1]$extra_icons[3]master %k%2F$left_head%f' + '%$frame_color[$color]F╭─' '%F{${${extra_icons[1]:+0}:-4}}$left_tail${extra_icons[1]:+%K{0\} $extra_icons[1] %K{4\}%0F$left_sep}%K{4}%254F $extra_icons[2]%B%255F~%b%K{4}%254F/%B%255Fsrc%b%K{4} %K{2}%4F$left_sep %0F$prefixes[1]$extra_icons[3]master %k%2F$left_head%f' '%$frame_color[$color]F╰─' '%f █' ) -- cgit v1.2.3