diff options
-rw-r--r-- | README.md | 25 | ||||
-rw-r--r-- | config/p10k-classic.zsh | 39 | ||||
-rw-r--r-- | config/p10k-lean-8colors.zsh | 34 | ||||
-rw-r--r-- | config/p10k-lean.zsh | 34 | ||||
-rw-r--r-- | config/p10k-rainbow.zsh | 38 | ||||
-rw-r--r-- | config/p10k-robbyrussell.zsh | 106 | ||||
-rwxr-xr-x | gitstatus/bin/gitstatusd-linux-x86_64 | bin | 2372840 -> 2372840 bytes | |||
-rw-r--r-- | internal/icons.zsh | 5 | ||||
-rw-r--r-- | internal/notes.txt | 9 | ||||
-rw-r--r-- | internal/p10k.zsh | 135 | ||||
-rw-r--r-- | internal/worker.zsh | 17 | ||||
-rw-r--r-- | powerlevel10k.zsh-theme | 1 |
12 files changed, 392 insertions, 51 deletions
@@ -279,10 +279,13 @@ enable as many segments as you like. It won't slow down your prompt or Zsh start | `luaenv` | lua environment from [luaenv](https://github.com/cehoffman/luaenv) | | `jenv` | java environment from [jenv](https://github.com/jenv/jenv) | | `plenv` | perl environment from [plenv](https://github.com/tokuhirom/plenv) | +| `phpenv` | php environment from [phpenv](https://github.com/phpenv/phpenv) | | `node_version` | [node.js](https://nodejs.org/) version | | `go_version` | [go](https://golang.org) version | | `rust_version` | [rustc](https://www.rust-lang.org) version | | `dotnet_version` | [dotnet](https://dotnet.microsoft.com) version | +| `php_version` | [php](https://www.php.net/) version | +| `laravel_version` | [laravel php framework](https://laravel.com/) version | | `kubecontext` | current [kubernetes](https://kubernetes.io/) context | | `terraform` | [terraform](https://www.terraform.io) workspace | | `aws` | [aws profile](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) | @@ -943,13 +946,26 @@ and replace mode respectively. When a command fails, the symbol turns red. *Lean `prompt_char` in it. *Rainbow* and *Classic* styles have it only in the two-line configuration without left frame. -If you value horizontal space or prefer minimalist aesthetics, disable *current time* and use *few -icons*. The extra icons enabled by the *many icons* option primarily serve decorative function. -Informative icons, such as background job indicator, will be shown either way. +If you value horizontal space or prefer minimalist aesthetics: + +- Use a monospace font, such as [the recommended font](#meslo-nerd-font-patched-for-powerlevel10k). + Non-monospace fonts require extra space after icons that are larger than a single column. +- Use Lean style. Compared to Classic and Rainbow, it saves two characters per prompt segment. +- Disable *current time* and *frame*. +- Use *few icons*. The extra icons enabled by the *many icons* option primarily serve decorative + function. Informative icons, such as background job indicator, will be shown either way. *Note*: You can run configuration wizard as many times as you like. Type `p10k configure` to try new prompt style. +### How to make Powerlevel10k look like robbyrussell Oh My Zsh theme? + +Use [this config]( + https://github.com/romkatv/powerlevel10k/blob/master/config/p10k-robbyrussell.zsh). + +You can either download it, save as `~/.p10k.zsh` and `source ~/.p10k.zsh` from `~/.zshrc`, or +source `p10k-robbyrussell.zsh` directly from your cloned `powerlevel10k` repository. + ### Can prompts for completed commands display error status for *those* commands instead of the commands preceding them? No. When you hit *ENTER* and the command you've typed starts running, its error status isn't yet @@ -1233,7 +1249,7 @@ It's almost always a bad idea to run `source ~/.zshrc`, whether you are using Po This command may result in random errors, misbehaving code and progressive slowdown of Zsh. If you've made changes to `~/.zshrc` or to files sourced by it, restart Zsh to apply them. The most -reliable way to do this is to type `exit` and then start start a new Zsh session. You can also use +reliable way to do this is to type `exit` and then start a new Zsh session. You can also use `exec zsh`. While not exactly equivalent to complete Zsh restart, this command is much more reliable than `source ~/.zshrc`. @@ -1469,6 +1485,7 @@ There are a few mitigation options for this issue. - [What is the relationship between Powerlevel9k and Powerlevel10k?](#what-is-the-relationship-between-powerlevel9k-and-powerlevel10k) - [Does Powerlevel10k always render exactly the same prompt as Powerlevel9k given the same config?](#does-powerlevel10k-always-render-exactly-the-same-prompt-as-powerlevel9k-given-the-same-config) - [What is the best prompt style in the configuration wizard?](#what-is-the-best-prompt-style-in-the-configuration-wizard) + - [How to make Powerlevel10k look like robbyrussell Oh My Zsh theme?](#how-to-make-powerlevel10k-look-like-robbyrussell-oh-my-zsh-theme) - [Can prompts for completed commands display error status for *those* commands instead of the commands preceding them?](#can-prompts-for-completed-commands-display-error-status-for-those-commands-instead-of-the-commands-preceding-them) - [Is there an AUR package for Powerlevel10k?](#is-there-an-aur-package-for-powerlevel10k) - [What is the minimum supported Zsh version?](#what-is-the-minimum-supported-zsh-version) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index 11ac1a72..b374a626 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -60,12 +60,15 @@ # go_version # go version (https://golang.org) # rust_version # rustc version (https://www.rust-lang.org) # dotnet_version # .NET version (https://dotnet.microsoft.com) + # php_version # php version (https://www.php.net/) + # laravel_version # laravel php framework version (https://laravel.com/) rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rvm # ruby version from rvm (https://rvm.io) fvm # flutter version management (https://github.com/leoafarias/fvm) luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv) jenv # java version from jenv (https://github.com/jenv/jenv) plenv # perl version from plenv (https://github.com/tokuhirom/plenv) + phpenv # php version from phpenv (https://github.com/phpenv/phpenv) 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) @@ -260,7 +263,13 @@ .hg .node-version .python-version + .go-version .ruby-version + .lua-version + .java-version + .perl-version + .php-version + .tool-version .shorten_folder_marker .svn .terraform @@ -673,6 +682,11 @@ # typeset -g POWERLEVEL9K_ASDF_POSTGRES_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_ASDF_POSTGRES_SHOW_ON_UPGLOB='*.foo|*.bar' + # PHP version from asdf. + typeset -g POWERLEVEL9K_ASDF_PHP_FOREGROUND=99 + # typeset -g POWERLEVEL9K_ASDF_PHP_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PHP_SHOW_ON_UPGLOB='*.foo|*.bar' + ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### # NordVPN connection indicator color. typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=39 @@ -928,6 +942,20 @@ # Custom icon. # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + #####################[ php_version: php version (https://www.php.net/) ]###################### + # PHP version color. + typeset -g POWERLEVEL9K_PHP_VERSION_FOREGROUND=99 + # Show PHP version only when in a PHP project subdirectory. + typeset -g POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_PHP_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ laravel_version: laravel php framework version (https://laravel.com/) ]########### + # Laravel version color. + typeset -g POWERLEVEL9K_LARAVEL_VERSION_FOREGROUND=161 + # Custom icon. + # typeset -g POWERLEVEL9K_LARAVEL_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## # Rbenv color. typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 @@ -988,6 +1016,17 @@ # Custom icon. # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ + # PHP color. + typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=99 + # Hide php version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global) + # If set to false, hide php version if it's the same as global: + # $(phpenv version-name) == $(phpenv global). + typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false + # Custom icon. + # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + ################[ terraform: terraform workspace (https://www.terraform.io) ]################# # POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element # in each pair defines a pattern against which the current terraform workspace gets matched. diff --git a/config/p10k-lean-8colors.zsh b/config/p10k-lean-8colors.zsh index a4e4e158..0484913c 100644 --- a/config/p10k-lean-8colors.zsh +++ b/config/p10k-lean-8colors.zsh @@ -60,12 +60,15 @@ # go_version # go version (https://golang.org) # rust_version # rustc version (https://www.rust-lang.org) # dotnet_version # .NET version (https://dotnet.microsoft.com) + # php_version # php version (https://www.php.net/) + # laravel_version # laravel php framework version (https://laravel.com/) rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rvm # ruby version from rvm (https://rvm.io) fvm # flutter version management (https://github.com/leoafarias/fvm) luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv) jenv # java version from jenv (https://github.com/jenv/jenv) plenv # perl version from plenv (https://github.com/tokuhirom/plenv) + phpenv # php version from phpenv (https://github.com/phpenv/phpenv) 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) @@ -261,6 +264,7 @@ .lua-version .java-version .perl-version + .php-version .tool-version .shorten_folder_marker .svn @@ -674,6 +678,11 @@ # typeset -g POWERLEVEL9K_ASDF_POSTGRES_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_ASDF_POSTGRES_SHOW_ON_UPGLOB='*.foo|*.bar' + # PHP version from asdf. + typeset -g POWERLEVEL9K_ASDF_PHP_FOREGROUND=5 + # typeset -g POWERLEVEL9K_ASDF_PHP_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PHP_SHOW_ON_UPGLOB='*.foo|*.bar' + ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### # NordVPN connection indicator color. typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=6 @@ -912,6 +921,20 @@ # Custom icon. # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + #####################[ php_version: php version (https://www.php.net/) ]###################### + # PHP version color. + typeset -g POWERLEVEL9K_PHP_VERSION_FOREGROUND=5 + # Show PHP version only when in a PHP project subdirectory. + typeset -g POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_PHP_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ laravel_version: laravel php framework version (https://laravel.com/) ]########### + # Laravel version color. + typeset -g POWERLEVEL9K_LARAVEL_VERSION_FOREGROUND=1 + # Custom icon. + # typeset -g POWERLEVEL9K_LARAVEL_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## # Rbenv color. typeset -g POWERLEVEL9K_RBENV_FOREGROUND=1 @@ -972,6 +995,17 @@ # Custom icon. # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ + # PHP color. + typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=5 + # Hide php version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global) + # If set to false, hide php version if it's the same as global: + # $(phpenv version-name) == $(phpenv global). + typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false + # Custom icon. + # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# # Show kubecontext only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show kubecontext. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 7cbf0bef..ce206f7f 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -60,12 +60,15 @@ # go_version # go version (https://golang.org) # rust_version # rustc version (https://www.rust-lang.org) # dotnet_version # .NET version (https://dotnet.microsoft.com) + # php_version # php version (https://www.php.net/) + # laravel_version # laravel php framework version (https://laravel.com/) rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rvm # ruby version from rvm (https://rvm.io) fvm # flutter version management (https://github.com/leoafarias/fvm) luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv) jenv # java version from jenv (https://github.com/jenv/jenv) plenv # perl version from plenv (https://github.com/tokuhirom/plenv) + phpenv # php version from phpenv (https://github.com/phpenv/phpenv) 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) @@ -261,6 +264,7 @@ .lua-version .java-version .perl-version + .php-version .tool-version .shorten_folder_marker .svn @@ -674,6 +678,11 @@ # typeset -g POWERLEVEL9K_ASDF_POSTGRES_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_ASDF_POSTGRES_SHOW_ON_UPGLOB='*.foo|*.bar' + # PHP version from asdf. + typeset -g POWERLEVEL9K_ASDF_PHP_FOREGROUND=99 + # typeset -g POWERLEVEL9K_ASDF_PHP_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PHP_SHOW_ON_UPGLOB='*.foo|*.bar' + ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### # NordVPN connection indicator color. typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=39 @@ -912,6 +921,20 @@ # Custom icon. # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + #####################[ php_version: php version (https://www.php.net/) ]###################### + # PHP version color. + typeset -g POWERLEVEL9K_PHP_VERSION_FOREGROUND=99 + # Show PHP version only when in a PHP project subdirectory. + typeset -g POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_PHP_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ laravel_version: laravel php framework version (https://laravel.com/) ]########### + # Laravel version color. + typeset -g POWERLEVEL9K_LARAVEL_VERSION_FOREGROUND=161 + # Custom icon. + # typeset -g POWERLEVEL9K_LARAVEL_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## # Rbenv color. typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168 @@ -972,6 +995,17 @@ # Custom icon. # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ + # PHP color. + typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=99 + # Hide php version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global) + # If set to false, hide php version if it's the same as global: + # $(phpenv version-name) == $(phpenv global). + typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false + # Custom icon. + # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# # Show kubecontext only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show kubecontext. diff --git a/config/p10k-rainbow.zsh b/config/p10k-rainbow.zsh index acd21d21..9b9acfb9 100644 --- a/config/p10k-rainbow.zsh +++ b/config/p10k-rainbow.zsh @@ -60,12 +60,15 @@ # go_version # go version (https://golang.org) # rust_version # rustc version (https://www.rust-lang.org) # dotnet_version # .NET version (https://dotnet.microsoft.com) + # php_version # php version (https://www.php.net/) + # laravel_version # laravel php framework version (https://laravel.com/) rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv) rvm # ruby version from rvm (https://rvm.io) fvm # flutter version management (https://github.com/leoafarias/fvm) luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv) jenv # java version from jenv (https://github.com/jenv/jenv) plenv # perl version from plenv (https://github.com/tokuhirom/plenv) + phpenv # php version from phpenv (https://github.com/phpenv/phpenv) 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) @@ -265,6 +268,7 @@ .lua-version .java-version .perl-version + .php-version .tool-version .shorten_folder_marker .svn @@ -689,6 +693,12 @@ # typeset -g POWERLEVEL9K_ASDF_POSTGRES_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_ASDF_POSTGRES_SHOW_ON_UPGLOB='*.foo|*.bar' + # PHP version from asdf. + typeset -g POWERLEVEL9K_ASDF_PHP_FOREGROUND=0 + typeset -g POWERLEVEL9K_ASDF_PHP_BACKGROUND=5 + # typeset -g POWERLEVEL9K_ASDF_PHP_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_ASDF_PHP_SHOW_ON_UPGLOB='*.foo|*.bar' + ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]########### # NordVPN connection indicator color. # typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=7 @@ -974,6 +984,22 @@ # Custom icon. # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + #####################[ php_version: php version (https://www.php.net/) ]###################### + # PHP version color. + typeset -g POWERLEVEL9K_PHP_VERSION_FOREGROUND=0 + typeset -g POWERLEVEL9K_PHP_VERSION_BACKGROUND=5 + # Show PHP version only when in a PHP project subdirectory. + typeset -g POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY=true + # Custom icon. + # typeset -g POWERLEVEL9K_PHP_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + + ##########[ laravel_version: laravel php framework version (https://laravel.com/) ]########### + # Laravel version color. + typeset -g POWERLEVEL9K_LARAVEL_VERSION_FOREGROUND=1 + typeset -g POWERLEVEL9K_LARAVEL_VERSION_BACKGROUND=7 + # Custom icon. + # typeset -g POWERLEVEL9K_LARAVEL_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' + #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]############## # Rbenv color. # typeset -g POWERLEVEL9K_RBENV_FOREGROUND=0 @@ -1040,6 +1066,18 @@ # Custom icon. # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ + # PHP color. + # typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=0 + # typeset -g POWERLEVEL9K_PHPENV_BACKGROUND=5 + # Hide php version if it doesn't come from one of these sources. + typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global) + # If set to false, hide php version if it's the same as global: + # $(phpenv version-name) == $(phpenv global). + typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false + # Custom icon. + # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' + ################[ terraform: terraform workspace (https://www.terraform.io) ]################# # POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element # in each pair defines a pattern against which the current terraform workspace gets matched. diff --git a/config/p10k-robbyrussell.zsh b/config/p10k-robbyrussell.zsh new file mode 100644 index 00000000..ec880fea --- /dev/null +++ b/config/p10k-robbyrussell.zsh @@ -0,0 +1,106 @@ +# Config file for Powerlevel10k with the style of robbyrussell theme from Oh My Zsh. +# +# Original: https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#robbyrussell. +# +# Replication of robbyrussell theme is exact. The only observable difference is in +# performance. Powerlevel10k prompt is very fast everywhere, even in large Git repositories. +# +# Usage: Source this file either before or after loading Powerlevel10k. +# +# source ~/powerlevel10k/config/p10k-robbyrussell.zsh +# source ~/powerlevel10k/powerlevel10k.zsh-theme + +# 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 + + autoload -Uz is-at-least && is-at-least 5.1 || return + + # Unset all configuration options. + unset -m 'POWERLEVEL9K_*' + + # Left prompt segments. + typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(prompt_char dir vcs) + # Right prompt segments. + typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=() + + # 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= # no segment icons + + # Green prompt symbol if the last command succeeded. + typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS}_FOREGROUND=green + # Red prompt symbol if the last command failed. + typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS}_FOREGROUND=red + # Prompt symbol: bold arrow. + typeset -g POWERLEVEL9K_PROMPT_CHAR_CONTENT_EXPANSION='%B➜ ' + + # Cyan current directory. + typeset -g POWERLEVEL9K_DIR_FOREGROUND=cyan + # Show only the last segment of the current directory. + typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_last + # Bold directory. + typeset -g POWERLEVEL9K_DIR_CONTENT_EXPANSION='%B$P9K_CONTENT' + + # Git status formatter. + function my_git_formatter() { + emulate -L zsh + if [[ -n $P9K_CONTENT ]]; then + # If P9K_CONTENT is not empty, 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 + else + # Use VCS_STATUS_* parameters to assemble Git status. See reference: + # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh. + typeset -g my_git_format='%B%F{blue}git:(%F{red}' + my_git_format+=${${VCS_STATUS_LOCAL_BRANCH:-${VCS_STATUS_COMMIT[1,8]}}//\%/%%} + my_git_format+='%F{blue})' + if (( VCS_STATUS_NUM_CONFLICTED || VCS_STATUS_NUM_STAGED || + VCS_STATUS_NUM_UNSTAGED || VCS_STATUS_NUM_UNTRACKED )); then + my_git_format+=' %F{yellow}✗' + fi + fi + } + 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()))+${my_git_format}}' + # Disable loading indicator. + typeset -g POWERLEVEL9K_VCS_LOADING_TEXT='%{%}' + + # Instant prompt mode. + # + # - off: Disable instant prompt. Choose this if you've tried instant prompt and found + # it incompatible with your zsh configuration files. + # - quiet: Enable instant prompt and don't print warnings when detecting console output + # during zsh initialization. Choose this if you've read and understood + # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. + # - verbose: Enable instant prompt and print a warning when detecting console output during + # zsh initialization. Choose this if you've never tried instant prompt, haven't + # seen the warning, or if you are unsure what this all means. + typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose + + # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized. + # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload + # can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you + # really need it. + typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true + + # If p10k is already loaded, reload configuration. + # This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true. + (( ! $+functions[p10k] )) || p10k reload +} + +(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]} +'builtin' 'unset' 'p10k_config_opts' diff --git a/gitstatus/bin/gitstatusd-linux-x86_64 b/gitstatus/bin/gitstatusd-linux-x86_64 Binary files differindex d09b194c..52aab1ec 100755 --- a/gitstatus/bin/gitstatusd-linux-x86_64 +++ b/gitstatus/bin/gitstatusd-linux-x86_64 diff --git a/internal/icons.zsh b/internal/icons.zsh index 725da7d0..21d421b1 100644 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -133,6 +133,7 @@ function _p9k_init_icons() { ERLANG_ICON 'erl' ELIXIR_ICON 'elixir' POSTGRES_ICON 'postgres' + PHP_ICON 'php' ) ;; 'awesome-fontconfig') @@ -251,6 +252,7 @@ function _p9k_init_icons() { ERLANG_ICON 'erl' ELIXIR_ICON 'elixir' POSTGRES_ICON 'postgres' + PHP_ICON 'php' ) ;; 'awesome-mapped-fontconfig') @@ -373,6 +375,7 @@ function _p9k_init_icons() { ERLANG_ICON 'erl' ELIXIR_ICON 'elixir' POSTGRES_ICON 'postgres' + PHP_ICON 'php' ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -492,6 +495,7 @@ function _p9k_init_icons() { ERLANG_ICON '\uE7B1 ' # ELIXIR_ICON '\uE62D' # POSTGRES_ICON '\uE76E' # + PHP_ICON '\uE608' # ) ;; *) @@ -610,6 +614,7 @@ function _p9k_init_icons() { ERLANG_ICON 'erl' ELIXIR_ICON 'elixir' POSTGRES_ICON 'postgres' + PHP_ICON 'php' ) ;; esac diff --git a/internal/notes.txt b/internal/notes.txt index a873eb83..de86abc6 100644 --- a/internal/notes.txt +++ b/internal/notes.txt @@ -17,3 +17,12 @@ replacing the chopped off part with `…`. e.g., `…/x/anchor/y/anchor`. the shortest dir representation is thus `…/last` or `…/last` depending on whether the last segment is an anchor. the replacement parameter's value is `…/` (with a slash) to allow for `x/anchor/y/anchor`. +- add to faq: how do i display an environment variable in prompt? link it from "extensible" +- add to faq: how do i display an icon in prompt? link it from "extensible" +- add root_indicator to config templates +- test chruby and add it to config templates +- add ssh to config templates +- add swift version to config templates; see if there is a good pattern for PROJECT_ONLY +- add swiftenv +- add faq: how to make directory shorter? mention POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER, + POWERLEVEL9K_DIR_MAX_LENGTH and truncate_to_last. diff --git a/internal/p10k.zsh b/internal/p10k.zsh index ccd75625..b51eea47 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -1766,8 +1766,10 @@ prompt_dir() { fi ;; truncate_to_last) - fake_first=$(($#parts > 1)) - parts[1,-2]=() + if [[ $#parts -gt 2 || $p[1] != / && $#parts -gt 1 ]]; then + fake_first=1 + parts[1,-2]=() + fi ;; truncate_to_first_and_last) if (( shortenlen > 0 )); then @@ -2100,12 +2102,16 @@ prompt_vpn_ip() { ################################################################ # Segment to display laravel version prompt_laravel_version() { - local laravel_version="$(php artisan --version 2> /dev/null)" - if [[ -n "${laravel_version}" && "${laravel_version}" =~ "Laravel Framework" ]]; then - # Strip out everything but the version - laravel_version="${laravel_version//Laravel Framework /}" - _p9k_prompt_segment "$0" "maroon" "white" 'LARAVEL_ICON' 0 '' "${laravel_version//\%/%%}" + _p9k_upglob artisan && return + local dir=$_p9k__parent_dirs[$?] + local app=$dir/vendor/laravel/framework/src/Illuminate/Foundation/Application.php + [[ -r $app ]] || return + if ! _p9k_cache_stat_get $0 $dir/artisan $app; then + local v="$(php $dir/artisan --version 2> /dev/null)" + _p9k_cache_stat_set "${${(M)v:#Laravel Framework *}#Laravel Framework }" fi + [[ -n $_p9k__cache_val[1] ]] || return + _p9k_prompt_segment "$0" "maroon" "white" 'LARAVEL_ICON' 0 '' "${_p9k__cache_val[1]//\%/%%}" } _p9k_prompt_laravel_version_init() { @@ -2425,10 +2431,13 @@ instant_prompt_os_icon() { prompt_os_icon; } ################################################################ # Segment to display PHP version number prompt_php_version() { + if (( _POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY )); then + _p9k_upglob 'composer.json|*.php' && return + fi _p9k_cached_cmd_stdout php --version || return - [[ $_p9k__ret == (#b)(*$'\n')#(PHP [[:digit:].]##)* ]] || return + [[ $_p9k__ret == (#b)(*$'\n')#'PHP '([[:digit:].]##)* ]] || return local v=$match[2] - _p9k_prompt_segment "$0" "fuchsia" "grey93" '' 0 '' "${v//\%/%%}" + _p9k_prompt_segment "$0" "fuchsia" "grey93" 'PHP_ICON' 0 '' "${v//\%/%%}" } _p9k_prompt_php_version_init() { @@ -2548,6 +2557,56 @@ _p9k_prompt_rbenv_init() { typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[rbenv]:-${${+functions[rbenv]}:#0}}' } +function _p9k_phpenv_global_version() { + _p9k_read_word ${PHPENV_ROOT:-$HOME/.phpenv}/version || _p9k__ret=system +} + +prompt_phpenv() { + if [[ -n $PHPENV_VERSION ]]; then + (( ${_POWERLEVEL9K_PHPENV_SOURCES[(I)shell]} )) || return + local v=$PHPENV_VERSION + else + (( ${_POWERLEVEL9K_PHPENV_SOURCES[(I)local|global]} )) || return + if [[ $PHPENV_DIR == (|.) ]]; then + _p9k_upglob .php-version + local -i idx=$? + if (( idx )) && _p9k_read_word $_p9k__parent_dirs[idx]/.php-version; then + (( ${_POWERLEVEL9K_PHPENV_SOURCES[(I)local]} )) || return + else + _p9k__ret= + fi + else + _p9k__ret= + [[ $PHPENV_DIR == /* ]] && local dir=$PHPENV_DIR || local dir="$_p9k__cwd_a/$PHPENV_DIR" + while true; do + if _p9k_read_word $dir/.php-version; then + (( ${_POWERLEVEL9K_PHPENV_SOURCES[(I)local]} )) || return + break + fi + [[ $dir == / ]] && break + dir=${dir:h} + done + fi + if [[ -z $_p9k__ret ]]; then + (( _POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW )) || return + (( ${_POWERLEVEL9K_PHPENV_SOURCES[(I)global]} )) || return + _p9k_phpenv_global_version + fi + local v=$_p9k__ret + fi + + if (( !_POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW )); then + _p9k_phpenv_global_version + [[ $v == $_p9k__ret ]] && return + fi + + _p9k_prompt_segment "$0" "magenta" "$_p9k_color1" 'PHP_ICON' 0 '' "${v//\%/%%}" +} + +_p9k_prompt_phpenv_init() { + typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[phpenv]:-${${+functions[phpenv]}:#0}}' +} + function _p9k_luaenv_global_version() { _p9k_read_word ${LUAENV_ROOT:-$HOME/.luaenv}/version || _p9k__ret=system } @@ -5565,7 +5624,7 @@ function _p9k_clear_instant_prompt() { print -rn -- $terminfo[rc]${(%):-%b%k%f%s%u}$terminfo[ed] fi prompt_opts=(percent subst sp cr) - if [[ $_POWERLEVEL9K_DISABLE_INSTANT_PROMPT == 0 && -o prompt_cr ]]; then + if [[ $_POWERLEVEL9K_DISABLE_INSTANT_PROMPT == 0 && $__p9k_instant_prompt_active == 2 ]]; then >&2 echo -E - "" >&2 echo -E - "${(%):-[%1FERROR%f]: When using Powerlevel10k with instant prompt, %Bprompt_cr%b must be unset.}" >&2 echo -E - "" @@ -5646,16 +5705,12 @@ function _p9k_maybe_dump() { } function _p9k_on_expand() { - (( _p9k__expanded && ! $+__p9k_instant_prompt_active )) && return + (( _p9k__expanded && ! ${+__p9k_instant_prompt_active} )) && return - () { - eval "$__p9k_intro" + eval "$__p9k_intro" + if (( ! _p9k__expanded )); then _p9k_maybe_dump - (( $+__p9k_instant_prompt_active )) && _p9k_clear_instant_prompt - - (( _p9k__expanded )) && return - _p9k__expanded=1 if (( ! $+P9K_TTY )); then typeset -gx P9K_TTY=old @@ -5698,15 +5753,24 @@ function _p9k_on_expand() { fi fi - if [[ -z $_p9k__last_tty ]]; then - _p9k_wrap_widgets - (( $+functions[p10k-on-init] )) && p10k-on-init - fi + [[ -z $_p9k__last_tty ]] && _p9k_wrap_widgets + fi + + if (( $+__p9k_instant_prompt_active )); then + _p9k_clear_instant_prompt + unset __p9k_instant_prompt_active + fi + + if (( ! _p9k__expanded )); then + _p9k__expanded=1 + + [[ -z $_p9k__last_tty && $+functions[p10k-on-init] == 1 ]] && p10k-on-init local pat idx var for pat idx var in $_p9k_show_on_command; do _p9k_display_segment $idx $var hide done + (( $+functions[p10k-on-pre-prompt] )) && p10k-on-pre-prompt __p9k_reset_state=0 @@ -5728,12 +5792,6 @@ function _p9k_on_expand() { } fi fi - } - - if (( $+__p9k_instant_prompt_active )); then - unset __p9k_instant_prompt_active - unsetopt localoptions - setopt prompt_sp prompt_cr fi } functions -M _p9k_on_expand @@ -5857,12 +5915,9 @@ _p9k_precmd() { _p9k_precmd_impl - unsetopt localoptions - setopt nopromptbang prompt_percent prompt_subst - - if (( ! $+functions[TRAPINT] )); then - trap '_p9k_trapint; return 130' INT - fi + (( ${+functions[TRAPINT]} )) || trap '_p9k_trapint; return 130' INT + [[ ${+__p9k_instant_prompt_active} == 0 || -o no_prompt_cr ]] || __p9k_instant_prompt_active=2 + setopt no_local_options no_prompt_bang prompt_percent prompt_subst prompt_cr prompt_sp } function _p9k_reset_prompt() { @@ -6285,11 +6340,14 @@ _p9k_init_params() { esac _p9k_declare -b POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -b POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY 0 + _p9k_declare -b POWERLEVEL9K_PHP_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 _p9k_declare -a POWERLEVEL9K_RBENV_SOURCES -- shell local global + _p9k_declare -b POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW 0 + _p9k_declare -a POWERLEVEL9K_PHPENV_SOURCES -- shell local global _p9k_declare -b POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -a POWERLEVEL9K_LUAENV_SOURCES -- shell local global _p9k_declare -b POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW 0 @@ -6961,7 +7019,7 @@ _p9k_must_init() { [[ $sig == $_p9k__param_sig ]] && return 1 _p9k_deinit fi - _p9k__param_pat=$'v46\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1' + _p9k__param_pat=$'v49\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1' _p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1' _p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1' _p9k__param_pat+=$'$DEFAULT_USER\1${ZLE_RPROMPT_INDENT:-1}\1$P9K_SSH\1$__p9k_ksh_arrays' @@ -7396,14 +7454,16 @@ _p9k_setup() { prompt_opts+=cr fi - eval "$__p9k_intro" prompt_powerlevel9k_teardown __p9k_enabled=1 typeset -ga preexec_functions=(_p9k_preexec1 $preexec_functions _p9k_preexec2) typeset -ga precmd_functions=(_p9k_do_nothing $precmd_functions _p9k_precmd) } -prompt_powerlevel9k_setup() { _p9k_setup } +prompt_powerlevel9k_setup() { + eval "$__p9k_intro" + _p9k_setup +} prompt_powerlevel9k_teardown() { eval "$__p9k_intro" @@ -7734,7 +7794,8 @@ function p10k() { powerlevel10k_plugin_unload() { prompt_powerlevel9k_teardown; } function p10k-instant-prompt-finalize() { - (( ! __p9k_instant_prompt_active )) || unsetopt localoptions prompt_cr + unsetopt local_options + (( ${+__p9k_instant_prompt_active} )) && unsetopt prompt_cr prompt_sp || setopt prompt_cr prompt_sp } autoload -Uz add-zsh-hook diff --git a/internal/worker.zsh b/internal/worker.zsh index 34398faa..10d0c93a 100644 --- a/internal/worker.zsh +++ b/internal/worker.zsh @@ -5,7 +5,7 @@ function _p9k_worker_main() { exec 0<$_p9k__worker_file_prefix.fifo || return zf_rm $_p9k__worker_file_prefix.fifo || return - local -i reset n + local -i reset local req fd local -a ready local _p9k_worker_request_id @@ -34,9 +34,9 @@ function _p9k_worker_main() { if [[ $fd == 0 ]]; then local buf= [[ -t 0 ]] # https://www.zsh.org/mla/workers/2020/msg00207.html - if sysread -c n -t 0 'buf[$#buf+1]'; then - while [[ $buf != *$'\x1e' ]] || (( n == 8192 )); do - sysread -c n 'buf[$#buf+1]' || return + if sysread -t 0 'buf[$#buf+1]'; then + while [[ $buf != *$'\x1e' ]]; do + sysread 'buf[$#buf+1]' || return done else (( $? == 4 )) || return @@ -116,12 +116,11 @@ function _p9k_worker_receive() { (( $# <= 1 )) || return local buf resp - local -i n [[ -t $_p9k__worker_resp_fd ]] # https://www.zsh.org/mla/workers/2020/msg00207.html - if sysread -i $_p9k__worker_resp_fd -c n -t 0 'buf[$#buf+1]'; then - while [[ ${buf%%$'\x05'#} != (|*$'\x1e') ]] || (( n == 8192 )); do - sysread -i $_p9k__worker_resp_fd -c n 'buf[$#buf+1]' || return + if sysread -i $_p9k__worker_resp_fd -t 0 'buf[$#buf+1]'; then + while [[ $buf == *[^$'\x05\x1e']$'\x05'# ]]; do + sysread -i $_p9k__worker_resp_fd 'buf[$#buf+1]' || return done else (( $? == 4 )) || return @@ -177,7 +176,7 @@ function _p9k_worker_start() { setopt monitor || return { [[ -n $_p9k__worker_resp_fd ]] && return - _p9k__worker_file_prefix=${TMPDIR:-/tmp}/p10k.worker.$EUID.$$.$EPOCHSECONDS + _p9k__worker_file_prefix=${TMPDIR:-/tmp}/p10k.worker.$EUID.$sysparams[pid].$EPOCHSECONDS sysopen -r -o cloexec -u _p9k__worker_resp_fd <( if [[ -n $_POWERLEVEL9K_WORKER_LOG_LEVEL ]]; then diff --git a/powerlevel10k.zsh-theme b/powerlevel10k.zsh-theme index d0dfde91..74eaba5a 100644 --- a/powerlevel10k.zsh-theme +++ b/powerlevel10k.zsh-theme @@ -53,7 +53,6 @@ source $__p9k_root_dir/internal/p10k.zsh || true } -unsetopt local_options (( $+__p9k_instant_prompt_active )) && unsetopt prompt_cr prompt_sp || setopt prompt_cr prompt_sp (( ${#__p9k_src_opts} )) && setopt ${__p9k_src_opts[@]} |