diff --git a/Makefile b/Makefile index 86e55ee4..116ae41d 100644 --- a/Makefile +++ b/Makefile @@ -2,13 +2,6 @@ ZSH := $(shell command -v zsh 2> /dev/null) all: -zwc: - $(MAKE) -C gitstatus zwc - $(or $(ZSH),:) -fc 'for f in *.zsh-theme internal/*.zsh; do zcompile -R -- $$f.zwc $$f || exit; done' - -minify: - $(MAKE) -C gitstatus minify - rm -rf -- .git .gitattributes .gitignore LICENSE Makefile README.md font.md powerlevel10k.png - -pkg: zwc +pkg: $(MAKE) -C gitstatus pkg + $(or $(ZSH),:) -fc 'for f in *.zsh-theme internal/*.zsh; do zcompile -R -- $$f.zwc $$f || exit; done' diff --git a/README.md b/README.md index 884cb21f..92bacb26 100644 --- a/README.md +++ b/README.md @@ -2,59 +2,48 @@ [![Gitter](https://badges.gitter.im/powerlevel10k/community.svg)]( https://gitter.im/powerlevel10k/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) -- **THE PROJECT HAS VERY LIMITED SUPPORT** -- **NO NEW FEATURES ARE IN THE WORKS** -- **MOST BUGS WILL GO UNFIXED** -- **HELP REQUESTS WILL BE IGNORED** - Powerlevel10k is a theme for Zsh. It emphasizes [speed](#uncompromising-performance), [flexibility](#extremely-customizable) and [out-of-the-box experience](#configuration-wizard). ![Powerlevel10k]( https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/prompt-styles-high-contrast.png) -- [Getting started](#getting-started) -- [Features](#features) -- [Installation](#installation) -- [Configuration](#configuration) -- [Fonts](#fonts) -- [Try it in Docker](#try-it-in-docker) -- [License](#license) -- [FAQ](#faq) -- [Troubleshooting](#troubleshooting) +Ready to [get started](#get-started)? See below. -## Getting started +To see what Powerlevel10k is about go to [features](#features). -1. [Install the recommended font](#meslo-nerd-font-patched-for-powerlevel10k). *Optional but highly +Powerlevel9k users, go [here](#powerlevel9k-compatibility). + +See the [table of contents](#table-of-contents) at the bottom. + +## Get Started + +1. Install [the recommended font](#meslo-nerd-font-patched-for-powerlevel10k). *Optional but highly recommended.* -1. [Install Powerlevel10k](#installation) itself. -1. Restart Zsh with `exec zsh`. +1. Install Powerlevel10k for your plugin manager. + - [Manual](#manual) 👈 **choose this if confused or uncertain** + - [Oh My Zsh](#oh-my-zsh) + - [Prezto](#prezto) + - [Zim](#zim) + - [Antibody](#antibody) + - [Antigen](#antigen) + - [Zplug](#zplug) + - [Zgen](#zgen) + - [Zplugin](#zplugin) + - [Zinit](#zinit) + - [Homebrew](#homebrew) + - [Arch Linux](#arch-linux) +1. Restart Zsh. 1. Type `p10k configure` if the configuration wizard doesn't start automatically. ## Features -- [Configuration wizard](#configuration-wizard) -- [Uncompromising performance](#uncompromising-performance) -- [Powerlevel9k compatibility](#powerlevel9k-compatibility) -- [Pure compatibility](#pure-compatibility) -- [Instant prompt](#instant-prompt) -- [Show on command](#show-on-command) -- [Transient prompt](#transient-prompt) -- [Current directory that just works](#current-directory-that-just-works) -- [Extremely customizable](#extremely-customizable) -- [Batteries included](#batteries-included) -- [Extensible](#extensible) - ### Configuration wizard Type `p10k configure` to access the builtin configuration wizard right from your terminal. -
- Screen recording - - ![Powerlevel10k Configuration Wizard]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/configuration-wizard.gif) -
+![Powerlevel10k Configuration Wizard]( + https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/configuration-wizard.gif) All styles except [Pure](#pure-compatibility) are functionally equivalent. They display the same information and differ only in presentation. @@ -93,12 +82,8 @@ segments to fill four prompt lines on both sides of the screen... wait, that's j one ever does that. Probably impossible, too. The point is, Powerlevel10k prompt is always fast, no matter what you do! -
- Screen recording - - ![Powerlevel10k Performance]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/performance.gif) -
+![Powerlevel10k Performance]( + https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/performance.gif) Note how the effect of every command is instantly reflected by the very next prompt. @@ -120,12 +105,8 @@ Powerlevel10k you get fast prompt *and* up-to-date information. Powerlevel10k understands all [Powerlevel9k](https://github.com/Powerlevel9k/powerlevel9k) configuration parameters. -
- Screen recording - - ![Powerlevel10k Compatibility with 9k]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/9k-compatibility.gif) -
+![Powerlevel10k Compatibility with 9k]( + https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/9k-compatibility.gif) [Migration](#installation) from Powerlevel9k to Powerlevel10k is a straightforward process. All your `POWERLEVEL9K` configuration parameters will still work. Prompt will look the same as before @@ -147,12 +128,8 @@ but it will be [much faster](#uncompromising-performance) ([certainly](#is-it-re Powerlevel10k can produce the same prompt as [Pure](https://github.com/sindresorhus/pure). Type `p10k configure` and select *Pure* style. -
- Screen recording - - ![Powerlevel10k Pure Style]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/pure-style.gif) -
+![Powerlevel10k Pure Style]( + https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/pure-style.gif) You can still use Powerlevel10k features such as [transient prompt](#transient-prompt) or [instant prompt](#instant-prompt) when sporting Pure style. @@ -171,33 +148,22 @@ If your `~/.zshrc` loads many plugins, or perhaps just a few slow ones (for example, [pyenv](https://github.com/pyenv/pyenv) or [nvm](https://github.com/nvm-sh/nvm)), you may have noticed that it takes some time for Zsh to start. -
- Screen recording - - ![Powerlevel10k No Instant Prompt]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/no-instant-prompt.gif) -
+![Powerlevel10k No Instant Prompt]( + https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/no-instant-prompt.gif) Powerlevel10k can remove Zsh startup lag **even if it's not caused by a theme**. -
- Screen recording - - ![Powerlevel10k Instant Prompt]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/instant-prompt.gif) -
+![Powerlevel10k Instant Prompt]( + https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/instant-prompt.gif) This feature is called *Instant Prompt*. You need to explicitly enable it through `p10k configure` -or [manually](#how-do-i-configure-instant-prompt). It does what it says on the tin -- prints prompt +or [manually](#how-do-i-enable-instant-prompt). It does what it says on the tin -- prints prompt instantly upon Zsh startup allowing you to start typing while plugins are still loading. Other themes *increase* Zsh startup lag -- some by a lot, others by a just a little. Powerlevel10k *removes* it outright. -If you are curious about how *Instant Prompt* works, see -[this section in zsh-bench](https://github.com/romkatv/zsh-bench#instant-prompt). - -*FAQ:* [How do I configure instant prompt?](#how-do-i-configure-instant-prompt) +*FAQ:* [How do I enable instant prompt?](#how-do-i-enable-instant-prompt) ### Show on command @@ -209,19 +175,16 @@ likewise for AWS, Azure and Google Cloud credentials, prompt will get pretty cro Enter *Show On Command*. This feature makes prompt segments appear only when they are relevant to the command you are currently typing. -
- Screen recording - - ![Powerlevel10k Show On Command]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/show-on-command.gif) -
+![Powerlevel10k Show On Command]( + https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/show-on-command.gif) Configs created by `p10k configure` enable show on command for several prompt segments by default. Here's the relevant parameter for kubernetes context: ```zsh -# Show prompt segment "kubecontext" only when the command you are typing invokes one of these tools. -typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens' +# Show prompt segment "kubecontext" only when the command you are typing +# invokes kubectl, helm, kubens, kubectx, oc, istioctl, kogito, k9s or helmfile. +typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile' ``` To customize when different prompt segments are shown, open `~/.p10k.zsh`, search for @@ -233,12 +196,8 @@ or change their values. When *Transient Prompt* is enabled through `p10k configure`, Powerlevel10k will trim down every prompt when accepting a command line. -
- Screen recording - - ![Powerlevel10k Transient Prompt]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/transient-prompt.gif) -
+![Powerlevel10k Transient Prompt]( + https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/transient-prompt.gif) Transient prompt makes it much easier to copy-paste series of commands from the terminal scrollback. @@ -252,12 +211,8 @@ The current working directory is perhaps the most important prompt segment. Powe great length to highlight its important parts and to truncate it with the least loss of information when horizontal space gets scarce. -
- Screen recording - - ![Powerlevel10k Directory Truncation]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/directory-truncation.gif) -
+![Powerlevel10k Directory Truncation]( + https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/directory-truncation.gif) When the full directory doesn't fit, the leftmost segment gets truncated to its shortest unique prefix. In the screencast, `~/work` becomes `~/wo`. It couldn't be truncated to `~/w` because it @@ -280,12 +235,8 @@ Directory segments are shown in one of three colors: Powerlevel10k can be configured to look like any other Zsh theme out there. -
- Screen recording - - ![Powerlevel10k Other Theme Emulation]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/other-theme-emulation.gif) -
+![Powerlevel10k Other Theme Emulation]( + https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/other-theme-emulation.gif) [Pure](#pure-compatibility), [Powerlevel9k](#powerlevel9k-compatibility) and [robbyrussell]( #how-to-make-powerlevel10k-look-like-robbyrussell-oh-my-zsh-theme) emulations are built-in. @@ -305,97 +256,81 @@ To ~~ridiculous~~ extravagant: ### Batteries included -Powerlevel10k comes with dozens of built-in high quality prompt segments that can display -information from a variety of sources. When you run `p10k configure` and choose any style -except [Pure](#pure-compatibility), many of these segments get enabled by -default while others can be manually enabled by opening `~/.p10k.zsh` and uncommenting them. -You can enable as many segments as you like. It won't slow down your prompt or Zsh startup. +Powerlevel10k comes with dozens of built-in high quality segments. When you run `p10k configure` +and choose any style except [Pure](#pure-compatibility), many of these segments get enabled by +default while others be manually enabled by opening `~/.p10k.zsh` and uncommenting them. You can +enable as many segments as you like. It won't slow down your prompt or Zsh startup. | Segment | Meaning | |--------:|---------| -| `anaconda` | virtual environment from [conda](https://conda.io/) | +| `os_icon` | your OS logo (apple for macOS, swirl for debian, etc.) | +| `dir` | current working directory | +| `vcs` | Git repository status | +| `prompt_char` | multi-functional prompt symbol; changes depending on vi mode: `❯`, `❮`, `V`, `▶` for insert, command, visual and replace mode respectively; turns red on error | +| `context` | user@hostname | +| `status` | exit code of the last command | +| `command_execution_time` | duration (wall time) of the last command | +| `background_jobs` | presence of background jobs | +| `time` | current time | +| `direnv` | [direnv](https://direnv.net/) status | | `asdf` | tool versions from [asdf](https://github.com/asdf-vm/asdf) | +| `virtualenv` | python environment from [venv](https://docs.python.org/3/library/venv.html) | +| `anaconda` | virtual environment from [conda](https://conda.io/) | +| `pyenv` | python environment from [pyenv](https://github.com/pyenv/pyenv) | +| `goenv` | go environment from [goenv](https://github.com/syndbg/goenv) | +| `nodenv` | node.js environment from [nodenv](https://github.com/nodenv/nodenv) | +| `nvm` | node.js environment from [nvm](https://github.com/nvm-sh/nvm) | +| `nodeenv` | node.js environment from [nodeenv](https://github.com/ekalinin/nodeenv) | +| `rbenv` | ruby environment from [rbenv](https://github.com/rbenv/rbenv) | +| `rvm` | ruby environment from [rvm](https://rvm.io) | +| `fvm` | flutter environment from [fvm](https://github.com/leoafarias/fvm) | +| `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) | +| `haskell_stack` | haskell version from [stack](https://haskellstack.org/) | +| `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 | +| `java_version` | [java](https://www.java.com/) version | +| `package` | `name@version` from [package.json](https://docs.npmjs.com/files/package.json) | +| `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) | | `aws_eb_env` | [aws elastic beanstalk](https://aws.amazon.com/elasticbeanstalk/) environment | | `azure` | [azure](https://docs.microsoft.com/en-us/cli/azure) account name | -| `background_jobs` | presence of background jobs | -| `battery` | internal battery state and charge level (yep, batteries *literally* included) | -| `command_execution_time` | duration (wall time) of the last command | -| `context` | user@hostname | -| `cpu_arch` | CPU architecture | -| `dir` | current working directory | -| `direnv` | [direnv](https://direnv.net/) status | -| `disk_usage` | disk usage | -| `dotnet_version` | [dotnet](https://dotnet.microsoft.com) version | -| `fvm` | flutter environment from [fvm](https://github.com/leoafarias/fvm) | | `gcloud` | [google cloud](https://cloud.google.com/) cli account and project | -| `goenv` | go environment from [goenv](https://github.com/syndbg/goenv) | | `google_app_cred` | [google application credentials](https://cloud.google.com/docs/authentication/production) | -| `go_version` | [go](https://golang.org) version | -| `haskell_stack` | haskell version from [stack](https://haskellstack.org/) | -| `ip` | IP address and bandwidth usage for a specified network interface | -| `java_version` | [java](https://www.java.com/) version | -| `jenv` | java environment from [jenv](https://github.com/jenv/jenv) | -| `kubecontext` | current [kubernetes](https://kubernetes.io/) context | -| `laravel_version` | [laravel php framework](https://laravel.com/) version | -| `load` | CPU load | -| `luaenv` | lua environment from [luaenv](https://github.com/cehoffman/luaenv) | +| `nordvpn` | [nordvpn](https://nordvpn.com/) connection status | +| `ranger` | [ranger](https://github.com/ranger/ranger) shell | +| `nnn` | [nnn](https://github.com/jarun/nnn) shell | +| `vim_shell` | [vim](https://www.vim.org/) shell (`:sh`) | | `midnight_commander` | [midnight commander](https://midnight-commander.org/) shell | | `nix_shell` | [nix shell](https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) indicator | -| `nnn` | [nnn](https://github.com/jarun/nnn) shell | -| `lf` | [lf](https://github.com/gokcehan/lf) shell | -| `chezmoi_shell` | [chezmoi](https://www.chezmoi.io/) shell | -| `nodeenv` | node.js environment from [nodeenv](https://github.com/ekalinin/nodeenv) | -| `nodenv` | node.js environment from [nodenv](https://github.com/nodenv/nodenv) | -| `node_version` | [node.js](https://nodejs.org/) version | -| `nordvpn` | [nordvpn](https://nordvpn.com/) connection status | -| `nvm` | node.js environment from [nvm](https://github.com/nvm-sh/nvm) | -| `os_icon` | your OS logo (apple for macOS, swirl for debian, etc.) | -| `package` | `name@version` from [package.json](https://docs.npmjs.com/files/package.json) | -| `per_directory_history` | Oh My Zsh [per-directory-history](https://github.com/jimhester/per-directory-history) local/global indicator | -| `perlbrew` | perl version from [perlbrew](https://github.com/gugod/App-perlbrew) | -| `phpenv` | php environment from [phpenv](https://github.com/phpenv/phpenv) | -| `php_version` | [php](https://www.php.net/) version | -| `plenv` | perl environment from [plenv](https://github.com/tokuhirom/plenv) | -| `prompt_char` | multi-functional prompt symbol; changes depending on vi mode: `❯`, `❮`, `V`, `▶` for insert, command, visual and replace mode respectively; turns red on error | -| `proxy` | system-wide http/https/ftp proxy | -| `public_ip` | public IP address | -| `pyenv` | python environment from [pyenv](https://github.com/pyenv/pyenv) | -| `ram` | free RAM | -| `ranger` | [ranger](https://github.com/ranger/ranger) shell | -| `yazi` | [yazi](https://github.com/sxyazi/yazi) shell | -| `rbenv` | ruby environment from [rbenv](https://github.com/rbenv/rbenv) | -| `rust_version` | [rustc](https://www.rust-lang.org) version | -| `rvm` | ruby environment from [rvm](https://rvm.io) | -| `scalaenv` | scala version from [scalaenv](https://github.com/scalaenv/scalaenv) | -| `status` | exit code of the last command | -| `swap` | used swap | -| `taskwarrior` | [taskwarrior](https://taskwarrior.org/) task count | -| `terraform` | [terraform](https://www.terraform.io) workspace | -| `terraform_version` | [terraform](https://www.terraform.io) version | -| `time` | current time | -| `timewarrior` | [timewarrior](https://timewarrior.net/) tracking status | | `todo` | [todo](https://github.com/todotxt/todo.txt-cli) items | -| `toolbox` | [toolbox](https://github.com/containers/toolbox) name | -| `vcs` | Git repository status | -| `vim_shell` | [vim](https://www.vim.org/) shell (`:sh`) | -| `virtualenv` | python environment from [venv](https://docs.python.org/3/library/venv.html) | -| `vi_mode` | vi mode (you don't need this if you've enabled prompt_char) | +| `timewarrior` | [timewarrior](https://timewarrior.net/) tracking status | +| `taskwarrior` | [taskwarrior](https://taskwarrior.org/) task count | | `vpn_ip` | virtual private network indicator | +| `ip` | IP address and bandwidth usage for a specified network interface | +| `load` | CPU load | +| `disk_usage` | disk usage | +| `ram` | free RAM | +| `swap` | used swap | +| `public_ip` | public IP address | +| `proxy` | system-wide http/https/ftp proxy | | `wifi` | WiFi speed | -| `xplr` | [xplr](https://github.com/sayanarijit/xplr) shell | +| `battery` | internal battery state and charge level (yep, batteries *literally* included) | ### Extensible If there is no prompt segment that does what you need, implement your own. Powerlevel10k provides public API for defining segments that are as fast and as flexible as built-in ones. -
- Screen recording - - ![Powerlevel10k Custom Segment]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/custom-segment.gif) -
+![Powerlevel10k Custom Segment]( + https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/custom-segment.gif) On Linux you can fetch current CPU temperature by reading `/sys/class/thermal/thermal_zone0/temp`. The screencast shows how to define a prompt segment to display this value. Once the segment is @@ -404,34 +339,11 @@ it out of the box. Type `p10k help segment` for reference. -*Note*: If you modify `POWERLEVEL9K_*` parameters in an already initialized interactive shell (as -opposed to editing `~/.p10k.zsh`), the changes might not be immediately effective. To apply the -modifications, invoke `p10k reload`. Setting `POWERLEVEL9K_DISABLE_HOT_RELOAD=false` eliminates the -necessity for `p10k reload` but results in a marginally slower prompt. - *Tip*: Prefix names of your own segments with `my_` to avoid clashes with future versions of Powerlevel10k. ## Installation -- [Manual](#manual) 👈 **choose this if confused or uncertain** -- [Oh My Zsh](#oh-my-zsh) -- [Prezto](#prezto) -- [Zim](#zim) -- [Antibody](#antibody) -- [Antidote](#antidote) -- [Antigen](#antigen) -- [Zplug](#zplug) -- [Zgen](#zgen) -- [Zplugin](#zplugin) -- [Zinit](#zinit) -- [Zi](#zi) -- [Zap](#zap) -- [Homebrew](#homebrew) -- [Arch Linux](#arch-linux) -- [Alpine Linux](#alpine-linux) -- [Fig](#fig) - ### Manual ```zsh @@ -439,8 +351,8 @@ git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc ``` -Users in China can use the official mirror on gitee.com for faster download.
-中国用户可以使用 gitee.com 上的官方镜像加速下载. +Users in mainland China can use the official mirror on gitee.com for faster download.
+中国大陆用户可以使用 gitee.com 上的官方镜像加速下载. ```zsh git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ~/powerlevel10k @@ -453,17 +365,18 @@ make sure to disable the current theme in your plugin manager. See ### Oh My Zsh -1. Clone the repository: - ```zsh - git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k - ``` - Users in China can use the official mirror on gitee.com for faster download.
- 中国用户可以使用 gitee.com 上的官方镜像加速下载. +```zsh +git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k +``` - ```zsh - git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k - ``` -2. Set `ZSH_THEME="powerlevel10k/powerlevel10k"` in `~/.zshrc`. +Users in mainland China can use the official mirror on gitee.com for faster download.
+中国大陆用户可以使用 gitee.com 上的官方镜像加速下载. + +```zsh +git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k +``` + +Set `ZSH_THEME="powerlevel10k/powerlevel10k"` in `~/.zshrc`. ### Prezto @@ -471,16 +384,12 @@ Add `zstyle :prezto:module:prompt theme powerlevel10k` to `~/.zpreztorc`. ### Zim -Add `zmodule romkatv/powerlevel10k --use degit` to `~/.zimrc` and run `zimfw install`. +Add `zmodule romkatv/powerlevel10k` to `~/.zimrc` and run `zimfw install`. ### Antibody Add `antibody bundle romkatv/powerlevel10k` to `~/.zshrc`. -### Antidote - -Add `romkatv/powerlevel10k` to `~/.zsh_plugins.txt`. - ### Antigen Add `antigen theme romkatv/powerlevel10k` to `~/.zshrc`. Make sure you have `antigen apply` @@ -508,22 +417,11 @@ Add `zinit ice depth=1; zinit light romkatv/powerlevel10k` to `~/.zshrc`. The use of `depth=1` ice is optional. Other types of ice are neither recommended nor officially supported by Powerlevel10k. -### Zi - -Add `zi ice depth=1; zi light romkatv/powerlevel10k` to `~/.zshrc`. - -The use of `depth=1` ice is optional. Other types of ice are neither recommended nor officially -supported by Powerlevel10k. - -### Zap - -Add `plug "romkatv/powerlevel10k"` to `~/.zshrc`. - ### Homebrew ```zsh -brew install powerlevel10k -echo "source $(brew --prefix)/share/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc +brew install romkatv/powerlevel10k/powerlevel10k +echo "source $(brew --prefix)/opt/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc ``` ### Arch Linux @@ -537,28 +435,12 @@ echo 'source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme' >>~/.zs referenced above is the official Powerlevel10k package. There is also [zsh-theme-powerlevel10k]( - https://www.archlinux.org/packages/extra/x86_64/zsh-theme-powerlevel10k/) package. -Historically, [it has been breaking often and for extended periods of time]( + https://www.archlinux.org/packages/community/x86_64/zsh-theme-powerlevel10k/) community package. +Historicaly, [it has been breaking often and for extended periods of time]( https://github.com/romkatv/powerlevel10k/pull/786). **Do not use it.** -### Alpine Linux - -```zsh -apk add zsh zsh-theme-powerlevel10k -mkdir -p ~/.local/share/zsh/plugins -ln -s /usr/share/zsh/plugins/powerlevel10k ~/.local/share/zsh/plugins/ -``` - -### Fig - -Follow the instructions on -[this page](https://fig.io/plugins/other/powerlevel10k). - ## Configuration -- [For new users](#for-new-users) -- [For Powerlevel9k users](#for-powerlevel9k-users) - ### For new users On the first run, Powerlevel10k [configuration wizard](#configuration-wizard) will ask you a few @@ -637,151 +519,72 @@ If you are using a different terminal, proceed with manual font installation. #### Manual font installation -1. Download these four ttf files: - - [MesloLGS NF Regular.ttf]( - https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf) - - [MesloLGS NF Bold.ttf]( - https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf) - - [MesloLGS NF Italic.ttf]( - https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf) - - [MesloLGS NF Bold Italic.ttf]( - https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf) -1. Double-click on each file and click "Install". This will make `MesloLGS NF` font available to all - applications on your system. -1. Configure your terminal to use this font: - - **iTerm2**: Type `p10k configure` and answer `Yes` when asked whether to install - *Meslo Nerd Font*. Alternatively, open *iTerm2 → Preferences → Profiles → Text* and set *Font* to - `MesloLGS NF`. - - **Apple Terminal**: Open *Terminal → Preferences → Profiles → Text*, click *Change* under *Font* - and select `MesloLGS NF` family. - - **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* (PC) or - *Code → Preferences → Settings* (Mac), enter `terminal.integrated.fontFamily` in the search box at - the top of *Settings* tab and set the value below to `MesloLGS NF`. - Consult [this screenshot]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/389133fb8c9a2347929a23702ce3039aacc46c3d/visual-studio-code-font-settings.jpg) - to see how it should look like or see [this issue]( - https://github.com/romkatv/powerlevel10k/issues/671) for extra information. - - **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** by Microsoft (the new thing): Open *Settings* (Ctrl+,), click - either on the selected profile under *Profiles* or on *Defaults*, click *Appearance* and set - *Font face* to `MesloLGS NF`. - - **Conemu**: Open *Setup → General → Fonts* and set *Main console font* to `MesloLGS NF`. - - **IntelliJ** (and other IDEs by Jet Brains): Open *IDE → Edit → Preferences → Editor → - Color Scheme → Console Font*. Select *Use console font instead of the default* and set the font - name to `MesloLGS NF`. - - **Termux**: Type `p10k configure` and answer `Yes` when asked whether to install - *Meslo Nerd Font*. - - **Blink**: Type `config`, go to *Appearance*, tap *Add a new font*, tap *Open Gallery*, select - *MesloLGS NF.css*, tap *import* and type `exit` in the home view to reload the font. - - **Tabby** (formerly **Terminus**): Open *Settings → Appearance* and set *Font* to `MesloLGS NF`. - - **Terminator**: Open *Preferences* using the context menu. Under *Profiles* select the *General* - tab (should be selected already), uncheck *Use the system fixed width font* (if not already) - and select `MesloLGS NF Regular`. Exit the Preferences dialog by clicking *Close*. - - **Guake**: Right Click on an open terminal and open *Preferences*. Under *Appearance* - tab, uncheck *Use the system fixed width font* (if not already) and select `MesloLGS NF Regular`. - Exit the Preferences dialog by clicking *Close*. - - **MobaXterm**: Open *Settings* → *Configuration* → *Terminal* → (under *Terminal look and feel*) - and change *Font* to `MesloLGS NF`. If you have *sessions*, you need to change the font in each - of them through *Settings* → right click on an individual session → *Edit Session* → *Terminal - Settings* → *Font settings*. - - **Asbrú Connection Manager**: Open *Preferences → Local Shell Options → Look and Feel*, enable - *Use these personal options* and change *Font:* under *Terminal UI* to `MesloLGS NF Regular`. - To change the font for the remote host connections, go to *Preferences → Terminal Options → - Look and Feel* and change *Font:* under *Terminal UI* to `MesloLGS NF Regular`. - - **WSLtty**: Right click on an open terminal and then on *Options*. In the *Text* section, under - *Font*, click *"Select..."* and set Font to `MesloLGS NF Regular`. - - **Yakuake**: Click *≡* → *Manage Profiles* → *New* → *Appearance*. Click *Choose* next to the - *Font* dropdown, select `MesloLGS NF` and click *OK*. Click *OK* to save the profile. Select the - new profile and click *Set as Default*. - - **Alacritty**: Create or open `~/.config/alacritty/alacritty.toml` and add the following - section to it: - ```toml - [font.normal] - family = "MesloLGS NF" - ``` - - **foot**: Create or open `~/.config/foot/foot.ini` and add the following section to it: - ```ini - font=MesloLGS NF:size=12 - ``` - - **kitty**: Create or open `~/.config/kitty/kitty.conf` and add the following line to it: - ```text - font_family MesloLGS NF - ``` - Restart kitty by closing all sessions and opening a new session. - - **puTTY**: Set *Window* → *Appearance* → *Font* to `MesloLGS NF`. Requires puTTY - version >= 0.75. - - **WezTerm**: Create or open `$HOME/.config/wezterm/wezterm.lua` and add the following: - ```lua - local wezterm = require 'wezterm'; - return { - font = wezterm.font("MesloLGS NF"), - } - ``` - If the file already exists, only add the line with the font to the existing return. - Also add the first line if it is not already present. - - **urxvt**: Create or open `~/.Xresources` and add the following line to it: - ```text - URxvt.font: xft:MesloLGS NF:size=11 - ``` - You can adjust the font size to your preference. After changing the config run - `xrdb ~/.Xresources` to reload it. The new config is applied to all new terminals. - - **xterm**: Create or open `~/.Xresources` and add the following line to it: - ```text - xterm*faceName: MesloLGS NF - ``` - After changing the config run `xrdb ~/.Xresources` to reload it. The new config is applied to - all new terminals. - - **Zed**: Open `~/.config/zed/settings.json` and set `terminal.font_family` to `"MesloLGS NF"`. - ```jsonc - { - "terminal": { - "font_family": "MesloLGS NF" - }, - // Other settings. - } - ``` - - Crostini (Linux on Chrome OS): Open - chrome-untrusted://terminal/html/nassh_preferences_editor.html, set *Text font family* to - `'MesloLGS NF'` (including the quotes) and *Custom CSS (inline text)* to the following: - ```css - @font-face { - font-family: "MesloLGS NF"; - src: url("https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Regular.ttf"); - font-weight: normal; - font-style: normal; - } - @font-face { - font-family: "MesloLGS NF"; - src: url("https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Bold.ttf"); - font-weight: bold; - font-style: normal; - } - @font-face { - font-family: "MesloLGS NF"; - src: url("https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Italic.ttf"); - font-weight: normal; - font-style: italic; - } - @font-face { - font-family: "MesloLGS NF"; - src: url("https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Bold%20Italic.ttf"); - font-weight: bold; - font-style: italic; - } - ``` - **_CAVEAT_**: If you open the normal terminal preferences these settings will be overwritten. -1. Run `p10k configure` to generate a new `~/.p10k.zsh`. The old config may work - incorrectly with the new font. +Download these four ttf files: + +- [MesloLGS NF Regular.ttf]( + https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf) +- [MesloLGS NF Bold.ttf]( + https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf) +- [MesloLGS NF Italic.ttf]( + https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf) +- [MesloLGS NF Bold Italic.ttf]( + https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf) + +Double-click on each file and click "Install". This will make `MesloLGS NF` font available to all +applications on your system. Configure your terminal to use this font: + +- **iTerm2**: Type `p10k configure` and answer `Yes` when asked whether to install + *Meslo Nerd Font*. Alternatively, open *iTerm2 → Preferences → Profiles → Text* and set *Font* to + `MesloLGS NF`. +- **Apple Terminal**: Open *Terminal → Preferences → Profiles → Text*, click *Change* under *Font* + and select `MesloLGS NF` family. +- **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 the value to `MesloLGS NF`. +- **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`. +- **Microsoft Terminal** (the new thing): Open *Settings* (`Ctrl+,`), search for `fontFace` and set + value to `MesloLGS NF` for every profile. +- **IntelliJ**: Open *Intellij → Edit → Preferences → Editor → Color Scheme → Console Font*. + Select *Use console font instead of the default* and set the font name to `MesloLGS NF`. +- **Termux**: Type `p10k configure` and answer `Yes` when asked whether to install + *Meslo Nerd Font*. +- **Blink**: Type `config`, go to *Appearance*, tap *Add a new font*, tap *Open Gallery*, select + *MesloLGS NF.css*, tap *import* and type `exit` in the home view to reload the font. +- **Terminus**: Open *Settings → Appearance* and set *Font* to `MesloLGS NF`. +- **Terminator**: Open *Preferences* using the context menu. Under *Profiles* select the *General* + tab (should be selected already), uncheck *Use the system fixed width font* (if not already) + and select `MesloLGS NF Regular`. Exit the Preferences dialog by clicking *Close*. +- **Guake**: Right Click on an open terminal and open *Preferences*. Under *Appearance* + tab, uncheck *Use the system fixed width font* (if not already) and select `MesloLGS NF Regular`. + Exit the Preferences dialog by clicking *Close*. +- **MobaXterm**: Open *Settings* → *Configuration* → *Terminal* → (Under *Terminal look and feel*) + and change *Font* to `MesloLGS NF`. +- **WSLtty**: Right click on an open terminal and then on *Options*. In the *Text* section, under + *Font*, click *"Select..."* and set Font to `MesloLGS NF Regular`. +- **Alacritty**: Create or open `~/.config/alacritty/alacritty.yml` and add the following section + to it: + ```yaml + font: + normal: + family: "MesloLGS NF" + ``` + - **Kitty**: Create or open `~/.config/kitty/kitty.conf` and add the following line to it: + ```text + font_family MesloLGS NF + ``` + Restart Kitty by closing all sessions and opening a new session. + +**IMPORTANT:** Run `p10k configure` after changing terminal font. The old `~/.p10k.zsh` may work +incorrectly with the new font. _Using a different terminal and know how to set the font for it? Share your knowledge by sending a PR to expand the list!_ @@ -789,10 +592,11 @@ PR to expand the list!_ ## Try it in Docker Try Powerlevel10k in Docker. You can safely make any changes to the file system while trying out -the theme. Once you exit Zsh, the container is deleted. +the theme. Once you exit Zsh, the image is deleted. ```zsh -docker run -e TERM -e COLORTERM -e LC_ALL=C.UTF-8 -it --rm alpine sh -uec ' +docker run -e TERM -e COLORTERM -it --rm alpine sh -uec ' + apk update apk add git zsh nano vim git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k echo "source ~/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc @@ -812,57 +616,23 @@ Powerlevel10k is released under the ## FAQ -- [How do I update Powerlevel10k?](#how-do-i-update-powerlevel10k) -- [How do I uninstall Powerlevel10k?](#how-do-i-uninstall-powerlevel10k) -- [How do I install Powerlevel10k on a machine without Internet access?](#how-do-i-install-powerlevel10k-on-a-machine-without-internet-access) -- [Where can I ask for help and report bugs?](#where-can-i-ask-for-help-and-report-bugs) -- [Which aspects of shell and terminal does Powerlevel10k affect?](#which-aspects-of-shell-and-terminal-does-powerlevel10k-affect) -- [I'm using Powerlevel9k with Oh My Zsh. How do I migrate?](#im-using-powerlevel9k-with-oh-my-zsh-how-do-i-migrate) -- [Is it really fast?](#is-it-really-fast) -- [How do I configure instant prompt?](#how-do-i-configure-instant-prompt) -- [How do I initialize direnv when using instant prompt?](#how-do-i-initialize-direnv-when-using-instant-prompt) -- [How do I export GPG_TTY when using instant prompt?](#how-do-i-export-gpg_tty-when-using-instant-prompt) -- [What do different symbols in Git status mean?](#what-do-different-symbols-in-git-status-mean) -- [How do I change the format of Git status?](#how-do-i-change-the-format-of-git-status) -- [Why is Git status from `$HOME/.git` not displayed in prompt?](#why-is-git-status-from-homegit-not-displayed-in-prompt) -- [Why does Git status sometimes appear grey and then gets colored after a short period of time?](#why-does-git-status-sometimes-appear-grey-and-then-gets-colored-after-a-short-period-of-time) -- [How do I add username and/or hostname to prompt?](#how-do-i-add-username-andor-hostname-to-prompt) -- [Why some prompt segments appear and disappear as I'm typing?](#why-some-prompt-segments-appear-and-disappear-as-im-typing) -- [How do I change prompt colors?](#how-do-i-change-prompt-colors) -- [Why does Powerlevel10k spawn extra processes?](#why-does-powerlevel10k-spawn-extra-processes) -- [Are there configuration options that make Powerlevel10k slow?](#are-there-configuration-options-that-make-powerlevel10k-slow) -- [Is Powerlevel10k fast to load?](#is-powerlevel10k-fast-to-load) -- [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) -- [What is the minimum supported Zsh version?](#what-is-the-minimum-supported-zsh-version) -- [How were these screenshots and animated gifs created?](#how-were-these-screenshots-and-animated-gifs-created) -- [How was the recommended font created?](#how-was-the-recommended-font-created) -- [How to package Powerlevel10k for distribution?](#how-to-package-powerlevel10k-for-distribution) - ### How do I update Powerlevel10k? The command to update Powerlevel10k depends on how it was installed. -| Installation | Update command | -|-------------------------------|-------------------------------------------------------------| -| [Manual](#manual) | `git -C ~/powerlevel10k pull` | -| [Oh My Zsh](#oh-my-zsh) | `git -C ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k pull` | -| [Prezto](#prezto) | `zprezto-update` | -| [Zim](#zim) | `zimfw update` | -| [Antigen](#antigen) | `antigen update` | -| [Antidote](#antidote) | `antidote update` | -| [Zplug](#zplug) | `zplug update` | -| [Zgen](#zgen) | `zgen update` | -| [Zplugin](#zplugin) | `zplugin update` | -| [Zinit](#zinit) | `zinit update` | -| [Zi](#zi) | `zi update` | -| [Zap](#zap) | `zap update` | -| [Homebrew](#homebrew) | `brew update && brew upgrade` | -| [Arch Linux](#arch-linux) | `yay -S --noconfirm zsh-theme-powerlevel10k-git` | -| [Alpine Linux](#alpine-linux) | `apk update && apk upgrade` | +| Installation | Update command | +|---------------------------|-------------------------------------------------------------| +| [Manual](#manual) | `git -C ~/powerlevel10k pull` | +| [Oh My Zsh](#oh-my-zsh) | `git -C ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k pull` | +| [Prezto](#prezto) | `zprezto-update` | +| [Zim](#zim) | `zimfw update` | +| [Antigen](#antigen) | `antigen update` | +| [Zplug](#zplug) | `zplug update` | +| [Zgen](#zgen) | `zgen update` | +| [Zplugin](#zplugin) | `zplugin update` | +| [Zinit](#zinit) | `zinit update` | +| [Homebrew](#homebrew) | `brew update && brew upgrade` | +| [Arch Linux](#arch-linux) | `yay -S --noconfirm zsh-theme-powerlevel10k-git` | **IMPORTANT**: Restart Zsh after updating Powerlevel10k. [Do not use `source ~/.zshrc`]( #weird-things-happen-after-typing-source-zshrc). @@ -900,28 +670,20 @@ The command to update Powerlevel10k depends on how it was installed. Powerlevel10k. The command to delete them depends on which installation method you'd chosen. Refer to the [installation instructions](#installation) if you need a reminder. - | Installation | Uninstall command | - |-------------------------------|------------------------------------------------------------------| - | [Manual](#manual) | `rm -rf ~/powerlevel10k` | - | [Oh My Zsh](#oh-my-zsh) | `rm -rf -- ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k` | - | [Prezto](#prezto) | n/a | - | [Zim](#zim) | `zimfw uninstall` | - | [Antigen](#antigen) | `antigen purge romkatv/powerlevel10k` | - | [Antidote](#antidote) | `antidote purge romkatv/powerlevel10k` | - | [Zplug](#zplug) | `zplug clean` | - | [Zgen](#zgen) | `zgen reset` | - | [Zplugin](#zplugin) | `zplugin delete romkatv/powerlevel10k` | - | [Zinit](#zinit) | `zinit delete romkatv/powerlevel10k` | - | [Zi](#zi) | `zi delete romkatv/powerlevel10k` | - | [Zap](#zap) | `zsh -ic 'zap clean'` | - | [Homebrew](#homebrew) | `brew uninstall powerlevel10k` | - | [Arch Linux](#arch-linux) | `yay -R --noconfirm zsh-theme-powerlevel10k-git` | - | [Alpine Linux](#alpine-linux) | `apk del zsh-theme-powerlevel10k` | -6. Restart Zsh. [Do not use `source ~/.zshrc`](#weird-things-happen-after-typing-source-zshrc). -7. Delete Powerlevel10k cache files. - ```zsh - rm -rf -- "${XDG_CACHE_HOME:-$HOME/.cache}"/p10k-*(N) "${XDG_CACHE_HOME:-$HOME/.cache}"/gitstatus - ``` + | Installation | Uninstall command | + |---------------------------|------------------------------------------------------------------| + | [Manual](#manual) | `rm -rf ~/powerlevel10k` | + | [Oh My Zsh](#oh-my-zsh) | `rm -rf -- ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k` | + | [Prezto](#prezto) | n/a | + | [Zim](#zim) | `zimfw uninstall` | + | [Antigen](#antigen) | `antigen purge romkatv/powerlevel10k` | + | [Zplug](#zplug) | `zplug clean` | + | [Zgen](#zgen) | `zgen reset` | + | [Zplugin](#zplugin) | `zplugin delete romkatv/powerlevel10k` | + | [Zinit](#zinit) | `zinit delete romkatv/powerlevel10k` | + | [Homebrew](#homebrew) | `brew uninstall powerlevel10k; brew untap romkatv/powerlevel10k` | + | [Arch Linux](#arch-linux) | `yay -R --noconfirm zsh-theme-powerlevel10k-git` | +5. Restart Zsh. [Do not use `source ~/.zshrc`](#weird-things-happen-after-typing-source-zshrc). ### How do I install Powerlevel10k on a machine without Internet access? @@ -987,8 +749,6 @@ Powerlevel10k does not affect: - Prompt parameters other than `PS1` and `RPS1`. - Zsh options other than those [related to prompt]( http://zsh.sourceforge.net/Doc/Release/Options.html#Prompting). -- The set of available commands. Powerlevel10k does not install any new commands - with the only exception of `p10k`. ### I'm using Powerlevel9k with Oh My Zsh. How do I migrate? @@ -1015,14 +775,36 @@ exec zsh ### Is it really fast? -Yes. See [zsh-bench](https://github.com/romkatv/zsh-bench) or a direct comparison with -[Powerlevel9k](https://asciinema.org/a/NHRjK3BMePw66jtRVY2livHwZ) and -[Spaceship](https://asciinema.org/a/253094). +Yes. -### How do I configure instant prompt? +[![asciicast](https://asciinema.org/a/NHRjK3BMePw66jtRVY2livHwZ.svg)]( + https://asciinema.org/a/NHRjK3BMePw66jtRVY2livHwZ) + +Benchmark results obtained with +[zsh-prompt-benchmark](https://github.com/romkatv/zsh-prompt-benchmark) on an Intel i9-7900X +running Ubuntu 18.04 with the config from the demo. + +| Theme | Prompt Latency | +|---------------------|---------------:| +| powerlevel9k/master | 1046 ms | +| powerlevel9k/next | 1005 ms | +| **powerlevel10k** | **8.7 ms** | + +Powerlevel10k is over 100 times faster than Powerlevel9k in this benchmark. + +In fairness, Powerlevel9k has acceptable latency when given a spartan configuration. If all you need +is the current directory without truncation or shortening, Powerlevel9k can render it for you in +17 ms. Powerlevel10k can do the same 30 times faster but it won't matter in practice because 17 ms +is fast enough (the threshold where latency becomes noticeable is around 50 ms). You have to be +careful with Powerlevel9k configuration as it's all too easy to make prompt frustratingly slow. +Powerlevel10k, on the other hand, doesn't require trading latency for utility -- it's virtually +instant with any configuration. It stays well below the 50 ms mark, leaving most of the latency +budget for other plugins you might install. + +### How do I enable instant prompt? See [instant prompt](#instant-prompt) to learn about instant prompt. This section explains how you -can enable and configure it and lists caveats that you should be aware of. +can enable it and lists caveats that you should be aware of. Instant prompt can be enabled either through `p10k configure` or by manually adding the following code snippet at the top of `~/.zshrc`: @@ -1088,79 +870,25 @@ to move it above the instant prompt preamble or to suppress its output. You can instant prompt with `POWERLEVEL9K_INSTANT_PROMPT=off`. Do this if instant prompt breaks Zsh initialization and you don't know how to fix it. -The value of `POWERLEVEL9K_INSTANT_PROMPT` can be changed by running `p10k configure` and selecting -the appropriate option on the *Instant Prompt* screen. Alternatively, you can search for -`POWERLEVEL9K_INSTANT_PROMPT` in the existing `~/.p10k.zsh` and change its value there. - *Note*: Instant prompt requires Zsh >= 5.4. It's OK to enable it even when using an older version of Zsh but it won't do anything. -*FAQ*: - -- [How do I initialize direnv when using instant prompt?]( - #how-do-i-initialize-direnv-when-using-instant-prompt) -- [How do I export GPG_TTY when using instant prompt?]( - #how-do-i-export-gpg_tty-when-using-instant-prompt) - -### How do I initialize direnv when using instant prompt? - -If you've enabled [instant prompt](#instant-prompt), you should have these lines at the top of -`~/.zshrc`: - -```zsh -if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then - source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" -fi -``` - -To initialize direnv you need to add one line above that block and one line below it. - -```zsh -(( ${+commands[direnv]} )) && emulate zsh -c "$(direnv export zsh)" - -if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then - source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" -fi - -(( ${+commands[direnv]} )) && emulate zsh -c "$(direnv hook zsh)" -``` - -*Related*: [How do I export GPG_TTY when using instant prompt?]( - #how-do-i-export-gpg_tty-when-using-instant-prompt) - -### How do I export GPG_TTY when using instant prompt? - -You can export `GPG_TTY` like this anywhere in `~/.zshrc`: - -```zsh -export GPG_TTY=$TTY -``` - -This works whether you are using [instant prompt](#instant-prompt) or not. It works even if you -aren't using powerlevel10k. As an extra bonus, it's much faster than the commonly used -`export GPG_TTY=$(tty)`. - -*Related*: [How do I initialize direnv when using instant prompt?]( - #how-do-i-initialize-direnv-when-using-instant-prompt) - ### What do different symbols in Git status mean? When using Lean, Classic or Rainbow style, Git status may look like this: ```text -feature:master wip ⇣42⇡42 ⇠42⇢42 *42 merge ~42 +42 !42 ?42 +feature:master ⇣42⇡42 ⇠42⇢42 *42 merge ~42 +42 !42 ?42 ``` | Symbol | Meaning | Source | | --------- | -------------------------------------------------------------------- | ------------------------------------------------------ | | `feature` | current branch; replaced with `#tag` or `@commit` if not on a branch | `git status --ignore-submodules=dirty` | -| `master` | remote tracking branch; only shown if different from local branch | `git rev-parse --abbrev-ref --symbolic-full-name @{upstream}` | -| `wip` | the latest commit's summary contains "wip" or "WIP" | `git show --pretty=%s --no-patch HEAD` | -| `=` | up to date with the remote (neither ahead nor behind) | `git rev-list --count HEAD...@{upstream}` | -| `⇣42` | this many commits behind the remote | `git rev-list --right-only --count HEAD...@{upstream}` | -| `⇡42` | this many commits ahead of the remote | `git rev-list --left-only --count HEAD...@{upstream}` | -| `⇠42` | this many commits behind the push remote | `git rev-list --right-only --count HEAD...@{push}` | -| `⇢42` | this many commits ahead of the push remote | `git rev-list --left-only --count HEAD...@{push}` | +| `master` | remote tracking branch; only shown if different from local branch | `git rev-parse --abbrev-ref --symbolic-full-name @{u}` | +| `⇣42` | this many commits behind the remote | `git status --ignore-submodules=dirty` | +| `⇡42` | this many commits ahead of the remote | `git status --ignore-submodules=dirty` | +| `⇠42` | this many commits behind the push remote | `git rev-list --left-right --count HEAD...@{push}` | +| `⇢42` | this many commits ahead of the push remote | `git rev-list --left-right --count HEAD...@{push}` | | `*42` | this many stashes | `git stash list` | | `merge` | repository state | `git status --ignore-submodules=dirty` | | `~42` | this many merge conflicts | `git status --ignore-submodules=dirty` | @@ -1208,7 +936,7 @@ completes, Powerlevel10k refreshes prompt with new information, this time with c When using *Rainbow* style, Git status is displayed as black on grey while it's still being computed. Depending on the terminal color palette, this may be difficult to read. In this case you -might want to change the background color to something lighter for more contrast. To do that, open +might want to change the background color to something ligher for more contrast. To do that, open `~/.p10k.zsh`, search for `POWERLEVEL9K_VCS_LOADING_BACKGROUND`, uncomment it if it's commented out, and change the value. @@ -1261,9 +989,9 @@ Prompt segments can be configured to be shown only when the current command you a relevant tool. ```zsh -# Show prompt segment "kubecontext" only when the command you are typing invokes -# invokes kubectl, helm, or kubens. -typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens' +# Show prompt segment "kubecontext" only when the command you are typing +# invokes kubectl, helm, kubens, kubectx, oc, istioctl, kogito, k9s or helmfile. +typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile' ``` Configs created by `p10k configure` may contain parameters of this kind. To customize when different @@ -1279,7 +1007,7 @@ function kube-toggle() { if (( ${+POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND} )); then unset POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND else - POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens' + POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile' fi p10k reload if zle; then @@ -1332,29 +1060,12 @@ terminals. Many terminals also support customization of these colors through col Type `source ~/.p10k.zsh` to apply your changes to the current Zsh session. -To see how different numbered colors look in your terminal, run the following command: +To see how different colors look in your terminal, run the following command: ```zsh for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done ``` -If your terminal supports truecolor, you can use 24-bit colors in the `#RRGGBB` format in addition -to the numbered colors. - -```zsh -typeset -g POWERLEVEL9K_TIME_FOREGROUND='#FF0000' -``` - -*Related:* - - [Directory is difficult to see in prompt when using Rainbow style.]( - #directory-is-difficult-to-see-in-prompt-when-using-rainbow-style) - - [Incorrect foreground color in VSCode Terminal.](#incorrect-foreground-color-in-vscode-terminal) - -By default, VSCode Terminal may arbitrarily replace the foreground color of your choice with a -different color. This behavior can be -[turned off](https://code.visualstudio.com/docs/terminal/appearance#_minimum-contrast-ratio) in -VSCode settings. - ### Why does Powerlevel10k spawn extra processes? Powerlevel10k uses [gitstatus](https://github.com/romkatv/gitstatus) as the backend behind `vcs` @@ -1372,13 +1083,26 @@ prompt latency when using Powerlevel10k, please ### Is Powerlevel10k fast to load? -Yes. See [zsh-bench](https://github.com/romkatv/zsh-bench). +Yes, provided that you are using Zsh >= 5.4. + +Loading time, or time to first prompt, can be measured with the following benchmark: + +```zsh +time (repeat 1000 zsh -dfis <<< 'source ~/powerlevel10k/powerlevel10k.zsh-theme') +``` + +*Note:* This measures time to first complete prompt. Powerlevel10k can also display a +[limited prompt](#instant-prompt) before the full-featured prompt is ready. + +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. ### What is the relationship between Powerlevel9k and Powerlevel10k? Powerlevel10k was forked from Powerlevel9k in March 2019 after a week-long discussion in [powerlevel9k#1170](https://github.com/Powerlevel9k/powerlevel9k/issues/1170). Powerlevel9k was -already a mature project with a large user base and a release cycle measured in months. Powerlevel10k +already a mature project with large user base and release cycle measured in months. Powerlevel10k was spun off to iterate on performance improvements and new features at much higher pace. Powerlevel9k and Powerlevel10k are independent projects. When using one, you shouldn't install the @@ -1484,7 +1208,7 @@ https://www.reddit.com/r/zsh/comments/eg49ff/powerlevel10k_prompt_history_exit_c ### What is the minimum supported Zsh version? -Zsh 5.3 or newer should work. Fast startup requires Zsh >= 5.4. +Zsh 5.1 or newer should work. Fast startup requires Zsh >= 5.4. ### How were these screenshots and animated gifs created? @@ -1525,51 +1249,6 @@ Powerlevel10k are released. This may change in the future but not soon. ## Troubleshooting -- [`[oh-my-zsh] theme 'powerlevel10k/powerlevel10k' not found`](#oh-my-zsh-theme-powerlevel10kpowerlevel10k-not-found) -- [Question mark in prompt](#question-mark-in-prompt) -- [Icons, glyphs or powerline symbols don't render](#icons-glyphs-or-powerline-symbols-dont-render) -- [Sub-pixel imperfections around powerline symbols](#sub-pixel-imperfections-around-powerline-symbols) -- [Error: character not in range](#error-character-not-in-range) -- [Cursor is in the wrong place](#cursor-is-in-the-wrong-place) -- [Prompt wrapping around in a weird way](#prompt-wrapping-around-in-a-weird-way) -- [Right prompt is in the wrong place](#right-prompt-is-in-the-wrong-place) -- [Configuration wizard runs automatically every time Zsh is started](#configuration-wizard-runs-automatically-every-time-zsh-is-started) -- [Some prompt styles are missing from the configuration wizard](#some-prompt-styles-are-missing-from-the-configuration-wizard) -- [Cannot install the recommended font](#cannot-install-the-recommended-font) -- [Extra or missing spaces in prompt compared to Powerlevel9k](#extra-or-missing-spaces-in-prompt-compared-to-powerlevel9k) - - [Extra space without background on the right side of right prompt](#extra-space-without-background-on-the-right-side-of-right-prompt) - - [Extra or missing spaces around icons](#extra-or-missing-spaces-around-icons) -- [Weird things happen after typing `source ~/.zshrc`](#weird-things-happen-after-typing-source-zshrc) -- [Transient prompt stops working after some time](#transient-prompt-stops-working-after-some-time) -- [Cannot make Powerlevel10k work with my plugin manager](#cannot-make-powerlevel10k-work-with-my-plugin-manager) -- [Directory is difficult to see in prompt when using Rainbow style](#directory-is-difficult-to-see-in-prompt-when-using-rainbow-style) -- [Incorrect foreground color in VSCode Terminal.](#incorrect-foreground-color-in-vscode-terminal) -- [Horrific mess when resizing terminal window](#horrific-mess-when-resizing-terminal-window) -- [Icons cut off in Konsole](#icons-cut-off-in-konsole) -- [Arch Linux logo has a dot in the bottom right corner](#arch-linux-logo-has-a-dot-in-the-bottom-right-corner) -- [Incorrect git status in prompt](#incorrect-git-status-in-prompt) - -### `[oh-my-zsh] theme 'powerlevel10k/powerlevel10k' not found` - -When opening a terminal, or starting zsh manually, you may encounter this error message: - -```text -[oh-my-zsh] theme 'powerlevel10k/powerlevel10k' not found -``` - -1. First, run `typeset -p P9K_VERSION` to check whether Powerlevel10k has been loaded. - - If `typeset -p P9K_VERSION` succeeds and prints something like `typeset P9K_VERSION=1.19.14` - (the version could be different), remove the following line from `~/.zshrc`: - ```zsh - ZSH_THEME="powerlevel10k/powerlevel10k" - ``` - - If `typeset -p P9K_VERSION` fails with the error `typeset: no such variable: P9K_VERSION`, run - the following command: - ```zsh - git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k - ``` -2. Restart Zsh with `exec zsh`. - ### Question mark in prompt If it looks like a regular `?`, that's normal. It means you have untracked files in the current Git @@ -1753,15 +1432,10 @@ and make sure that `TERM` environment variable is set correctly. Verify with If there is no UTF-8 locale on the system, configuration wizard won't offer prompt styles that use Unicode characters. *Fix*: Install a UTF-8 locale. Verify with `locale -a`. -Another case in which configuration wizard may not offer Unicode prompt styles is when the -`MULTIBYTE` shell option is disabled. *Fix*: Enable the `MULTIBYTE` option, or rather don't disable -it (this option is enabled in Zsh by default). Verify with `print -r -- ${options[MULTIBYTE]}`. - -When `MULTIBYTE` is enabled and a UTF-8 locale is available, the first few questions asked by the -configuration wizard assess capabilities of the terminal font. If your answers indicate that some -glyphs don't render correctly, configuration wizard won't offer prompt styles that use them. *Fix*: -Restart your terminal and install -[the recommended font](#meslo-nerd-font-patched-for-powerlevel10k). Verify by running +When a UTF-8 locale is available, the first few questions asked by the configuration wizard assess +capabilities of the terminal font. If your answers indicate that some glyphs don't render correctly, +configuration wizard won't offer prompt styles that use them. *Fix*: Restart your terminal and +install [the recommended font](#meslo-nerd-font-patched-for-powerlevel10k). Verify by running `p10k configure` and checking that all glyphs render correctly. ### Cannot install the recommended font @@ -1885,38 +1559,23 @@ There are several ways to fix this. The parameters you are looking for are called `POWERLEVEL9K_DIR_BACKGROUND`, `POWERLEVEL9K_DIR_FOREGROUND`, `POWERLEVEL9K_DIR_SHORTENED_FOREGROUND`, `POWERLEVEL9K_DIR_ANCHOR_FOREGROUND` and `POWERLEVEL9K_DIR_ANCHOR_BOLD`. You can find them in - `~/.p10k.zsh`. - -*Related*: [Incorrect foreground color in VSCode Terminal.](#incorrect-foreground-color-in-vscode-terminal) - -### Incorrect foreground color in VSCode Terminal - -By default, VSCode Terminal may arbitrarily replace the foreground color of your choice with a -different color. This behavior can be -[turned off](https://code.visualstudio.com/docs/terminal/appearance#_minimum-contrast-ratio) in -VSCode settings. + in `~/.p10k.zsh`. ### Horrific mess when resizing terminal window -When you resize a terminal window horizontally back and forth a few times, you might see this ugly +When you resize terminal window horizontally back and forth a few times, you might see this ugly picture. ![Powerlevel10k Resizing Mess]( https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/resizing-mess.png) -tl;dr: This issue arises when a terminal reflows Zsh prompt upon resizing. It isn't specific to -Powerlevel10k. See [mitigation](#mitigation). +tl;dr: This is a bug in Zsh that isn't specific to Powerlevel10k. See [mitigation](#mitigation). -*Note: This section [used to say]( - https://github.com/romkatv/powerlevel10k/blob/dce00cdb5daaa8a519df234a7012ba3257b644d4/README.md#horrific-mess-when-resizing-terminal-window) -that the problem is caused by a bug in Zsh. While it's true that it's possible to avoid the problem -in many circumstances by modifying Zsh, it cannot be completely resolved this way. Thus it's unfair -to pin the blame on Zsh.* +#### Zsh bug -#### The anatomy of the problem - -The issue is manifested when the vertical distance between the start of the current prompt and the -cursor (henceforth `VD`) changes when the terminal window is resized. +This issue is caused by a bug in Zsh that gets triggered when the vertical distance between the +start of the current prompt and the cursor (henceforth `VD`) changes when the terminal window is +resized. This bug is not specific to Powerlevel10k. When a terminal window gets shrunk horizontally, there are two ways for a terminal to handle long lines that no longer fit: *reflow* or *truncate*. @@ -1938,9 +1597,9 @@ Terminal truncates text when shrinking: Reflowing strategy can change the height of terminal content. If such content happens to be between the start of the current prompt and the cursor, Zsh will print prompt on the wrong line. Truncation -strategy never changes the height of terminal content, so it doesn't trigger this issue. +strategy never changes the height of terminal content, so it doesn't trigger this bug in Zsh. -Let's see how the issue plays out in slow motion. We'll start by launching `zsh -f` and pasting +Let's see how the bug plays out in slow motion. We'll start by launching `zsh -df` and pasting the following code: ```zsh @@ -1956,13 +1615,13 @@ PROMPT=$'${$((pause()))+}left>${(pl.$((COLUMNS-12))..-.)} ' When `PROMPT` gets expanded, it calls `pause` to let us observe the state of the terminal. Here's the initial state: -![Terminal Resizing Bug 1]( +![Zsh Resizing Bug 1]( https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/resize-bug-1.png) Zsh keeps track of the cursor position relative to the start of the current prompt. In this case it knows that the cursor is one line below. When we shrink the terminal window, it looks like this: -![Terminal Resizing Bug 2]( +![Zsh Resizing Bug 2]( https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/resize-bug-2.png) At this point the terminal sends `SIGWINCH` to Zsh to notify it about changes in the terminal @@ -1974,7 +1633,7 @@ terminal content that follows and prints reexpanded prompt there. However, after no longer one line above the cursor. It's two lines above! Zsh ends up printing new prompt one line too low. -![Terminal Resizing Bug 3]( +![Zsh Resizing Bug 3]( https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/resize-bug-3.png) In this case we ended up with unwanted junk content because `VD` has *increased*. When you make @@ -1983,30 +1642,33 @@ higher than intended, potentially erasing useful content in the process. Here are a few more examples where shrinking terminal window increased `VD`. -- Simple one-line left prompt with right prompt. No `prompt_subst`. Note that the cursor is below - the prompt line (hit *ESC-ENTER* to get it there). - ![Zsh Prompt That Breaks on Terminal Shrinking 1]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/resize-breakable-1.png) -- Simple one-line left prompt. No `prompt_subst`, no right prompt. Here `VD` is bound to increase - upon terminal shrinking due to the command line wrapping around. - ![Zsh Prompt That Breaks on Terminal Shrinking 2]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/resize-breakable-2.png) +Simple one-line left prompt with right prompt. No `prompt_subst`. Note that the cursor is below the +prompt line (hit *ESC-ENTER* to get it there). + +![Zsh Prompt That Breaks on Terminal Shrinking 1]( + https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/resize-breakable-1.png) + +Simple one-line left prompt. No `prompt_subst`, no right prompt. Here `VD` is bound to increase +upon terminal shrinking due to the command line wrapping around. + +![Zsh Prompt That Breaks on Terminal Shrinking 2]( + https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/resize-breakable-2.png) #### Zsh patch -[This Zsh patch](https://github.com/romkatv/zsh/tree/fix-winchanged) fixes the issue on some -terminals. The idea behind the patch is to use `sc` (save cursor) terminal capability before -printing prompt and `rc` (restore cursor) to move cursor back to the original position when prompt -needs to be refreshed. +The bug described above has been partially fixed (only for some terminals) in [this branch]( + https://github.com/romkatv/zsh/tree/fix-winchanged). The idea behind the fix is to use `sc` (save +cursor) terminal capability before printing prompt and `rc` (restore cursor) to move cursor back +to the original position when prompt needs to be refreshed. The patch works only on terminals that reflow saved cursor position together with text when the terminal window is resized. The patch has no observable effect on terminals that don't reflow text on resize (both patched and unpatched Zsh behave correctly) and on terminals that reflow text but -not the saved cursor position (both patched and unpatched Zsh redraw prompt at the same incorrect +not saved cursor position (both patched and unpatched Zsh redraw prompt at the same incorrect position). In other words, the patch fixes the resizing issue on some terminals while keeping the behavior unchanged on others. -There are two alternative approaches to patching Zsh that may seem to work at first glance but in +There are two alternative approaches to fixing the bug that may seem to work at first glance but in fact don't: - Instead of `sc`, use `u7` terminal capability to query the current cursor position and then `cup` @@ -2025,12 +1687,9 @@ There is no ETA for the patch making its way into upstream Zsh. See [discussion] There are a few mitigation options for this issue. -- Use [kitty](https://sw.kovidgoyal.net/kitty/) terminal version >= 0.24.0 and enable terminal-shell - integration in Powerlevel10k by defining `POWERLEVEL9K_TERM_SHELL_INTEGRATION=true` in - `~/.p10k.zsh`. - Apply [the patch](#zsh-patch) and [rebuild Zsh from source]( https://github.com/zsh-users/zsh/blob/master/INSTALL). It won't help if you are using Alacritty, - kitty or some other terminal that reflows text on resize but doesn't reflow saved cursor position. + Kitty or some other terminal that reflows text on resize but doesn't reflow saved cursor position. On such terminals the patch will have no visible effect. - Disable text reflowing on window resize in terminal settings. If your terminal doesn't have this setting, try a different terminal. @@ -2093,15 +1752,88 @@ Some fonts have this incorrect dotted icon in bold typeface. There are two ways typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='${P9K_CONTENT}' # not bold ``` -### Incorrect git status in prompt +## Table of contents -Powerlevel10k uses [gitstatusd](https://github.com/romkatv/gitstatus) to inspect the state of git -repositories. The project relies on the [libgit2](https://github.com/libgit2/libgit2) library, which -has some gaps in its implementation. Under some conditions, this may result in discrepancies between -the real state of a git repository (reflected by `git status`) and what gets shown in the -Powerlevel10k prompt. - -Most notably, [libgit2 does not support `skipHash`](https://github.com/libgit2/libgit2/issues/6531). -If you see incorrect git status in prompt, run `git config -l` and check whether `skipHash` is -enabled. If it is, consider disabling it. Keep in mind that `skipHash` may be implicitly enabled -when activating certain git features, such as `manyFiles`. +- [Features](#features) + - [Configuration wizard](#configuration-wizard) + - [Uncompromising performance](#uncompromising-performance) + - [Powerlevel9k compatibility](#powerlevel9k-compatibility) + - [Pure compatibility](#pure-compatibility) + - [Instant prompt](#instant-prompt) + - [Show on command](#show-on-command) + - [Transient prompt](#transient-prompt) + - [Current directory that just works](#current-directory-that-just-works) + - [Extremely customizable](#extremely-customizable) + - [Batteries included](#batteries-included) + - [Extensible](#extensible) +- [Installation](#installation) + - [Manual](#manual) + - [Oh My Zsh](#oh-my-zsh) + - [Prezto](#prezto) + - [Zim](#zim) + - [Antibody](#antibody) + - [Antigen](#antigen) + - [Zplug](#zplug) + - [Zgen](#zgen) + - [Zplugin](#zplugin) + - [Zinit](#zinit) + - [Homebrew](#homebrew) + - [Arch Linux](#arch-linux) +- [Configuration](#configuration) + - [For new users](#for-new-users) + - [For Powerlevel9k users](#for-powerlevel9k-users) +- [Fonts](#fonts) + - [Meslo Nerd Font patched for Powerlevel10k](#meslo-nerd-font-patched-for-powerlevel10k) + - [Automatic font installation](#automatic-font-installation) + - [Manual font installation](#manual-font-installation) +- [Try it in Docker](#try-it-in-docker) +- [License](#license) +- [FAQ](#faq) + - [How do I update Powerlevel10k?](#how-do-i-update-powerlevel10k) + - [How do I uninstall Powerlevel10k?](#how-do-i-uninstall-powerlevel10k) + - [How do I install Powerlevel10k on a machine without Internet access?](#how-do-i-install-powerlevel10k-on-a-machine-without-internet-access) + - [Where can I ask for help and report bugs?](#where-can-i-ask-for-help-and-report-bugs) + - [Which aspects of shell and terminal does Powerlevel10k affect?](#which-aspects-of-shell-and-terminal-does-powerlevel10k-affect) + - [I'm using Powerlevel9k with Oh My Zsh. How do I migrate?](#im-using-powerlevel9k-with-oh-my-zsh-how-do-i-migrate) + - [Is it really fast?](#is-it-really-fast) + - [How do I enable instant prompt?](#how-do-i-enable-instant-prompt) + - [What do different symbols in Git status mean?](#what-do-different-symbols-in-git-status-mean) + - [How do I change the format of Git status?](#how-do-i-change-the-format-of-git-status) + - [Why is Git status from `$HOME/.git` not displayed in prompt?](#why-is-git-status-from-homegit-not-displayed-in-prompt) + - [Why does Git status sometimes appear grey and then gets colored after a short period of time?](#why-does-git-status-sometimes-appear-grey-and-then-gets-colored-after-a-short-period-of-time) + - [How do I add username and/or hostname to prompt?](#how-do-i-add-username-andor-hostname-to-prompt) + - [Why some prompt segments appear and disappear as I'm typing?](#why-some-prompt-segments-appear-and-disappear-as-im-typing) + - [How do I change prompt colors?](#how-do-i-change-prompt-colors) + - [Why does Powerlevel10k spawn extra processes?](#why-does-powerlevel10k-spawn-extra-processes) + - [Are there configuration options that make Powerlevel10k slow?](#are-there-configuration-options-that-make-powerlevel10k-slow) + - [Is Powerlevel10k fast to load?](#is-powerlevel10k-fast-to-load) + - [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) + - [What is the minimum supported Zsh version?](#what-is-the-minimum-supported-zsh-version) + - [How were these screenshots and animated gifs created?](#how-were-these-screenshots-and-animated-gifs-created) + - [How was the recommended font created?](#how-was-the-recommended-font-created) + - [How to package Powerlevel10k for distribution?](#how-to-package-powerlevel10k-for-distribution) +- [Troubleshooting](#troubleshooting) + - [Question mark in prompt](#question-mark-in-prompt) + - [Icons, glyphs or powerline symbols don't render](#icons-glyphs-or-powerline-symbols-dont-render) + - [Sub-pixel imperfections around powerline symbols](#sub-pixel-imperfections-around-powerline-symbols) + - [Error: character not in range](#error-character-not-in-range) + - [Cursor is in the wrong place](#cursor-is-in-the-wrong-place) + - [Prompt wrapping around in a weird way](#prompt-wrapping-around-in-a-weird-way) + - [Right prompt is in the wrong place](#right-prompt-is-in-the-wrong-place) + - [Configuration wizard runs automatically every time Zsh is started](#configuration-wizard-runs-automatically-every-time-zsh-is-started) + - [Some prompt styles are missing from the configuration wizard](#some-prompt-styles-are-missing-from-the-configuration-wizard) + - [Cannot install the recommended font](#cannot-install-the-recommended-font) + - [Extra or missing spaces in prompt compared to Powerlevel9k](#extra-or-missing-spaces-in-prompt-compared-to-powerlevel9k) + - [Extra space without background on the right side of right prompt](#extra-space-without-background-on-the-right-side-of-right-prompt) + - [Extra or missing spaces around icons](#extra-or-missing-spaces-around-icons) + - [Weird things happen after typing `source ~/.zshrc`](#weird-things-happen-after-typing-source-zshrc) + - [Transient prompt stops working after some time](#transient-prompt-stops-working-after-some-time) + - [Cannot make Powerlevel10k work with my plugin manager](#cannot-make-powerlevel10k-work-with-my-plugin-manager) + - [Directory is difficult to see in prompt when using Rainbow style](#directory-is-difficult-to-see-in-prompt-when-using-rainbow-style) + - [Horrific mess when resizing terminal window](#horrific-mess-when-resizing-terminal-window) + - [Icons cut off in Konsole](#icons-cut-off-in-konsole) + - [Arch Linux logo has a dot in the bottom right corner](#arch-linux-logo-has-a-dot-in-the-bottom-right-corner) diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh index d7be6722..8bb7e4df 100644 --- a/config/p10k-classic.zsh +++ b/config/p10k-classic.zsh @@ -20,7 +20,7 @@ unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR' # Zsh >= 5.1 is required. - [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return + autoload -Uz is-at-least && is-at-least 5.1 || return # The list of segments shown on the left. Fill it with the most important segments. typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( @@ -65,30 +65,23 @@ 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) - perlbrew # perl version from perlbrew (https://github.com/gugod/App-perlbrew) phpenv # php version from phpenv (https://github.com/phpenv/phpenv) scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv) haskell_stack # haskell version from stack (https://haskellstack.org/) kubecontext # current kubernetes context (https://kubernetes.io/) terraform # terraform workspace (https://www.terraform.io) - # terraform_version # terraform version (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) gcloud # google cloud cli account and project (https://cloud.google.com/) google_app_cred # google application credentials (https://cloud.google.com/docs/authentication/production) - toolbox # toolbox name (https://github.com/containers/toolbox) context # user@hostname nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) - yazi # yazi shell (https://github.com/sxyazi/yazi) nnn # nnn shell (https://github.com/jarun/nnn) - lf # lf shell (https://github.com/gokcehan/lf) - xplr # xplr shell (https://github.com/sayanarijit/xplr) vim_shell # vim shell indicator (:sh) midnight_commander # midnight commander shell (https://midnight-commander.org/) nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) - chezmoi_shell # chezmoi shell (https://www.chezmoi.io/) # vi_mode # vi mode (you don't need this if you've enabled prompt_char) # vpn_ip # virtual private network indicator # load # CPU load @@ -98,8 +91,6 @@ todo # todo items (https://github.com/todotxt/todo.txt-cli) timewarrior # timewarrior tracking status (https://timewarrior.net/) taskwarrior # taskwarrior task count (https://taskwarrior.org/) - per_directory_history # Oh My Zsh per-directory-history local/global indicator - # cpu_arch # CPU architecture # time # current time # =========================[ Line #2 ]========================= newline # \n @@ -146,7 +137,7 @@ # 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 this option. + # 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= typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_GAP_BACKGROUND= @@ -171,9 +162,6 @@ typeset -g POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\uE0B0' # Separator between different-color segments on the right. typeset -g POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR='\uE0B2' - # To remove a separator between two segments, add "_joined" to the second segment name. - # For example: POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(os_icon context_joined) - # The right end of left prompt. typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='\uE0B0' # The left end of right prompt. @@ -243,7 +231,7 @@ .java-version .perl-version .php-version - .tool-versions + .tool-version .shorten_folder_marker .svn .terraform @@ -349,7 +337,7 @@ # typeset -g POWERLEVEL9K_DIR_PREFIX='%248Fin ' #####################################[ vcs: git status ]###################################### - # Branch icon. Set this parameter to '\UE0A0 ' 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. @@ -358,7 +346,7 @@ # Formatter for Git status. # - # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42. + # Example output: master ⇣42⇡42 *42 merge ~42 +42 !42 ?42. # # You can edit the function to customize how Git status looks. # @@ -416,7 +404,7 @@ # Display the current Git commit if there is no branch and no tag. # Tip: To always display the current Git commit, delete the next line. - [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line + [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_LOCAL_BRANCH ]] && # <-- this line res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" # Show tracking branch name if it differs from local branch. @@ -424,22 +412,11 @@ res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" fi - # Display "wip" if the latest commit's summary contains "wip" or "WIP". - if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then - res+=" ${modified}wip" - fi - - if (( VCS_STATUS_COMMITS_AHEAD || VCS_STATUS_COMMITS_BEHIND )); then - # ⇣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}" - elif [[ -n $VCS_STATUS_REMOTE_BRANCH ]]; then - # Tip: Uncomment the next line to display '=' if up to date with the remote. - # res+=" ${clean}=" - 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 behind the push remote. (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " @@ -729,12 +706,6 @@ typeset -g POWERLEVEL9K_RANGER_FOREGROUND=178 # Custom icon. # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ####################[ yazi: yazi shell (https://github.com/sxyazi/yazi) ]##################### - # Yazi shell color. - typeset -g POWERLEVEL9K_YAZI_FOREGROUND=178 - # Custom icon. - # typeset -g POWERLEVEL9K_YAZI_VISUAL_IDENTIFIER_EXPANSION='⭐' ######################[ nnn: nnn shell (https://github.com/jarun/nnn) ]####################### # Nnn shell color. @@ -742,18 +713,6 @@ # Custom icon. # typeset -g POWERLEVEL9K_NNN_VISUAL_IDENTIFIER_EXPANSION='⭐' - ######################[ lf: lf shell (https://github.com/gokcehan/lf) ]####################### - # lf shell color. - typeset -g POWERLEVEL9K_LF_FOREGROUND=72 - # Custom icon. - # typeset -g POWERLEVEL9K_LF_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##################[ xplr: xplr shell (https://github.com/sayanarijit/xplr) ]################## - # xplr shell color. - typeset -g POWERLEVEL9K_XPLR_FOREGROUND=72 - # Custom icon. - # typeset -g POWERLEVEL9K_XPLR_VISUAL_IDENTIFIER_EXPANSION='⭐' - ###########################[ vim_shell: vim shell indicator (:sh) ]########################### # Vim shell indicator color. typeset -g POWERLEVEL9K_VIM_SHELL_FOREGROUND=34 @@ -770,21 +729,12 @@ # Nix shell color. typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=74 - # Display the icon of nix_shell if PATH contains a subdirectory of /nix/store. - # typeset -g POWERLEVEL9K_NIX_SHELL_INFER_FROM_PATH=false - # Tip: If you want to see just the icon without "pure" and "impure", uncomment the next line. # typeset -g POWERLEVEL9K_NIX_SHELL_CONTENT_EXPANSION= # Custom icon. # typeset -g POWERLEVEL9K_NIX_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - ##################[ chezmoi_shell: chezmoi shell (https://www.chezmoi.io/) ]################## - # chezmoi shell color. - typeset -g POWERLEVEL9K_CHEZMOI_SHELL_FOREGROUND=33 - # Custom icon. - # typeset -g POWERLEVEL9K_CHEZMOI_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - ##################################[ disk_usage: disk usage ]################################## # Colors for different levels of disk usage. typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_FOREGROUND=35 @@ -811,8 +761,9 @@ # Text and color for insert vi mode. typeset -g POWERLEVEL9K_VI_INSERT_MODE_STRING= typeset -g POWERLEVEL9K_VI_MODE_INSERT_FOREGROUND=66 + # Custom icon. - # typeset -g POWERLEVEL9K_VI_MODE_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' ######################################[ ram: free RAM ]####################################### # RAM color. @@ -894,30 +845,6 @@ # Custom icon. # typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' - ######[ per_directory_history: Oh My Zsh per-directory-history local/global indicator ]####### - # Color when using local/global history. - typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_FOREGROUND=135 - typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_FOREGROUND=130 - - # Tip: Uncomment the next two lines to hide "local"/"global" text and leave just the icon. - # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_CONTENT_EXPANSION='' - # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_CONTENT_EXPANSION='' - - # Custom icon. - # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################################[ cpu_arch: CPU architecture ]################################ - # CPU architecture color. - typeset -g POWERLEVEL9K_CPU_ARCH_FOREGROUND=172 - - # Hide the segment when on a specific CPU architecture. - # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_CONTENT_EXPANSION= - # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_VISUAL_IDENTIFIER_EXPANSION= - - # Custom icon. - # typeset -g POWERLEVEL9K_CPU_ARCH_VISUAL_IDENTIFIER_EXPANSION='⭐' - ##################################[ context: user@hostname ]################################## # Context color when running with privileges. typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178 @@ -1006,10 +933,10 @@ # # The default format has the following logic: # - # 1. Display just "$P9K_CONTENT" if it's equal to "$P9K_PYENV_PYTHON_VERSION" or - # starts with "$P9K_PYENV_PYTHON_VERSION/". - # 2. Otherwise display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION". - typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_CONTENT:#$P9K_PYENV_PYTHON_VERSION(|/*)}:+ $P9K_PYENV_PYTHON_VERSION}' + # 1. Display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION" if $P9K_PYENV_PYTHON_VERSION is not + # empty and unequal to $P9K_CONTENT. + # 2. Otherwise display just "$P9K_CONTENT". + typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_PYENV_PYTHON_VERSION:#$P9K_CONTENT}:+ $P9K_PYENV_PYTHON_VERSION}' # Custom icon. # typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='⭐' @@ -1043,11 +970,6 @@ ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### # Nvm color. typeset -g POWERLEVEL9K_NVM_FOREGROUND=70 - # If set to false, hide node version if it's the same as default: - # $(nvm version current) == $(nvm version default). - typeset -g POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW=false - # If set to false, hide node version if it's equal to "system". - typeset -g POWERLEVEL9K_NVM_SHOW_SYSTEM=true # Custom icon. # typeset -g POWERLEVEL9K_NVM_VISUAL_IDENTIFIER_EXPANSION='⭐' @@ -1197,16 +1119,6 @@ # Custom icon. # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - ###########[ perlbrew: perl version from perlbrew (https://github.com/gugod/App-perlbrew) ]############ - # Perlbrew color. - typeset -g POWERLEVEL9K_PERLBREW_FOREGROUND=67 - # Show perlbrew version only when in a perl project subdirectory. - typeset -g POWERLEVEL9K_PERLBREW_PROJECT_ONLY=true - # Don't show "perl-" at the front. - typeset -g POWERLEVEL9K_PERLBREW_SHOW_PREFIX=false - # Custom icon. - # typeset -g POWERLEVEL9K_PERLBREW_VISUAL_IDENTIFIER_EXPANSION='⭐' - ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ # PHP color. typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=99 @@ -1280,16 +1192,10 @@ typeset -g POWERLEVEL9K_TERRAFORM_OTHER_FOREGROUND=38 # typeset -g POWERLEVEL9K_TERRAFORM_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' - #############[ terraform_version: terraform version (https://www.terraform.io) ]############## - # Terraform version color. - typeset -g POWERLEVEL9K_TERRAFORM_VERSION_FOREGROUND=38 - # Custom icon. - # typeset -g POWERLEVEL9K_TERRAFORM_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# - # Show kubecontext only when the command you are typing invokes one of these tools. + # Show kubecontext only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show kubecontext. - typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern|kubeseal|skaffold|kubent|kubecolor|cmctl|sparkctl' + typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile' # Kubernetes context classes for the purpose of using different colors, icons and expansions with # different contexts. @@ -1374,9 +1280,9 @@ # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%248Fat ' #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]# - # Show aws only when the command you are typing invokes one of these tools. + # Show aws only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show aws. - typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|cdk|terraform|pulumi|terragrunt' + typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|terraform|pulumi|terragrunt' # POWERLEVEL9K_AWS_CLASSES is an array with even number of elements. The first element # in each pair defines a pattern against which the current AWS profile gets matched. @@ -1408,12 +1314,6 @@ typeset -g POWERLEVEL9K_AWS_DEFAULT_FOREGROUND=208 # typeset -g POWERLEVEL9K_AWS_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' - # AWS segment format. The following parameters are available within the expansion. - # - # - P9K_AWS_PROFILE The name of the current AWS profile. - # - P9K_AWS_REGION The region associated with the current AWS profile. - typeset -g POWERLEVEL9K_AWS_CONTENT_EXPANSION='${P9K_AWS_PROFILE//\%/%%}${P9K_AWS_REGION:+ ${P9K_AWS_REGION//\%/%%}}' - #[ 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 @@ -1421,47 +1321,18 @@ # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐' ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## - # Show azure only when the command you are typing invokes one of these tools. + # Show azure only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show azure. typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt' - - # POWERLEVEL9K_AZURE_CLASSES is an array with even number of elements. The first element - # in each pair defines a pattern against which the current azure account name 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_AZURE_*CONTENT_EXPANSION parameters, - # you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_AZURE_CLASSES defines the account class. Patterns are tried in order. The - # first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_AZURE_CLASSES=( - # '*prod*' PROD - # '*test*' TEST - # '*' OTHER) - # - # If your current azure account is "company_test", its class is TEST because "company_test" - # 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_AZURE_TEST_FOREGROUND=28 - # typeset -g POWERLEVEL9K_AZURE_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_AZURE_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' - typeset -g POWERLEVEL9K_AZURE_CLASSES=( - # '*prod*' PROD # These values are examples that are unlikely - # '*test*' TEST # to match your needs. Customize them as needed. - '*' OTHER) - # Azure account name color. - typeset -g POWERLEVEL9K_AZURE_OTHER_FOREGROUND=32 + typeset -g POWERLEVEL9K_AZURE_FOREGROUND=32 # Custom icon. - # typeset -g POWERLEVEL9K_AZURE_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### - # Show gcloud only when the command you are typing invokes one of these tools. + # Show gcloud only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show gcloud. - typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil' + typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs' # Google cloud color. typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=32 @@ -1500,7 +1371,7 @@ # typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐' #[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]# - # Show google_app_cred only when the command you are typing invokes one of these tools. + # Show google_app_cred only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show google_app_cred. typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt' @@ -1553,16 +1424,6 @@ # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced by '%%'. typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}' - ##############[ toolbox: toolbox name (https://github.com/containers/toolbox) ]############### - # Toolbox color. - typeset -g POWERLEVEL9K_TOOLBOX_FOREGROUND=178 - # Don't display the name of the toolbox if it matches fedora-toolbox-*. - typeset -g POWERLEVEL9K_TOOLBOX_CONTENT_EXPANSION='${P9K_TOOLBOX_NAME:#fedora-toolbox-*}' - # Custom icon. - # typeset -g POWERLEVEL9K_TOOLBOX_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_TOOLBOX_PREFIX='%248Fin ' - ###############################[ public_ip: public IP address ]############################### # Public IP color. typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=94 @@ -1577,7 +1438,7 @@ typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION= # Regular expression for the VPN network interface. Run `ifconfig` or `ip -4 a show` while on VPN # to see the name of the interface. - typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*|(zt.*)' + typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*' # If set to true, show one segment per matching network interface. If set to false, show only # one segment corresponding to the first matching network interface. # Tip: If you set it to true, you'll probably want to unset POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION. @@ -1591,15 +1452,13 @@ # The following parameters are accessible within the expansion: # # Parameter | Meaning - # ----------------------+------------------------------------------- - # P9K_IP_IP | IP address - # P9K_IP_INTERFACE | network interface - # P9K_IP_RX_BYTES | total number of bytes received - # P9K_IP_TX_BYTES | total number of bytes sent - # P9K_IP_RX_BYTES_DELTA | number of bytes received since last prompt - # P9K_IP_TX_BYTES_DELTA | number of bytes sent since last prompt - # P9K_IP_RX_RATE | receive rate (since last prompt) - # P9K_IP_TX_RATE | send rate (since last prompt) + # ----------------------+--------------- + # P9K_IP_IP | IP address + # P9K_IP_INTERFACE | network interface + # P9K_IP_RX_BYTES | total number of bytes received + # P9K_IP_TX_BYTES | total number of bytes sent + # P9K_IP_RX_RATE | receive rate (since last prompt) + # P9K_IP_TX_RATE | send rate (since last prompt) typeset -g POWERLEVEL9K_IP_CONTENT_EXPANSION='${P9K_IP_RX_RATE:+%70F⇣$P9K_IP_RX_RATE }${P9K_IP_TX_RATE:+%215F⇡$P9K_IP_TX_RATE }%38F$P9K_IP_IP' # Show information for the first network interface whose name matches this regular expression. # Run `ifconfig` or `ip -4 a show` to see the names of all network interfaces. @@ -1677,7 +1536,7 @@ # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job # is to generate the prompt segment for display in instant prompt. See - # https://github.com/romkatv/powerlevel10k#instant-prompt. + # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. # # Powerlevel10k will call instant_prompt_* at the same time as the regular prompt_* function # and will record all `p10k segment` calls it makes. When displaying instant prompt, Powerlevel10k @@ -1713,7 +1572,7 @@ # 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#instant-prompt. + # 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. diff --git a/config/p10k-lean-8colors.zsh b/config/p10k-lean-8colors.zsh index bf469df7..2b1eabca 100644 --- a/config/p10k-lean-8colors.zsh +++ b/config/p10k-lean-8colors.zsh @@ -20,7 +20,7 @@ unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR' # Zsh >= 5.1 is required. - [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return + autoload -Uz is-at-least && is-at-least 5.1 || return # The list of segments shown on the left. Fill it with the most important segments. typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( @@ -65,30 +65,23 @@ 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) - perlbrew # perl version from perlbrew (https://github.com/gugod/App-perlbrew) phpenv # php version from phpenv (https://github.com/phpenv/phpenv) scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv) haskell_stack # haskell version from stack (https://haskellstack.org/) kubecontext # current kubernetes context (https://kubernetes.io/) terraform # terraform workspace (https://www.terraform.io) - # terraform_version # terraform version (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) gcloud # google cloud cli account and project (https://cloud.google.com/) google_app_cred # google application credentials (https://cloud.google.com/docs/authentication/production) - toolbox # toolbox name (https://github.com/containers/toolbox) context # user@hostname nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) - yazi # yazi shell (https://github.com/sxyazi/yazi) nnn # nnn shell (https://github.com/jarun/nnn) - lf # lf shell (https://github.com/gokcehan/lf) - xplr # xplr shell (https://github.com/sayanarijit/xplr) vim_shell # vim shell indicator (:sh) midnight_commander # midnight commander shell (https://midnight-commander.org/) nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) - chezmoi_shell # chezmoi shell (https://www.chezmoi.io/) # vpn_ip # virtual private network indicator # load # CPU load # disk_usage # disk usage @@ -97,8 +90,6 @@ todo # todo items (https://github.com/todotxt/todo.txt-cli) timewarrior # timewarrior tracking status (https://timewarrior.net/) taskwarrior # taskwarrior task count (https://taskwarrior.org/) - per_directory_history # Oh My Zsh per-directory-history local/global indicator - # cpu_arch # CPU architecture # time # current time # =========================[ Line #2 ]========================= newline # \n @@ -234,7 +225,7 @@ .java-version .perl-version .php-version - .tool-versions + .tool-version .shorten_folder_marker .svn .terraform @@ -277,6 +268,10 @@ # the full directory that was used in previous commands. typeset -g POWERLEVEL9K_DIR_HYPERLINK=false + # Enable special styling for non-writable directories. See POWERLEVEL9K_LOCK_ICON and + # POWERLEVEL9K_DIR_CLASSES below. + typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v2 + # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON # and POWERLEVEL9K_DIR_CLASSES below. typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3 @@ -340,7 +335,7 @@ # typeset -g POWERLEVEL9K_DIR_PREFIX='%fin ' #####################################[ vcs: git status ]###################################### - # Branch icon. Set this parameter to '\UE0A0 ' 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. @@ -349,7 +344,7 @@ # Formatter for Git status. # - # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42. + # Example output: master ⇣42⇡42 *42 merge ~42 +42 !42 ?42. # # You can edit the function to customize how Git status looks. # @@ -407,7 +402,7 @@ # Display the current Git commit if there is no branch and no tag. # Tip: To always display the current Git commit, delete the next line. - [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line + [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_LOCAL_BRANCH ]] && # <-- this line res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" # Show tracking branch name if it differs from local branch. @@ -415,22 +410,11 @@ res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" fi - # Display "wip" if the latest commit's summary contains "wip" or "WIP". - if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then - res+=" ${modified}wip" - fi - - if (( VCS_STATUS_COMMITS_AHEAD || VCS_STATUS_COMMITS_BEHIND )); then - # ⇣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}" - elif [[ -n $VCS_STATUS_REMOTE_BRANCH ]]; then - # Tip: Uncomment the next line to display '=' if up to date with the remote. - # res+=" ${clean}=" - 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 behind the push remote. (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " @@ -493,7 +477,7 @@ # 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 repository. + # isn't in an svn or hg reposotiry. typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) # These settings are used for repositories other than Git or when gitstatusd fails and @@ -720,12 +704,6 @@ typeset -g POWERLEVEL9K_RANGER_FOREGROUND=3 # Custom icon. # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ####################[ yazi: yazi shell (https://github.com/sxyazi/yazi) ]##################### - # Yazi shell color. - typeset -g POWERLEVEL9K_YAZI_FOREGROUND=3 - # Custom icon. - # typeset -g POWERLEVEL9K_YAZI_VISUAL_IDENTIFIER_EXPANSION='⭐' ######################[ nnn: nnn shell (https://github.com/jarun/nnn) ]####################### # Nnn shell color. @@ -733,18 +711,6 @@ # Custom icon. # typeset -g POWERLEVEL9K_NNN_VISUAL_IDENTIFIER_EXPANSION='⭐' - ######################[ lf: lf shell (https://github.com/gokcehan/lf) ]####################### - # lf shell color. - typeset -g POWERLEVEL9K_LF_FOREGROUND=3 - # Custom icon. - # typeset -g POWERLEVEL9K_LF_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##################[ xplr: xplr shell (https://github.com/sayanarijit/xplr) ]################## - # xplr shell color. - typeset -g POWERLEVEL9K_XPLR_FOREGROUND=3 - # Custom icon. - # typeset -g POWERLEVEL9K_XPLR_VISUAL_IDENTIFIER_EXPANSION='⭐' - ###########################[ vim_shell: vim shell indicator (:sh) ]########################### # Vim shell indicator color. typeset -g POWERLEVEL9K_VIM_SHELL_FOREGROUND=3 @@ -761,21 +727,12 @@ # Nix shell color. typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=4 - # Display the icon of nix_shell if PATH contains a subdirectory of /nix/store. - # typeset -g POWERLEVEL9K_NIX_SHELL_INFER_FROM_PATH=false - # Tip: If you want to see just the icon without "pure" and "impure", uncomment the next line. # typeset -g POWERLEVEL9K_NIX_SHELL_CONTENT_EXPANSION= # Custom icon. # typeset -g POWERLEVEL9K_NIX_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - ##################[ chezmoi_shell: chezmoi shell (https://www.chezmoi.io/) ]################## - # chezmoi shell color. - typeset -g POWERLEVEL9K_CHEZMOI_SHELL_FOREGROUND=4 - # Custom icon. - # typeset -g POWERLEVEL9K_CHEZMOI_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - ##################################[ disk_usage: disk usage ]################################## # Colors for different levels of disk usage. typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_FOREGROUND=2 @@ -869,30 +826,6 @@ # Custom icon. # typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' - ######[ per_directory_history: Oh My Zsh per-directory-history local/global indicator ]####### - # Color when using local/global history. - typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_FOREGROUND=5 - typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_FOREGROUND=3 - - # Tip: Uncomment the next two lines to hide "local"/"global" text and leave just the icon. - # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_CONTENT_EXPANSION='' - # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_CONTENT_EXPANSION='' - - # Custom icon. - # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################################[ cpu_arch: CPU architecture ]################################ - # CPU architecture color. - typeset -g POWERLEVEL9K_CPU_ARCH_FOREGROUND=3 - - # Hide the segment when on a specific CPU architecture. - # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_CONTENT_EXPANSION= - # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_VISUAL_IDENTIFIER_EXPANSION= - - # Custom icon. - # typeset -g POWERLEVEL9K_CPU_ARCH_VISUAL_IDENTIFIER_EXPANSION='⭐' - ##################################[ context: user@hostname ]################################## # Context color when running with privileges. typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=1 @@ -981,10 +914,10 @@ # # The default format has the following logic: # - # 1. Display just "$P9K_CONTENT" if it's equal to "$P9K_PYENV_PYTHON_VERSION" or - # starts with "$P9K_PYENV_PYTHON_VERSION/". - # 2. Otherwise display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION". - typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_CONTENT:#$P9K_PYENV_PYTHON_VERSION(|/*)}:+ $P9K_PYENV_PYTHON_VERSION}' + # 1. Display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION" if $P9K_PYENV_PYTHON_VERSION is not + # empty and unequal to $P9K_CONTENT. + # 2. Otherwise display just "$P9K_CONTENT". + typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_PYENV_PYTHON_VERSION:#$P9K_CONTENT}:+ $P9K_PYENV_PYTHON_VERSION}' # Custom icon. # typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='⭐' @@ -1018,11 +951,6 @@ ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### # Nvm color. typeset -g POWERLEVEL9K_NVM_FOREGROUND=2 - # If set to false, hide node version if it's the same as default: - # $(nvm version current) == $(nvm version default). - typeset -g POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW=false - # If set to false, hide node version if it's equal to "system". - typeset -g POWERLEVEL9K_NVM_SHOW_SYSTEM=true # Custom icon. # typeset -g POWERLEVEL9K_NVM_VISUAL_IDENTIFIER_EXPANSION='⭐' @@ -1172,16 +1100,6 @@ # Custom icon. # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - ###########[ perlbrew: perl version from perlbrew (https://github.com/gugod/App-perlbrew) ]############ - # Perlbrew color. - typeset -g POWERLEVEL9K_PERLBREW_FOREGROUND=67 - # Show perlbrew version only when in a perl project subdirectory. - typeset -g POWERLEVEL9K_PERLBREW_PROJECT_ONLY=true - # Don't show "perl-" at the front. - typeset -g POWERLEVEL9K_PERLBREW_SHOW_PREFIX=false - # Custom icon. - # typeset -g POWERLEVEL9K_PERLBREW_VISUAL_IDENTIFIER_EXPANSION='⭐' - ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ # PHP color. typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=5 @@ -1223,9 +1141,9 @@ # typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐' #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# - # Show kubecontext only when the command you are typing invokes one of these tools. + # Show kubecontext only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show kubecontext. - typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern|kubeseal|skaffold|kubent|kubecolor|cmctl|sparkctl' + typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile' # Kubernetes context classes for the purpose of using different colors, icons and expansions with # different contexts. @@ -1342,16 +1260,10 @@ typeset -g POWERLEVEL9K_TERRAFORM_OTHER_FOREGROUND=4 # typeset -g POWERLEVEL9K_TERRAFORM_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' - #############[ terraform_version: terraform version (https://www.terraform.io) ]############## - # Terraform version color. - typeset -g POWERLEVEL9K_TERRAFORM_VERSION_FOREGROUND=4 - # Custom icon. - # typeset -g POWERLEVEL9K_TERRAFORM_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]# - # Show aws only when the command you are typing invokes one of these tools. + # Show aws only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show aws. - typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|cdk|terraform|pulumi|terragrunt' + typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|terraform|pulumi|terragrunt' # POWERLEVEL9K_AWS_CLASSES is an array with even number of elements. The first element # in each pair defines a pattern against which the current AWS profile gets matched. @@ -1383,12 +1295,6 @@ typeset -g POWERLEVEL9K_AWS_DEFAULT_FOREGROUND=3 # typeset -g POWERLEVEL9K_AWS_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' - # AWS segment format. The following parameters are available within the expansion. - # - # - P9K_AWS_PROFILE The name of the current AWS profile. - # - P9K_AWS_REGION The region associated with the current AWS profile. - typeset -g POWERLEVEL9K_AWS_CONTENT_EXPANSION='${P9K_AWS_PROFILE//\%/%%}${P9K_AWS_REGION:+ ${P9K_AWS_REGION//\%/%%}}' - #[ 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 @@ -1396,47 +1302,18 @@ # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐' ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## - # Show azure only when the command you are typing invokes one of these tools. + # Show azure only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show azure. typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt' - - # POWERLEVEL9K_AZURE_CLASSES is an array with even number of elements. The first element - # in each pair defines a pattern against which the current azure account name 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_AZURE_*CONTENT_EXPANSION parameters, - # you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_AZURE_CLASSES defines the account class. Patterns are tried in order. The - # first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_AZURE_CLASSES=( - # '*prod*' PROD - # '*test*' TEST - # '*' OTHER) - # - # If your current azure account is "company_test", its class is TEST because "company_test" - # 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_AZURE_TEST_FOREGROUND=2 - # typeset -g POWERLEVEL9K_AZURE_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_AZURE_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' - typeset -g POWERLEVEL9K_AZURE_CLASSES=( - # '*prod*' PROD # These values are examples that are unlikely - # '*test*' TEST # to match your needs. Customize them as needed. - '*' OTHER) - # Azure account name color. - typeset -g POWERLEVEL9K_AZURE_OTHER_FOREGROUND=4 + typeset -g POWERLEVEL9K_AZURE_FOREGROUND=4 # Custom icon. - # typeset -g POWERLEVEL9K_AZURE_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### - # Show gcloud only when the command you are typing invokes one of these tools. + # Show gcloud only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show gcloud. - typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil' + typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs' # Google cloud color. typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=4 @@ -1475,7 +1352,7 @@ # typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐' #[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]# - # Show google_app_cred only when the command you are typing invokes one of these tools. + # Show google_app_cred only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show google_app_cred. typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt' @@ -1528,16 +1405,6 @@ # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced by '%%'. typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}' - ##############[ toolbox: toolbox name (https://github.com/containers/toolbox) ]############### - # Toolbox color. - typeset -g POWERLEVEL9K_TOOLBOX_FOREGROUND=3 - # Don't display the name of the toolbox if it matches fedora-toolbox-*. - typeset -g POWERLEVEL9K_TOOLBOX_CONTENT_EXPANSION='${P9K_TOOLBOX_NAME:#fedora-toolbox-*}' - # Custom icon. - # typeset -g POWERLEVEL9K_TOOLBOX_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_TOOLBOX_PREFIX='%fin ' - ###############################[ public_ip: public IP address ]############################### # Public IP color. typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=6 @@ -1552,7 +1419,7 @@ typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION= # Regular expression for the VPN network interface. Run `ifconfig` or `ip -4 a show` while on VPN # to see the name of the interface. - typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*|(zt.*)' + typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*' # If set to true, show one segment per matching network interface. If set to false, show only # one segment corresponding to the first matching network interface. # Tip: If you set it to true, you'll probably want to unset POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION. @@ -1566,15 +1433,13 @@ # The following parameters are accessible within the expansion: # # Parameter | Meaning - # ----------------------+------------------------------------------- - # P9K_IP_IP | IP address - # P9K_IP_INTERFACE | network interface - # P9K_IP_RX_BYTES | total number of bytes received - # P9K_IP_TX_BYTES | total number of bytes sent - # P9K_IP_RX_BYTES_DELTA | number of bytes received since last prompt - # P9K_IP_TX_BYTES_DELTA | number of bytes sent since last prompt - # P9K_IP_RX_RATE | receive rate (since last prompt) - # P9K_IP_TX_RATE | send rate (since last prompt) + # ----------------------+--------------- + # P9K_IP_IP | IP address + # P9K_IP_INTERFACE | network interface + # P9K_IP_RX_BYTES | total number of bytes received + # P9K_IP_TX_BYTES | total number of bytes sent + # P9K_IP_RX_RATE | receive rate (since last prompt) + # P9K_IP_TX_RATE | send rate (since last prompt) typeset -g POWERLEVEL9K_IP_CONTENT_EXPANSION='$P9K_IP_IP${P9K_IP_RX_RATE:+ %2F⇣$P9K_IP_RX_RATE}${P9K_IP_TX_RATE:+ %3F⇡$P9K_IP_TX_RATE}' # Show information for the first network interface whose name matches this regular expression. # Run `ifconfig` or `ip -4 a show` to see the names of all network interfaces. @@ -1652,7 +1517,7 @@ # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job # is to generate the prompt segment for display in instant prompt. See - # https://github.com/romkatv/powerlevel10k#instant-prompt. + # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. # # Powerlevel10k will call instant_prompt_* at the same time as the regular prompt_* function # and will record all `p10k segment` calls it makes. When displaying instant prompt, Powerlevel10k @@ -1688,7 +1553,7 @@ # 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#instant-prompt. + # 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. diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh index 1595a377..dd6fd959 100644 --- a/config/p10k-lean.zsh +++ b/config/p10k-lean.zsh @@ -20,7 +20,7 @@ unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR' # Zsh >= 5.1 is required. - [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return + autoload -Uz is-at-least && is-at-least 5.1 || return # The list of segments shown on the left. Fill it with the most important segments. typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( @@ -65,30 +65,23 @@ 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) - perlbrew # perl version from perlbrew (https://github.com/gugod/App-perlbrew) phpenv # php version from phpenv (https://github.com/phpenv/phpenv) scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv) haskell_stack # haskell version from stack (https://haskellstack.org/) kubecontext # current kubernetes context (https://kubernetes.io/) terraform # terraform workspace (https://www.terraform.io) - # terraform_version # terraform version (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) gcloud # google cloud cli account and project (https://cloud.google.com/) google_app_cred # google application credentials (https://cloud.google.com/docs/authentication/production) - toolbox # toolbox name (https://github.com/containers/toolbox) context # user@hostname nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) - yazi # yazi shell (https://github.com/sxyazi/yazi) nnn # nnn shell (https://github.com/jarun/nnn) - lf # lf shell (https://github.com/gokcehan/lf) - xplr # xplr shell (https://github.com/sayanarijit/xplr) vim_shell # vim shell indicator (:sh) midnight_commander # midnight commander shell (https://midnight-commander.org/) nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) - chezmoi_shell # chezmoi shell (https://www.chezmoi.io/) # vpn_ip # virtual private network indicator # load # CPU load # disk_usage # disk usage @@ -97,8 +90,6 @@ todo # todo items (https://github.com/todotxt/todo.txt-cli) timewarrior # timewarrior tracking status (https://timewarrior.net/) taskwarrior # taskwarrior task count (https://taskwarrior.org/) - per_directory_history # Oh My Zsh per-directory-history local/global indicator - # cpu_arch # CPU architecture # time # current time # =========================[ Line #2 ]========================= newline @@ -234,7 +225,7 @@ .java-version .perl-version .php-version - .tool-versions + .tool-version .shorten_folder_marker .svn .terraform @@ -340,7 +331,7 @@ # typeset -g POWERLEVEL9K_DIR_PREFIX='%fin ' #####################################[ vcs: git status ]###################################### - # Branch icon. Set this parameter to '\UE0A0 ' 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. @@ -349,7 +340,7 @@ # Formatter for Git status. # - # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42. + # Example output: master ⇣42⇡42 *42 merge ~42 +42 !42 ?42. # # You can edit the function to customize how Git status looks. # @@ -407,7 +398,7 @@ # Display the current Git commit if there is no branch and no tag. # Tip: To always display the current Git commit, delete the next line. - [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line + [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_LOCAL_BRANCH ]] && # <-- this line res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" # Show tracking branch name if it differs from local branch. @@ -415,22 +406,11 @@ res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" fi - # Display "wip" if the latest commit's summary contains "wip" or "WIP". - if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then - res+=" ${modified}wip" - fi - - if (( VCS_STATUS_COMMITS_AHEAD || VCS_STATUS_COMMITS_BEHIND )); then - # ⇣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}" - elif [[ -n $VCS_STATUS_REMOTE_BRANCH ]]; then - # Tip: Uncomment the next line to display '=' if up to date with the remote. - # res+=" ${clean}=" - 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 behind the push remote. (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " @@ -493,7 +473,7 @@ # 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 repository. + # isn't in an svn or hg reposotiry. typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) # These settings are used for repositories other than Git or when gitstatusd fails and @@ -720,12 +700,6 @@ typeset -g POWERLEVEL9K_RANGER_FOREGROUND=178 # Custom icon. # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ####################[ yazi: yazi shell (https://github.com/sxyazi/yazi) ]##################### - # Yazi shell color. - typeset -g POWERLEVEL9K_YAZI_FOREGROUND=178 - # Custom icon. - # typeset -g POWERLEVEL9K_YAZI_VISUAL_IDENTIFIER_EXPANSION='⭐' ######################[ nnn: nnn shell (https://github.com/jarun/nnn) ]####################### # Nnn shell color. @@ -733,18 +707,6 @@ # Custom icon. # typeset -g POWERLEVEL9K_NNN_VISUAL_IDENTIFIER_EXPANSION='⭐' - ######################[ lf: lf shell (https://github.com/gokcehan/lf) ]####################### - # lf shell color. - typeset -g POWERLEVEL9K_LF_FOREGROUND=72 - # Custom icon. - # typeset -g POWERLEVEL9K_LF_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##################[ xplr: xplr shell (https://github.com/sayanarijit/xplr) ]################## - # xplr shell color. - typeset -g POWERLEVEL9K_XPLR_FOREGROUND=72 - # Custom icon. - # typeset -g POWERLEVEL9K_XPLR_VISUAL_IDENTIFIER_EXPANSION='⭐' - ###########################[ vim_shell: vim shell indicator (:sh) ]########################### # Vim shell indicator color. typeset -g POWERLEVEL9K_VIM_SHELL_FOREGROUND=34 @@ -761,21 +723,12 @@ # Nix shell color. typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=74 - # Display the icon of nix_shell if PATH contains a subdirectory of /nix/store. - # typeset -g POWERLEVEL9K_NIX_SHELL_INFER_FROM_PATH=false - # Tip: If you want to see just the icon without "pure" and "impure", uncomment the next line. # typeset -g POWERLEVEL9K_NIX_SHELL_CONTENT_EXPANSION= # Custom icon. # typeset -g POWERLEVEL9K_NIX_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - ##################[ chezmoi_shell: chezmoi shell (https://www.chezmoi.io/) ]################## - # chezmoi shell color. - typeset -g POWERLEVEL9K_CHEZMOI_SHELL_FOREGROUND=33 - # Custom icon. - # typeset -g POWERLEVEL9K_CHEZMOI_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - ##################################[ disk_usage: disk usage ]################################## # Colors for different levels of disk usage. typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_FOREGROUND=35 @@ -869,30 +822,6 @@ # Custom icon. # typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' - ######[ per_directory_history: Oh My Zsh per-directory-history local/global indicator ]####### - # Color when using local/global history. - typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_FOREGROUND=135 - typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_FOREGROUND=130 - - # Tip: Uncomment the next two lines to hide "local"/"global" text and leave just the icon. - # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_CONTENT_EXPANSION='' - # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_CONTENT_EXPANSION='' - - # Custom icon. - # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################################[ cpu_arch: CPU architecture ]################################ - # CPU architecture color. - typeset -g POWERLEVEL9K_CPU_ARCH_FOREGROUND=172 - - # Hide the segment when on a specific CPU architecture. - # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_CONTENT_EXPANSION= - # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_VISUAL_IDENTIFIER_EXPANSION= - - # Custom icon. - # typeset -g POWERLEVEL9K_CPU_ARCH_VISUAL_IDENTIFIER_EXPANSION='⭐' - ##################################[ context: user@hostname ]################################## # Context color when running with privileges. typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178 @@ -981,10 +910,10 @@ # # The default format has the following logic: # - # 1. Display just "$P9K_CONTENT" if it's equal to "$P9K_PYENV_PYTHON_VERSION" or - # starts with "$P9K_PYENV_PYTHON_VERSION/". - # 2. Otherwise display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION". - typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_CONTENT:#$P9K_PYENV_PYTHON_VERSION(|/*)}:+ $P9K_PYENV_PYTHON_VERSION}' + # 1. Display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION" if $P9K_PYENV_PYTHON_VERSION is not + # empty and unequal to $P9K_CONTENT. + # 2. Otherwise display just "$P9K_CONTENT". + typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_PYENV_PYTHON_VERSION:#$P9K_CONTENT}:+ $P9K_PYENV_PYTHON_VERSION}' # Custom icon. # typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='⭐' @@ -1018,11 +947,6 @@ ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]############### # Nvm color. typeset -g POWERLEVEL9K_NVM_FOREGROUND=70 - # If set to false, hide node version if it's the same as default: - # $(nvm version current) == $(nvm version default). - typeset -g POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW=false - # If set to false, hide node version if it's equal to "system". - typeset -g POWERLEVEL9K_NVM_SHOW_SYSTEM=true # Custom icon. # typeset -g POWERLEVEL9K_NVM_VISUAL_IDENTIFIER_EXPANSION='⭐' @@ -1172,16 +1096,6 @@ # Custom icon. # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - ###########[ perlbrew: perl version from perlbrew (https://github.com/gugod/App-perlbrew) ]############ - # Perlbrew color. - typeset -g POWERLEVEL9K_PERLBREW_FOREGROUND=67 - # Show perlbrew version only when in a perl project subdirectory. - typeset -g POWERLEVEL9K_PERLBREW_PROJECT_ONLY=true - # Don't show "perl-" at the front. - typeset -g POWERLEVEL9K_PERLBREW_SHOW_PREFIX=false - # Custom icon. - # typeset -g POWERLEVEL9K_PERLBREW_VISUAL_IDENTIFIER_EXPANSION='⭐' - ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ # PHP color. typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=99 @@ -1223,9 +1137,9 @@ # typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐' #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# - # Show kubecontext only when the command you are typing invokes one of these tools. + # Show kubecontext only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show kubecontext. - typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern|kubeseal|skaffold|kubent|kubecolor|cmctl|sparkctl' + typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile' # Kubernetes context classes for the purpose of using different colors, icons and expansions with # different contexts. @@ -1342,16 +1256,10 @@ typeset -g POWERLEVEL9K_TERRAFORM_OTHER_FOREGROUND=38 # typeset -g POWERLEVEL9K_TERRAFORM_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' - #############[ terraform_version: terraform version (https://www.terraform.io) ]############## - # Terraform version color. - typeset -g POWERLEVEL9K_TERRAFORM_VERSION_FOREGROUND=38 - # Custom icon. - # typeset -g POWERLEVEL9K_TERRAFORM_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]# - # Show aws only when the command you are typing invokes one of these tools. + # Show aws only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show aws. - typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|cdk|terraform|pulumi|terragrunt' + typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|terraform|pulumi|terragrunt' # POWERLEVEL9K_AWS_CLASSES is an array with even number of elements. The first element # in each pair defines a pattern against which the current AWS profile gets matched. @@ -1383,12 +1291,6 @@ typeset -g POWERLEVEL9K_AWS_DEFAULT_FOREGROUND=208 # typeset -g POWERLEVEL9K_AWS_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' - # AWS segment format. The following parameters are available within the expansion. - # - # - P9K_AWS_PROFILE The name of the current AWS profile. - # - P9K_AWS_REGION The region associated with the current AWS profile. - typeset -g POWERLEVEL9K_AWS_CONTENT_EXPANSION='${P9K_AWS_PROFILE//\%/%%}${P9K_AWS_REGION:+ ${P9K_AWS_REGION//\%/%%}}' - #[ 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 @@ -1396,47 +1298,18 @@ # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐' ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## - # Show azure only when the command you are typing invokes one of these tools. + # Show azure only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show azure. typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt' - - # POWERLEVEL9K_AZURE_CLASSES is an array with even number of elements. The first element - # in each pair defines a pattern against which the current azure account name 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_AZURE_*CONTENT_EXPANSION parameters, - # you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_AZURE_CLASSES defines the account class. Patterns are tried in order. The - # first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_AZURE_CLASSES=( - # '*prod*' PROD - # '*test*' TEST - # '*' OTHER) - # - # If your current azure account is "company_test", its class is TEST because "company_test" - # 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_AZURE_TEST_FOREGROUND=28 - # typeset -g POWERLEVEL9K_AZURE_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_AZURE_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' - typeset -g POWERLEVEL9K_AZURE_CLASSES=( - # '*prod*' PROD # These values are examples that are unlikely - # '*test*' TEST # to match your needs. Customize them as needed. - '*' OTHER) - # Azure account name color. - typeset -g POWERLEVEL9K_AZURE_OTHER_FOREGROUND=32 + typeset -g POWERLEVEL9K_AZURE_FOREGROUND=32 # Custom icon. - # typeset -g POWERLEVEL9K_AZURE_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### - # Show gcloud only when the command you are typing invokes one of these tools. + # Show gcloud only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show gcloud. - typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil' + typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs' # Google cloud color. typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=32 @@ -1475,7 +1348,7 @@ # typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐' #[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]# - # Show google_app_cred only when the command you are typing invokes one of these tools. + # Show google_app_cred only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show google_app_cred. typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt' @@ -1528,16 +1401,6 @@ # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced by '%%'. typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}' - ##############[ toolbox: toolbox name (https://github.com/containers/toolbox) ]############### - # Toolbox color. - typeset -g POWERLEVEL9K_TOOLBOX_FOREGROUND=178 - # Don't display the name of the toolbox if it matches fedora-toolbox-*. - typeset -g POWERLEVEL9K_TOOLBOX_CONTENT_EXPANSION='${P9K_TOOLBOX_NAME:#fedora-toolbox-*}' - # Custom icon. - # typeset -g POWERLEVEL9K_TOOLBOX_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_TOOLBOX_PREFIX='%fin ' - ###############################[ public_ip: public IP address ]############################### # Public IP color. typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=94 @@ -1552,7 +1415,7 @@ typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION= # Regular expression for the VPN network interface. Run `ifconfig` or `ip -4 a show` while on VPN # to see the name of the interface. - typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*|(zt.*)' + typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*' # If set to true, show one segment per matching network interface. If set to false, show only # one segment corresponding to the first matching network interface. # Tip: If you set it to true, you'll probably want to unset POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION. @@ -1566,15 +1429,13 @@ # The following parameters are accessible within the expansion: # # Parameter | Meaning - # ----------------------+------------------------------------------- - # P9K_IP_IP | IP address - # P9K_IP_INTERFACE | network interface - # P9K_IP_RX_BYTES | total number of bytes received - # P9K_IP_TX_BYTES | total number of bytes sent - # P9K_IP_RX_BYTES_DELTA | number of bytes received since last prompt - # P9K_IP_TX_BYTES_DELTA | number of bytes sent since last prompt - # P9K_IP_RX_RATE | receive rate (since last prompt) - # P9K_IP_TX_RATE | send rate (since last prompt) + # ----------------------+--------------- + # P9K_IP_IP | IP address + # P9K_IP_INTERFACE | network interface + # P9K_IP_RX_BYTES | total number of bytes received + # P9K_IP_TX_BYTES | total number of bytes sent + # P9K_IP_RX_RATE | receive rate (since last prompt) + # P9K_IP_TX_RATE | send rate (since last prompt) typeset -g POWERLEVEL9K_IP_CONTENT_EXPANSION='$P9K_IP_IP${P9K_IP_RX_RATE:+ %70F⇣$P9K_IP_RX_RATE}${P9K_IP_TX_RATE:+ %215F⇡$P9K_IP_TX_RATE}' # Show information for the first network interface whose name matches this regular expression. # Run `ifconfig` or `ip -4 a show` to see the names of all network interfaces. @@ -1652,7 +1513,7 @@ # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job # is to generate the prompt segment for display in instant prompt. See - # https://github.com/romkatv/powerlevel10k#instant-prompt. + # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. # # Powerlevel10k will call instant_prompt_* at the same time as the regular prompt_* function # and will record all `p10k segment` calls it makes. When displaying instant prompt, Powerlevel10k @@ -1688,7 +1549,7 @@ # 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#instant-prompt. + # 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. diff --git a/config/p10k-pure.zsh b/config/p10k-pure.zsh index 7a4d2441..566c030d 100644 --- a/config/p10k-pure.zsh +++ b/config/p10k-pure.zsh @@ -29,7 +29,7 @@ unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR' # Zsh >= 5.1 is required. - [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return + autoload -Uz is-at-least && is-at-least 5.1 || return # Prompt colors. local grey=242 @@ -169,7 +169,7 @@ # 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#instant-prompt. + # 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. diff --git a/config/p10k-rainbow.zsh b/config/p10k-rainbow.zsh index 355ee9bb..318792eb 100644 --- a/config/p10k-rainbow.zsh +++ b/config/p10k-rainbow.zsh @@ -20,7 +20,7 @@ unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR' # Zsh >= 5.1 is required. - [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return + autoload -Uz is-at-least && is-at-least 5.1 || return # The list of segments shown on the left. Fill it with the most important segments. typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=( @@ -65,30 +65,23 @@ 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) - perlbrew # perl version from perlbrew (https://github.com/gugod/App-perlbrew) phpenv # php version from phpenv (https://github.com/phpenv/phpenv) scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv) haskell_stack # haskell version from stack (https://haskellstack.org/) kubecontext # current kubernetes context (https://kubernetes.io/) terraform # terraform workspace (https://www.terraform.io) - # terraform_version # terraform version (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) gcloud # google cloud cli account and project (https://cloud.google.com/) google_app_cred # google application credentials (https://cloud.google.com/docs/authentication/production) - toolbox # toolbox name (https://github.com/containers/toolbox) context # user@hostname nordvpn # nordvpn connection status, linux only (https://nordvpn.com/) ranger # ranger shell (https://github.com/ranger/ranger) - yazi # yazi shell (https://github.com/sxyazi/yazi) nnn # nnn shell (https://github.com/jarun/nnn) - lf # lf shell (https://github.com/gokcehan/lf) - xplr # xplr shell (https://github.com/sayanarijit/xplr) vim_shell # vim shell indicator (:sh) midnight_commander # midnight commander shell (https://midnight-commander.org/) nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) - chezmoi_shell # chezmoi shell (https://www.chezmoi.io/) # vi_mode # vi mode (you don't need this if you've enabled prompt_char) # vpn_ip # virtual private network indicator # load # CPU load @@ -98,8 +91,6 @@ todo # todo items (https://github.com/todotxt/todo.txt-cli) timewarrior # timewarrior tracking status (https://timewarrior.net/) taskwarrior # taskwarrior task count (https://taskwarrior.org/) - per_directory_history # Oh My Zsh per-directory-history local/global indicator - # cpu_arch # CPU architecture # time # current time # =========================[ Line #2 ]========================= newline @@ -146,7 +137,7 @@ # 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 this option. + # 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= typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_GAP_BACKGROUND= @@ -168,9 +159,6 @@ typeset -g POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\uE0B0' # Separator between different-color segments on the right. typeset -g POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR='\uE0B2' - # To remove a separator between two segments, add "_joined" to the second segment name. - # For example: POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(os_icon context_joined) - # The right end of left prompt. typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL='\uE0B0' # The left end of right prompt. @@ -243,7 +231,7 @@ .java-version .perl-version .php-version - .tool-versions + .tool-version .shorten_folder_marker .svn .terraform @@ -352,14 +340,14 @@ # typeset -g POWERLEVEL9K_DIR_PREFIX='in ' #####################################[ vcs: git status ]###################################### - # Version control background colors. + # Version 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 '\UE0A0 ' 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. @@ -368,7 +356,7 @@ # Formatter for Git status. # - # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42. + # Example output: master ⇣42⇡42 *42 merge ~42 +42 !42 ?42. # # You can edit the function to customize how Git status looks. # @@ -417,7 +405,7 @@ # Display the current Git commit if there is no branch and no tag. # Tip: To always display the current Git commit, delete the next line. - [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line + [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_LOCAL_BRANCH ]] && # <-- this line res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}" # Show tracking branch name if it differs from local branch. @@ -425,22 +413,11 @@ res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" fi - # Display "wip" if the latest commit's summary contains "wip" or "WIP". - if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then - res+=" ${modified}wip" - fi - - if (( VCS_STATUS_COMMITS_AHEAD || VCS_STATUS_COMMITS_BEHIND )); then - # ⇣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}" - elif [[ -n $VCS_STATUS_REMOTE_BRANCH ]]; then - # Tip: Uncomment the next line to display '=' if up to date with the remote. - # res+=" ${clean}=" - 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 behind the push remote. (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}" (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" " @@ -499,7 +476,7 @@ # 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 repository. + # isn't in an svn or hg reposotiry. typeset -g POWERLEVEL9K_VCS_BACKENDS=(git) ##########################[ status: exit code of the last command ]########################### @@ -748,14 +725,7 @@ typeset -g POWERLEVEL9K_RANGER_BACKGROUND=0 # Custom icon. # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ####################[ yazi: yazi shell (https://github.com/sxyazi/yazi) ]##################### - # Yazi shell color. - typeset -g POWERLEVEL9K_YAZI_FOREGROUND=3 - typeset -g POWERLEVEL9K_YAZI_BACKGROUND=0 - # Custom icon. - # typeset -g POWERLEVEL9K_YAZI_VISUAL_IDENTIFIER_EXPANSION='⭐' - + ######################[ nnn: nnn shell (https://github.com/jarun/nnn) ]####################### # Nnn shell color. typeset -g POWERLEVEL9K_NNN_FOREGROUND=0 @@ -763,20 +733,6 @@ # Custom icon. # typeset -g POWERLEVEL9K_NNN_VISUAL_IDENTIFIER_EXPANSION='⭐' - ######################[ lf: lf shell (https://github.com/gokcehan/lf) ]####################### - # lf shell color. - typeset -g POWERLEVEL9K_LF_FOREGROUND=0 - typeset -g POWERLEVEL9K_LF_BACKGROUND=6 - # Custom icon. - # typeset -g POWERLEVEL9K_LF_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ##################[ xplr: xplr shell (https://github.com/sayanarijit/xplr) ]################## - # xplr shell color. - typeset -g POWERLEVEL9K_XPLR_FOREGROUND=0 - typeset -g POWERLEVEL9K_XPLR_BACKGROUND=6 - # Custom icon. - # typeset -g POWERLEVEL9K_XPLR_VISUAL_IDENTIFIER_EXPANSION='⭐' - ###########################[ vim_shell: vim shell indicator (:sh) ]########################### # Vim shell indicator color. typeset -g POWERLEVEL9K_VIM_SHELL_FOREGROUND=0 @@ -796,22 +752,12 @@ typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=0 typeset -g POWERLEVEL9K_NIX_SHELL_BACKGROUND=4 - # Display the icon of nix_shell if PATH contains a subdirectory of /nix/store. - # typeset -g POWERLEVEL9K_NIX_SHELL_INFER_FROM_PATH=false - # Tip: If you want to see just the icon without "pure" and "impure", uncomment the next line. # typeset -g POWERLEVEL9K_NIX_SHELL_CONTENT_EXPANSION= # Custom icon. # typeset -g POWERLEVEL9K_NIX_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - ##################[ chezmoi_shell: chezmoi shell (https://www.chezmoi.io/) ]################## - # chezmoi shell color. - typeset -g POWERLEVEL9K_CHEZMOI_SHELL_FOREGROUND=0 - typeset -g POWERLEVEL9K_CHEZMOI_SHELL_BACKGROUND=4 - # Custom icon. - # typeset -g POWERLEVEL9K_CHEZMOI_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐' - ##################################[ disk_usage: disk usage ]################################## # Colors for different levels of disk usage. typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_FOREGROUND=3 @@ -843,8 +789,6 @@ # Text and color for insert vi mode. typeset -g POWERLEVEL9K_VI_INSERT_MODE_STRING= typeset -g POWERLEVEL9K_VI_MODE_INSERT_FOREGROUND=8 - # Custom icon. - # typeset -g POWERLEVEL9K_VI_MODE_VISUAL_IDENTIFIER_EXPANSION='⭐' ######################################[ ram: free RAM ]####################################### # RAM color. @@ -935,33 +879,6 @@ # Custom icon. # typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐' - ######[ per_directory_history: Oh My Zsh per-directory-history local/global indicator ]####### - # Color when using local/global history. - typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_FOREGROUND=0 - typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_BACKGROUND=5 - typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_FOREGROUND=0 - typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_BACKGROUND=3 - - # Tip: Uncomment the next two lines to hide "local"/"global" text and leave just the icon. - # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_CONTENT_EXPANSION='' - # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_CONTENT_EXPANSION='' - - # Custom icon. - # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################################[ cpu_arch: CPU architecture ]################################ - # CPU architecture color. - typeset -g POWERLEVEL9K_CPU_ARCH_FOREGROUND=0 - typeset -g POWERLEVEL9K_CPU_ARCH_BACKGROUND=3 - - # Hide the segment when on a specific CPU architecture. - # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_CONTENT_EXPANSION= - # typeset -g POWERLEVEL9K_CPU_ARCH_X86_64_VISUAL_IDENTIFIER_EXPANSION= - - # Custom icon. - # typeset -g POWERLEVEL9K_CPU_ARCH_VISUAL_IDENTIFIER_EXPANSION='⭐' - ##################################[ context: user@hostname ]################################## # Context color when running with privileges. typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=1 @@ -1056,10 +973,10 @@ # # The default format has the following logic: # - # 1. Display just "$P9K_CONTENT" if it's equal to "$P9K_PYENV_PYTHON_VERSION" or - # starts with "$P9K_PYENV_PYTHON_VERSION/". - # 2. Otherwise display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION". - typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_CONTENT:#$P9K_PYENV_PYTHON_VERSION(|/*)}:+ $P9K_PYENV_PYTHON_VERSION}' + # 1. Display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION" if $P9K_PYENV_PYTHON_VERSION is not + # empty and unequal to $P9K_CONTENT. + # 2. Otherwise display just "$P9K_CONTENT". + typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_PYENV_PYTHON_VERSION:#$P9K_CONTENT}:+ $P9K_PYENV_PYTHON_VERSION}' # Custom icon. # typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='⭐' @@ -1096,11 +1013,6 @@ # Nvm color. typeset -g POWERLEVEL9K_NVM_FOREGROUND=0 typeset -g POWERLEVEL9K_NVM_BACKGROUND=5 - # If set to false, hide node version if it's the same as default: - # $(nvm version current) == $(nvm version default). - typeset -g POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW=false - # If set to false, hide node version if it's equal to "system". - typeset -g POWERLEVEL9K_NVM_SHOW_SYSTEM=true # Custom icon. # typeset -g POWERLEVEL9K_NVM_VISUAL_IDENTIFIER_EXPANSION='⭐' @@ -1267,16 +1179,6 @@ # Custom icon. # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' - ###########[ perlbrew: perl version from perlbrew (https://github.com/gugod/App-perlbrew) ]############ - # Perlbrew color. - typeset -g POWERLEVEL9K_PERLBREW_FOREGROUND=67 - # Show perlbrew version only when in a perl project subdirectory. - typeset -g POWERLEVEL9K_PERLBREW_PROJECT_ONLY=true - # Don't show "perl-" at the front. - typeset -g POWERLEVEL9K_PERLBREW_SHOW_PREFIX=false - # Custom icon. - # typeset -g POWERLEVEL9K_PERLBREW_VISUAL_IDENTIFIER_EXPANSION='⭐' - ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############ # PHP color. typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=0 @@ -1356,20 +1258,10 @@ typeset -g POWERLEVEL9K_TERRAFORM_OTHER_BACKGROUND=0 # typeset -g POWERLEVEL9K_TERRAFORM_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' - #############[ terraform_version: terraform version (https://www.terraform.io) ]############## - # Terraform version color. - typeset -g POWERLEVEL9K_TERRAFORM_VERSION_FOREGROUND=4 - typeset -g POWERLEVEL9K_TERRAFORM_VERSION_BACKGROUND=0 - # Custom icon. - # typeset -g POWERLEVEL9K_TERRAFORM_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐' - - ################[ terraform_version: It shows active terraform version (https://www.terraform.io) ]################# - typeset -g POWERLEVEL9K_TERRAFORM_VERSION_SHOW_ON_COMMAND='terraform|tf' - #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# - # Show kubecontext only when the command you are typing invokes one of these tools. + # Show kubecontext only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show kubecontext. - typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern|kubeseal|skaffold|kubent|kubecolor|cmctl|sparkctl' + typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile' # Kubernetes context classes for the purpose of using different colors, icons and expansions with # different contexts. @@ -1456,9 +1348,9 @@ # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='at ' #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]# - # Show aws only when the command you are typing invokes one of these tools. + # Show aws only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show aws. - typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|cdk|terraform|pulumi|terragrunt' + typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|terraform|pulumi|terragrunt' # POWERLEVEL9K_AWS_CLASSES is an array with even number of elements. The first element # in each pair defines a pattern against which the current AWS profile gets matched. @@ -1491,12 +1383,6 @@ typeset -g POWERLEVEL9K_AWS_DEFAULT_BACKGROUND=1 # typeset -g POWERLEVEL9K_AWS_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐' - # AWS segment format. The following parameters are available within the expansion. - # - # - P9K_AWS_PROFILE The name of the current AWS profile. - # - P9K_AWS_REGION The region associated with the current AWS profile. - typeset -g POWERLEVEL9K_AWS_CONTENT_EXPANSION='${P9K_AWS_PROFILE//\%/%%}${P9K_AWS_REGION:+ ${P9K_AWS_REGION//\%/%%}}' - #[ 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 @@ -1505,49 +1391,19 @@ # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐' ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]########## - # Show azure only when the command you are typing invokes one of these tools. + # Show azure only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show azure. typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt' - - # POWERLEVEL9K_AZURE_CLASSES is an array with even number of elements. The first element - # in each pair defines a pattern against which the current azure account name 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_AZURE_*CONTENT_EXPANSION parameters, - # you'll see this value in your prompt. The second element of each pair in - # POWERLEVEL9K_AZURE_CLASSES defines the account class. Patterns are tried in order. The - # first match wins. - # - # For example, given these settings: - # - # typeset -g POWERLEVEL9K_AZURE_CLASSES=( - # '*prod*' PROD - # '*test*' TEST - # '*' OTHER) - # - # If your current azure account is "company_test", its class is TEST because "company_test" - # 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_AZURE_TEST_FOREGROUND=2 - # typeset -g POWERLEVEL9K_AZURE_TEST_BACKGROUND=0 - # typeset -g POWERLEVEL9K_AZURE_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐' - # typeset -g POWERLEVEL9K_AZURE_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <' - typeset -g POWERLEVEL9K_AZURE_CLASSES=( - # '*prod*' PROD # These values are examples that are unlikely - # '*test*' TEST # to match your needs. Customize them as needed. - '*' OTHER) - # Azure account name color. - typeset -g POWERLEVEL9K_AZURE_OTHER_FOREGROUND=7 - typeset -g POWERLEVEL9K_AZURE_OTHER_BACKGROUND=4 + typeset -g POWERLEVEL9K_AZURE_FOREGROUND=7 + typeset -g POWERLEVEL9K_AZURE_BACKGROUND=4 # Custom icon. - # typeset -g POWERLEVEL9K_AZURE_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐' + # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐' ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]########### - # Show gcloud only when the command you are typing invokes one of these tools. + # Show gcloud only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show gcloud. - typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil' + typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs' # Google cloud color. typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=7 typeset -g POWERLEVEL9K_GCLOUD_BACKGROUND=4 @@ -1587,7 +1443,7 @@ # typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐' #[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]# - # Show google_app_cred only when the command you are typing invokes one of these tools. + # Show google_app_cred only when the the command you are typing invokes one of these tools. # Tip: Remove the next line to always show google_app_cred. typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt' @@ -1641,17 +1497,6 @@ # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced by '%%'. typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}' - ##############[ toolbox: toolbox name (https://github.com/containers/toolbox) ]############### - # Toolbox color. - typeset -g POWERLEVEL9K_TOOLBOX_FOREGROUND=0 - typeset -g POWERLEVEL9K_TOOLBOX_BACKGROUND=3 - # Don't display the name of the toolbox if it matches fedora-toolbox-*. - typeset -g POWERLEVEL9K_TOOLBOX_CONTENT_EXPANSION='${P9K_TOOLBOX_NAME:#fedora-toolbox-*}' - # Custom icon. - # typeset -g POWERLEVEL9K_TOOLBOX_VISUAL_IDENTIFIER_EXPANSION='⭐' - # Custom prefix. - # typeset -g POWERLEVEL9K_TOOLBOX_PREFIX='in ' - ###############################[ public_ip: public IP address ]############################### # Public IP color. typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=7 @@ -1668,7 +1513,7 @@ typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION= # Regular expression for the VPN network interface. Run `ifconfig` or `ip -4 a show` while on VPN # to see the name of the interface. - typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*|(zt.*)' + typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*' # If set to true, show one segment per matching network interface. If set to false, show only # one segment corresponding to the first matching network interface. # Tip: If you set it to true, you'll probably want to unset POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION. @@ -1683,15 +1528,13 @@ # The following parameters are accessible within the expansion: # # Parameter | Meaning - # ----------------------+------------------------------------------- - # P9K_IP_IP | IP address - # P9K_IP_INTERFACE | network interface - # P9K_IP_RX_BYTES | total number of bytes received - # P9K_IP_TX_BYTES | total number of bytes sent - # P9K_IP_RX_BYTES_DELTA | number of bytes received since last prompt - # P9K_IP_TX_BYTES_DELTA | number of bytes sent since last prompt - # P9K_IP_RX_RATE | receive rate (since last prompt) - # P9K_IP_TX_RATE | send rate (since last prompt) + # ----------------------+--------------- + # P9K_IP_IP | IP address + # P9K_IP_INTERFACE | network interface + # P9K_IP_RX_BYTES | total number of bytes received + # P9K_IP_TX_BYTES | total number of bytes sent + # P9K_IP_RX_RATE | receive rate (since last prompt) + # P9K_IP_TX_RATE | send rate (since last prompt) typeset -g POWERLEVEL9K_IP_CONTENT_EXPANSION='${P9K_IP_RX_RATE:+⇣$P9K_IP_RX_RATE }${P9K_IP_TX_RATE:+⇡$P9K_IP_TX_RATE }$P9K_IP_IP' # Show information for the first network interface whose name matches this regular expression. # Run `ifconfig` or `ip -4 a show` to see the names of all network interfaces. @@ -1774,7 +1617,7 @@ # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job # is to generate the prompt segment for display in instant prompt. See - # https://github.com/romkatv/powerlevel10k#instant-prompt. + # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt. # # Powerlevel10k will call instant_prompt_* at the same time as the regular prompt_* function # and will record all `p10k segment` calls it makes. When displaying instant prompt, Powerlevel10k @@ -1811,7 +1654,7 @@ # 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#instant-prompt. + # 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. diff --git a/config/p10k-robbyrussell.zsh b/config/p10k-robbyrussell.zsh index 6a204d29..a4cb8b2d 100644 --- a/config/p10k-robbyrussell.zsh +++ b/config/p10k-robbyrussell.zsh @@ -24,7 +24,7 @@ unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR' # Zsh >= 5.1 is required. - [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return + autoload -Uz is-at-least && is-at-least 5.1 || return # Left prompt segments. typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(prompt_char dir vcs) @@ -87,7 +87,7 @@ # 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#instant-prompt. + # 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. diff --git a/font.md b/font.md index 7a7cb005..b7fa4564 100644 --- a/font.md +++ b/font.md @@ -8,160 +8,81 @@ systems. *FAQ*: [How was the recommended font created?](README.md#how-was-the-recommended-font-created) -## Automatic font installation +#### Automatic font installation If you are using iTerm2 or Termux, `p10k configure` can install the recommended font for you. Simply answer `Yes` when asked whether to install *Meslo Nerd Font*. If you are using a different terminal, proceed with manual font installation. 👇 -## Manual font installation +#### Manual font installation -1. Download these four ttf files: - - [MesloLGS NF Regular.ttf]( - https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf) - - [MesloLGS NF Bold.ttf]( - https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf) - - [MesloLGS NF Italic.ttf]( - https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf) - - [MesloLGS NF Bold Italic.ttf]( - https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf) -1. Double-click on each file and click "Install". This will make `MesloLGS NF` font available to all - applications on your system. -1. Configure your terminal to use this font: - - **iTerm2**: Type `p10k configure` and answer `Yes` when asked whether to install - *Meslo Nerd Font*. Alternatively, open *iTerm2 → Preferences → Profiles → Text* and set *Font* to - `MesloLGS NF`. - - **Apple Terminal**: Open *Terminal → Preferences → Profiles → Text*, click *Change* under *Font* - and select `MesloLGS NF` family. - - **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* (PC) or - *Code → Preferences → Settings* (Mac), enter `terminal.integrated.fontFamily` in the search box at - the top of *Settings* tab and set the value below to `MesloLGS NF`. - Consult [this screenshot]( - https://raw.githubusercontent.com/romkatv/powerlevel10k-media/389133fb8c9a2347929a23702ce3039aacc46c3d/visual-studio-code-font-settings.jpg) - to see how it should look like or see [this issue]( - https://github.com/romkatv/powerlevel10k/issues/671) for extra information. - - **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** by Microsoft (the new thing): Open *Settings* (Ctrl+,), click - either on the selected profile under *Profiles* or on *Defaults*, click *Appearance* and set - *Font face* to `MesloLGS NF`. - - **Conemu**: Open *Setup → General → Fonts* and set *Main console font* to `MesloLGS NF`. - - **IntelliJ** (and other IDEs by Jet Brains): Open *IDE → Edit → Preferences → Editor → - Color Scheme → Console Font*. Select *Use console font instead of the default* and set the font - name to `MesloLGS NF`. - - **Termux**: Type `p10k configure` and answer `Yes` when asked whether to install - *Meslo Nerd Font*. - - **Blink**: Type `config`, go to *Appearance*, tap *Add a new font*, tap *Open Gallery*, select - *MesloLGS NF.css*, tap *import* and type `exit` in the home view to reload the font. - - **Tabby** (formerly **Terminus**): Open *Settings → Appearance* and set *Font* to `MesloLGS NF`. - - **Terminator**: Open *Preferences* using the context menu. Under *Profiles* select the *General* - tab (should be selected already), uncheck *Use the system fixed width font* (if not already) - and select `MesloLGS NF Regular`. Exit the Preferences dialog by clicking *Close*. - - **Guake**: Right Click on an open terminal and open *Preferences*. Under *Appearance* - tab, uncheck *Use the system fixed width font* (if not already) and select `MesloLGS NF Regular`. - Exit the Preferences dialog by clicking *Close*. - - **MobaXterm**: Open *Settings* → *Configuration* → *Terminal* → (under *Terminal look and feel*) - and change *Font* to `MesloLGS NF`. If you have *sessions*, you need to change the font in each - of them through *Settings* → right click on an individual session → *Edit Session* → *Terminal - Settings* → *Font settings*. - - **Asbrú Connection Manager**: Open *Preferences → Local Shell Options → Look and Feel*, enable - *Use these personal options* and change *Font:* under *Terminal UI* to `MesloLGS NF Regular`. - To change the font for the remote host connections, go to *Preferences → Terminal Options → - Look and Feel* and change *Font:* under *Terminal UI* to `MesloLGS NF Regular`. - - **WSLtty**: Right click on an open terminal and then on *Options*. In the *Text* section, under - *Font*, click *"Select..."* and set Font to `MesloLGS NF Regular`. - - **Yakuake**: Click *≡* → *Manage Profiles* → *New* → *Appearance*. Click *Choose* next to the - *Font* dropdown, select `MesloLGS NF` and click *OK*. Click *OK* to save the profile. Select the - new profile and click *Set as Default*. - - **Alacritty**: Create or open `~/.config/alacritty/alacritty.toml` and add the following - section to it: - ```toml - [font.normal] - family = "MesloLGS NF" - ``` - - **foot**: Create or open `~/.config/foot/foot.ini` and add the following section to it: - ```ini - font=MesloLGS NF:size=12 - ``` - - **kitty**: Create or open `~/.config/kitty/kitty.conf` and add the following line to it: - ```text - font_family MesloLGS NF - ``` - Restart kitty by closing all sessions and opening a new session. - - **puTTY**: Set *Window* → *Appearance* → *Font* to `MesloLGS NF`. Requires puTTY - version >= 0.75. - - **WezTerm**: Create or open `$HOME/.config/wezterm/wezterm.lua` and add the following: - ```lua - local wezterm = require 'wezterm'; - return { - font = wezterm.font("MesloLGS NF"), - } - ``` - If the file already exists, only add the line with the font to the existing return. - Also add the first line if it is not already present. - - **urxvt**: Create or open `~/.Xresources` and add the following line to it: - ```text - URxvt.font: xft:MesloLGS NF:size=11 - ``` - You can adjust the font size to your preference. After changing the config run - `xrdb ~/.Xresources` to reload it. The new config is applied to all new terminals. - - **xterm**: Create or open `~/.Xresources` and add the following line to it: - ```text - xterm*faceName: MesloLGS NF - ``` - After changing the config run `xrdb ~/.Xresources` to reload it. The new config is applied to - all new terminals. - - **Zed**: Open `~/.config/zed/settings.json` and set `terminal.font_family` to `"MesloLGS NF"`. - ```jsonc - { - "terminal": { - "font_family": "MesloLGS NF" - }, - // Other settings. - } - ``` - - Crostini (Linux on Chrome OS): Open - chrome-untrusted://terminal/html/nassh_preferences_editor.html, set *Text font family* to - `'MesloLGS NF'` (including the quotes) and *Custom CSS (inline text)* to the following: - ```css - @font-face { - font-family: "MesloLGS NF"; - src: url("https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Regular.ttf"); - font-weight: normal; - font-style: normal; - } - @font-face { - font-family: "MesloLGS NF"; - src: url("https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Bold.ttf"); - font-weight: bold; - font-style: normal; - } - @font-face { - font-family: "MesloLGS NF"; - src: url("https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Italic.ttf"); - font-weight: normal; - font-style: italic; - } - @font-face { - font-family: "MesloLGS NF"; - src: url("https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20Bold%20Italic.ttf"); - font-weight: bold; - font-style: italic; - } - ``` - **_CAVEAT_**: If you open the normal terminal preferences these settings will be overwritten. -1. Run `p10k configure` to generate a new `~/.p10k.zsh`. The old config may work - incorrectly with the new font. +Download these four ttf files: + +- [MesloLGS NF Regular.ttf]( + https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf) +- [MesloLGS NF Bold.ttf]( + https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf) +- [MesloLGS NF Italic.ttf]( + https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf) +- [MesloLGS NF Bold Italic.ttf]( + https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf) + +Double-click on each file and click "Install". This will make `MesloLGS NF` font available to all +applications on your system. Configure your terminal to use this font: + +- **iTerm2**: Type `p10k configure` and answer `Yes` when asked whether to install + *Meslo Nerd Font*. Alternatively, open *iTerm2 → Preferences → Profiles → Text* and set *Font* to + `MesloLGS NF`. +- **Apple Terminal**: Open *Terminal → Preferences → Profiles → Text*, click *Change* under *Font* + and select `MesloLGS NF` family. +- **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 the value to `MesloLGS NF`. +- **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`. +- **Microsoft Terminal** (the new thing): Open *Settings* (`Ctrl+,`), search for `fontFace` and set + value to `MesloLGS NF` for every profile. +- **IntelliJ**: Open *Intellij → Edit → Preferences → Editor → Color Scheme → Console Font*. + Select *Use console font instead of the default* and set the font name to `MesloLGS NF`. +- **Termux**: Type `p10k configure` and answer `Yes` when asked whether to install + *Meslo Nerd Font*. +- **Blink**: Type `config`, go to *Appearance*, tap *Add a new font*, tap *Open Gallery*, select + *MesloLGS NF.css*, tap *import* and type `exit` in the home view to reload the font. +- **Terminus**: Open *Settings → Appearance* and set *Font* to `MesloLGS NF`. +- **Terminator**: Open *Preferences* using the context menu. Under *Profiles* select the *General* + tab (should be selected already), uncheck *Use the system fixed width font* (if not already) + and select `MesloLGS NF Regular`. Exit the Preferences dialog by clicking *Close*. +- **Guake**: Right Click on an open terminal and open *Preferences*. Under *Appearance* + tab, uncheck *Use the system fixed width font* (if not already) and select `MesloLGS NF Regular`. + Exit the Preferences dialog by clicking *Close*. +- **MobaXterm**: Open *Settings* → *Configuration* → *Terminal* → (Under *Terminal look and feel*) + and change *Font* to `MesloLGS NF`. +- **WSLtty**: Right click on an open terminal and then on *Options*. In the *Text* section, under + *Font*, click *"Select..."* and set Font to `MesloLGS NF Regular`. +- **Alacritty**: Create or open `~/.config/alacritty/alacritty.yml` and add the following section + to it: + ```yaml + font: + normal: + family: "MesloLGS NF" + ``` + - **Kitty**: Create or open `~/.config/kitty/kitty.conf` and add the following line to it: + ```text + font_family MesloLGS NF + ``` + Restart Kitty by closing all sessions and opening a new session. + +**IMPORTANT:** Run `p10k configure` after changing terminal font. The old `~/.p10k.zsh` may work +incorrectly with the new font. _Using a different terminal and know how to set the font for it? Share your knowledge by sending a PR to expand the list!_ diff --git a/gitstatus/Makefile b/gitstatus/Makefile index adb20e9d..0141dd90 100644 --- a/gitstatus/Makefile +++ b/gitstatus/Makefile @@ -10,7 +10,7 @@ VERSION ?= $(shell . ./build.info && printf "%s" "$$gitstatus_version") # # Sized delete is implemented as __ZdlPvm in /usr/lib/libc++.1.dylib but this symbol is # missing in macOS prior to 10.13. -CXXFLAGS += -std=c++14 -funsigned-char -O3 -DNDEBUG -DGITSTATUS_VERSION=$(VERSION) -Wall # -g -fsanitize=thread +CXXFLAGS += -std=c++14 -funsigned-char -O3 -DNDEBUG -DGITSTATUS_VERSION=$(VERSION) -Wall -Werror # -g -fsanitize=thread LDFLAGS += -pthread # -fsanitize=thread LDLIBS += -lgit2 # -lprofiler -lunwind @@ -34,24 +34,8 @@ $(OBJDIR)/%.o: src/%.cc Makefile build.info | $(OBJDIR) clean: rm -rf -- $(OBJDIR) -zwc: +pkg: + GITSTATUS_DAEMON= GITSTATUS_CACHE_DIR=$(shell pwd)/usrbin ./install -f $(or $(ZSH),:) -fc 'for f in *.zsh install; do zcompile -R -- $$f.zwc $$f || exit; done' -minify: - rm -rf -- .clang-format .git .gitattributes .gitignore .vscode deps docs src usrbin/.gitkeep LICENSE Makefile README.md build mbuild - -pkg: zwc - GITSTATUS_DAEMON= GITSTATUS_CACHE_DIR=$(shell pwd)/usrbin ./install -f - -include $(OBJS:.o=.dep) - -.PHONY: help - -help: - @echo "Usage: make [TARGET]" - @echo "Available targets:" - @echo " all Build $(APPNAME) (default target)" - @echo " clean Remove generated files and directories" - @echo " zwc Compile Zsh files" - @echo " minify Remove unnecessary files and folders" - @echo " pkg Create a package" diff --git a/gitstatus/README.md b/gitstatus/README.md index a6631f63..cbf29c3a 100644 --- a/gitstatus/README.md +++ b/gitstatus/README.md @@ -22,8 +22,7 @@ Bash bindings for integration with shell. The easiest way to take advantage of gitstatus from Zsh is to use a theme that's already integrated with it. For example, [Powerlevel10k](https://github.com/romkatv/powerlevel10k) is a flexible and -fast theme with first-class gitstatus integration. If you install Powerlevel10k, you don't need to -install gitstatus. +fast theme with first-class gitstatus integration. ![Powerlevel10k Zsh Theme]( https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/prompt-styles-high-contrast.png) @@ -36,7 +35,7 @@ git clone --depth=1 https://github.com/romkatv/gitstatus.git ~/gitstatus echo 'source ~/gitstatus/gitstatus.prompt.zsh' >>! ~/.zshrc ``` -Users in China can use the official mirror on gitee.com for faster download.
+Users in mainland China can use the official mirror on gitee.com for faster download.
中国大陆用户可以使用 gitee.com 上的官方镜像加速下载. ```zsh @@ -44,15 +43,15 @@ git clone --depth=1 https://gitee.com/romkatv/gitstatus.git ~/gitstatus echo 'source ~/gitstatus/gitstatus.prompt.zsh' >>! ~/.zshrc ``` -Alternatively, if you have Homebrew installed: +Alternatively, on macOS you can install with Homebrew: ```zsh brew install romkatv/gitstatus/gitstatus -echo "source $(brew --prefix)/opt/gitstatus/gitstatus.prompt.zsh" >>! ~/.zshrc +echo 'source /usr/local/opt/gitstatus/gitstatus.prompt.zsh' >>! ~/.zshrc ``` -(If you choose this option, replace `~/gitstatus` with `$(brew --prefix)/opt/gitstatus/gitstatus` -in all code snippets below.) +(If you choose this option, replace `~/gitstatus` with `/usr/local/opt/gitstatus` in all code +snippets below.) _Make sure to disable your current theme if you have one._ @@ -137,7 +136,7 @@ git clone --depth=1 https://github.com/romkatv/gitstatus.git ~/gitstatus echo 'source ~/gitstatus/gitstatus.prompt.sh' >> ~/.bashrc ``` -Users in China can use the official mirror on gitee.com for faster download.
+Users in mainland China can use the official mirror on gitee.com for faster download.
中国大陆用户可以使用 gitee.com 上的官方镜像加速下载. ```bash @@ -145,15 +144,15 @@ git clone --depth=1 https://gitee.com/romkatv/gitstatus.git ~/gitstatus echo 'source ~/gitstatus/gitstatus.prompt.sh' >> ~/.bashrc ``` -Alternatively, if you have Homebrew installed: +Alternatively, on macOS you can install with Homebrew: ```zsh brew install romkatv/gitstatus/gitstatus -echo "source $(brew --prefix)/opt/gitstatus/gitstatus.prompt.sh" >> ~/.bashrc +echo 'source /usr/local/opt/gitstatus/gitstatus.prompt.sh' >> ~/.bashrc ``` -(If you choose this option, replace `~/gitstatus` with `$(brew --prefix)/opt/gitstatus/gitstatus` -in all code snippets below.) +(If you choose this option, replace `~/gitstatus` with `/usr/local/opt/gitstatus` in all code +snippets below.) This will give you a basic yet functional prompt with git status in it. It's [over 10x faster](#benchmarks) than any alternative that can give you comparable prompt. @@ -255,7 +254,7 @@ repository was checked out to an ext4 filesystem on M.2 SSD. Three functionally equivalent tools for computing git status were benchmarked: * `gitstatusd` -* `git` with `core.untrackedcache` enabled and `core.fsmonitor` disabled +* `git` with untracked cache enabled * `lg2` -- a demo/example executable from [libgit2](https://github.com/romkatv/libgit2) that implements a subset of `git` functionality on top of libgit2 API; for the purposes of this benchmark the subset is sufficient to generate the same data as the other tools @@ -381,7 +380,7 @@ generated with the same tools and the same flags as the profile of libgit2. Since both profiles were generated from the same workload, absolute numbers can be compared. We can see that gitstatusd took 62 seconds in total compared to libgit2's 232 seconds. System calls at the -core of the algorithm are clearly visible. `__GI___fxstatat` is a flavor of `stat()`, and the other +core of the algorithm are cleary visible. `__GI___fxstatat` is a flavor of `stat()`, and the other three calls -- `__libc_openat64`, `__libc_close` and `__GI___fxstat` are responsible for opening directories and finding untracked files. Notice that there is almost nothing else in the profile apart from these calls. The rest of the code accounts for 3.77 seconds of CPU time -- 32 times less @@ -492,7 +491,7 @@ cd gitstatus ./build -w -s -d docker ``` -Users in China can use the official mirror on gitee.com for faster download.
+Users in mainland China can use the official mirror on gitee.com for faster download.
中国大陆用户可以使用 gitee.com 上的官方镜像加速下载. ```zsh diff --git a/gitstatus/build b/gitstatus/build index e116abb2..ad1d1484 100755 --- a/gitstatus/build +++ b/gitstatus/build @@ -12,24 +12,11 @@ fi export LC_ALL=C if [ -z "${ZSH_VERSION-}" ] && command -v zsh >/dev/null 2>&1; then - # Avoid bash 3.*. case "${BASH_VERSION-}" in [0-3].*) exec zsh "$0" "$@";; esac fi -# Avoid ksh: https://github.com/romkatv/gitstatus/issues/282. -if [ -n "${KSH_VERSION-}" ]; then - if [ -z "${ZSH_VERSION-}" ] && command -v zsh >/dev/null 2>&1; then - exec zsh "$0" "$@" - elif [ -z "${BASH_VERSION-}" ] && command -v bash >/dev/null 2>&1 && - bash_version="$(bash --version 2>&1)"; then - case "$bash_version" in - *version\ [4-9]*|*version\ [1-9][0-9]*) exec bash "$0" "$@";; - esac - fi -fi - usage="$(command cat <<\END Usage: build [-m ARCH] [-c CPU] [-d CMD] [-i IMAGE] [-s] [-w] @@ -68,7 +55,7 @@ workdir="$(command pwd)" narg() { echo $#; } -if [ "$(narg $workdir)" != 1 -o -z "${workdir##*:*}" -o -z "${workdir##*=*}" ]; then +if [ "$(narg $workdir)" != 1 -o -z "${workdir##*:*}" ]; then >&2 echo "[error] cannot build in this directory: $workdir" exit 1 fi @@ -100,11 +87,8 @@ if [ -n "$gitstatus_install_tools" ]; then exit 1 fi ;; - freebsd|dragonfly) - command pkg install -y cmake gmake binutils git perl5 wget - ;; - openbsd) - command pkg_add cmake gmake gcc g++ git wget + freebsd) + command pkg install -y cmake gmake binutils gcc git perl5 ;; netbsd) command pkgin -y install cmake gmake binutils git @@ -118,7 +102,7 @@ if [ -n "$gitstatus_install_tools" ]; then sudo port -N install libiconv cmake wget elif command -v brew >/dev/null 2>&1; then for formula in libiconv cmake git wget; do - if command brew ls --version "$formula" &>/dev/null; then + if command brew list "$formula" &>/dev/null; then command brew upgrade "$formula" else command brew install "$formula" @@ -141,113 +125,45 @@ if [ -n "$gitstatus_install_tools" ]; then fi cpus="$(command getconf _NPROCESSORS_ONLN 2>/dev/null)" || - cpus="$(command sysctl -n hw.ncpu 2>/dev/null)" || + cpus="$(command sysctl -n hw.ncpu 2>/dev/null)" || cpus=8 case "$gitstatus_cpu" in - powerpc64|powerpc64le) - archflag="-mcpu" - ;; - *) - archflag="-march" - ;; + powerpc64le) archflag="-mcpu";; + *) archflag="-march";; esac -cflags="$archflag=$gitstatus_cpu -fno-plt -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fpie" -ldflags= -static_pie= - -if [ -z "${CC-}" ]; then - case "$gitstatus_kernel" in - freebsd) export CC=clang;; - *) export CC=cc;; - esac -fi - -printf 'int main() {}\n' >"$workdir"/cc-test.c -if 2>/dev/null "$CC" \ - -ffile-prefix-map=x=y \ - -Werror \ - -c "$workdir"/cc-test.c \ - -o "$workdir"/cc-test.o; then - cflags="$cflags -ffile-prefix-map=$workdir/=" -fi - -command rm -f -- "$workdir"/cc-test "$workdir"/cc-test.o -if 2>/dev/null "$CC" \ - -fstack-clash-protection \ - -Werror \ - -c "$workdir"/cc-test.c \ - -o "$workdir"/cc-test.o; then - cflags="$cflags -fstack-clash-protection" -fi - -command rm -f -- "$workdir"/cc-test "$workdir"/cc-test.o -if 2>/dev/null "$CC" \ - -fcf-protection \ - -Werror \ - -c "$workdir"/cc-test.c \ - -o "$workdir"/cc-test.o; then - cflags="$cflags -fcf-protection" -fi - -command rm -f -- "$workdir"/cc-test "$workdir"/cc-test.o -if 2>/dev/null "$CC" \ - -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now \ - -Werror \ - "$workdir"/cc-test.c \ - -o "$workdir"/cc-test; then - ldflags="$ldflags -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now" -fi - -command rm -f -- "$workdir"/cc-test "$workdir"/cc-test.o -if 2>/dev/null "$CC" \ - -fpie -static-pie \ - -Werror \ - "$workdir"/cc-test.c \ - -o "$workdir"/cc-test; then - static_pie='-static-pie' -fi +cflags="$archflag=$gitstatus_cpu -fno-plt" if [ "$gitstatus_cpu" = x86-64 ]; then cflags="$cflags -mtune=generic" fi libgit2_cmake_flags= -libgit2_cflags="${CFLAGS-} $cflags -O3 -DNDEBUG" +libgit2_cflags="$cflags" gitstatus_cxx=g++ -gitstatus_cxxflags="${CXXFLAGS-} $cflags -I${workdir}/libgit2/include -DGITSTATUS_ZERO_NSEC -D_GNU_SOURCE -D_GLIBCXX_ASSERTIONS" -gitstatus_ldflags="${LDFLAGS-} $ldflags -L${workdir}/libgit2/build" +gitstatus_cxxflags="$cflags -I${workdir}/libgit2/include -DGITSTATUS_ZERO_NSEC -D_GNU_SOURCE" +gitstatus_ldflags="-L${workdir}/libgit2/build" gitstatus_ldlibs= gitstatus_make=make case "$gitstatus_kernel" in linux) - gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}" + gitstatus_ldflags="$gitstatus_ldflags -static" + gitstatus_ldflags="$gitstatus_ldflags -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now" libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON" ;; freebsd) - gitstatus_cxx=clang++ gitstatus_make=gmake - gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}" - libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON" - ;; - dragonfly) - gitstatus_cxx=clang++12 - gitstatus_make=gmake - gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}" - libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON" - ;; - openbsd) - gitstatus_cxx=eg++ - gitstatus_make=gmake - gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}" + gitstatus_ldflags="$gitstatus_ldflags -static" + gitstatus_ldflags="$gitstatus_ldflags -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now" libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON" ;; netbsd) gitstatus_make=gmake - gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}" + gitstatus_ldflags="$gitstatus_ldflags -static" + gitstatus_ldflags="$gitstatus_ldflags -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now" libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON" ;; darwin) @@ -268,11 +184,11 @@ case "$gitstatus_kernel" in libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=OFF" ;; msys*|mingw*) - gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}" + gitstatus_ldflags="$gitstatus_ldflags -static" libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON" ;; cygwin*) - gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}" + gitstatus_ldflags="$gitstatus_ldflags -static" libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON" ;; *) @@ -281,7 +197,7 @@ case "$gitstatus_kernel" in ;; esac -for cmd in cat cmake git ld ln mkdir rm strip tar "$gitstatus_make"; do +for cmd in cat cmake gcc g++ git ld ln mkdir rm strip tar "$gitstatus_make"; do if ! command -v "$cmd" >/dev/null 2>&1; then if [ -n "$gitstatus_install_tools" ]; then >&2 echo "[internal error] $cmd not found" @@ -315,18 +231,7 @@ if [ ! -e "$libgit2_tarball" ]; then fi fi libgit2_url=https://github.com/romkatv/libgit2/archive/"$libgit2_version".tar.gz - if ! >"$libgit2_tmp" command wget --no-config -qO- -- "$libgit2_url" && - ! >"$libgit2_tmp" command wget -qO- -- "$libgit2_url"; then - set -x - >&2 command which wget - >&2 command ls -lAd -- "$(command which wget)" - >&2 command ls -lAd -- "$outdir" - >&2 command ls -lA -- "$outdir" - >&2 command ls -lAd -- "$outdir"/deps - >&2 command ls -lA -- "$outdir"/deps - set +x - exit 1 - fi + command wget -O "$libgit2_tmp" -- "$libgit2_url" command mv -f -- "$libgit2_tmp" "$libgit2_tarball" else >&2 echo "[error] file not found: deps/libgit2-"$libgit2_version".tar.gz" @@ -372,7 +277,7 @@ command mkdir libgit2/build cd libgit2/build CFLAGS="$libgit2_cflags" command cmake \ - -DCMAKE_BUILD_TYPE=None \ + -DCMAKE_BUILD_TYPE=Release \ -DZERO_NSEC=ON \ -DTHREADSAFE=ON \ -DUSE_BUNDLED_ZLIB=ON \ @@ -390,7 +295,7 @@ command make -j "$cpus" VERBOSE=1 APPNAME="$appname".tmp \ OBJDIR="$workdir"/gitstatus \ - CXX="${CXX:-$gitstatus_cxx}" \ + CXX="$gitstatus_cxx" \ CXXFLAGS="$gitstatus_cxxflags" \ LDFLAGS="$gitstatus_ldflags" \ LDLIBS="$gitstatus_ldlibs" \ @@ -401,33 +306,16 @@ app="$outdir"/usrbin/"$appname" command strip "$app".tmp command mkdir -- "$workdir"/repo -printf '[init]\n defaultBranch = master\n' >"$workdir"/.gitconfig -( - cd -- "$workdir"/repo - GIT_CONFIG_NOSYSTEM=1 HOME="$workdir" command git init - GIT_CONFIG_NOSYSTEM=1 HOME="$workdir" command git config user.name "Your Name" - GIT_CONFIG_NOSYSTEM=1 HOME="$workdir" command git config user.email "you@example.com" - GIT_CONFIG_NOSYSTEM=1 HOME="$workdir" command git commit \ - --allow-empty --allow-empty-message --no-gpg-sign -m '' -) +command git -C "$workdir"/repo init +command git -C "$workdir"/repo config user.name "Your Name" +command git -C "$workdir"/repo config user.email "you@example.com" +command git -C "$workdir"/repo commit --allow-empty --allow-empty-message --no-gpg-sign -m '' resp="$(printf "hello\037$workdir/repo\036" | "$app".tmp)" -case "$resp" in - hello*1*/repo*master*);; - *) - >&2 echo 'error: invalid gitstatusd response for a git repo' - exit 1 - ;; -esac +[ -n "$resp" -a -z "${resp##hello*1*$workdir/repo*master*}" ] resp="$(printf 'hello\037\036' | "$app".tmp)" -case "$resp" in - hello*0*);; - *) - >&2 echo 'error: invalid gitstatusd response for a non-repo' - exit 1 - ;; -esac +[ -n "$resp" -a -z "${resp##hello*0*}" ] command mv -f -- "$app".tmp "$app" @@ -535,16 +423,13 @@ fi if [ -z "$gitstatus_cpu" ]; then case "$gitstatus_arch" in - armel) gitstatus_cpu=armv5;; - armv6l|armhf) gitstatus_cpu=armv6;; + armv6l) gitstatus_cpu=armv6;; armv7l) gitstatus_cpu=armv7;; - arm64|aarch64) gitstatus_cpu=armv8-a;; - ppc64|ppc64le) gitstatus_cpu=powerpc64le;; + arm64) gitstatus_cpu=armv8;; + aarch64) gitstatus_cpu=armv8-a;; + ppc64le) gitstatus_cpu=powerpc64le;; riscv64) gitstatus_cpu=rv64imafdc;; - loongarch64) gitstatus_cpu=loongarch64;; x86_64|amd64) gitstatus_cpu=x86-64;; - x86) gitstatus_cpu=i586;; - s390x) gitstatus_cpu=z900;; i386|i586|i686) gitstatus_cpu="$gitstatus_arch";; *) >&2 echo '[error] unable to infer target CPU architecture' @@ -573,13 +458,12 @@ case "$gitstatus_kernel" in fi if [ -z "$docker_image" ]; then case "$gitstatus_arch" in - x86_64) docker_image=alpine:3.11.6;; - x86|i386|i586|i686) docker_image=i386/alpine:3.11.6;; - armv6l|armhf) docker_image=arm32v6/alpine:3.11.6;; - armv7l) docker_image=arm32v7/alpine:3.11.6;; - aarch64) docker_image=arm64v8/alpine:3.11.6;; - ppc64|ppc64le) docker_image=ppc64le/alpine:3.11.6;; - s390x) docker_image=s390x/alpine:3.11.6;; + x86_64) docker_image=alpine:3.11.6;; + i386|i586|i686) docker_image=i386/alpine:3.11.6;; + armv6l) docker_image=arm32v6/alpine:3.11.6;; + armv7l) docker_image=arm32v7/alpine:3.11.6;; + aarch64) docker_image=arm64v8/alpine:3.11.6;; + ppc64le) docker_image=ppc64le/alpine:3.11.6;; *) >&2 echo '[error] unable to infer docker image' >&2 echo 'Please specify explicitly with `-i IMAGE`.' @@ -589,7 +473,7 @@ case "$gitstatus_kernel" in fi fi ;; - freebsd|openbsd|netbsd|darwin|dragonfly) + freebsd|netbsd|darwin) if [ -n "$docker_cmd" ]; then >&2 echo "[error] docker (-d) is not supported on $gitstatus_kernel" exit 1 diff --git a/gitstatus/build.info b/gitstatus/build.info index 9a4967e8..aa52263b 100644 --- a/gitstatus/build.info +++ b/gitstatus/build.info @@ -3,7 +3,7 @@ # # This value is also read by shell bindings (indirectly, through # ./install) when using GITSTATUS_DAEMON or usrbin/gitstatusd. -gitstatus_version="v1.5.4" +gitstatus_version="v1.3.1" # libgit2 is a build time dependency of gitstatusd. The values of # libgit2_version and libgit2_sha256 are read by ./build. @@ -18,5 +18,5 @@ gitstatus_version="v1.5.4" # # If sha256 of ./deps/libgit2-${libgit2_version}.tar.gz doesn't match, # build gets aborted. -libgit2_version="tag-2ecf33948a4df9ef45a66c68b8ef24a5e60eaac6" -libgit2_sha256="4ce11d71ee576dbbc410b9fa33a9642809cc1fa687b315f7c23eeb825b251e93" +libgit2_version="tag-82cefe2b42300224ad3c148f8b1a569757cc617a" +libgit2_sha256="dc701c4e2080f7901f5d599d642b629569e5581086b9838d481d09f284dc7621" diff --git a/gitstatus/gitstatus.plugin.sh b/gitstatus/gitstatus.plugin.sh index bfe16dc2..61b81e6a 100644 --- a/gitstatus/gitstatus.plugin.sh +++ b/gitstatus/gitstatus.plugin.sh @@ -35,11 +35,6 @@ # # -D Unless this option is specified, report zero staged, unstaged and conflicted # changes for repositories with bash.showDirtyState = false. -# -# -r INT Close git repositories that haven't been used for this many seconds. This is -# meant to release resources such as memory and file descriptors. The next request -# for a repo that's been closed is much slower than for a repo that hasn't been. -# Negative value means infinity. The default is 3600 (one hour). function gitstatus_start() { if [[ "$BASH_VERSION" < 4 ]]; then >&2 printf 'gitstatus_start: need bash version >= 4.0, found %s\n' "$BASH_VERSION" @@ -53,9 +48,10 @@ function gitstatus_start() { fi unset OPTIND - local opt timeout=5 max_dirty=-1 ttl=3600 extra_flags= + local opt timeout=5 max_dirty=-1 extra_flags local max_num_staged=1 max_num_unstaged=1 max_num_conflicted=1 max_num_untracked=1 - while getopts "t:s:u:c:d:m:r:eUWD" opt; do + local ignore_status_show_untracked_files + while getopts "t:s:u:c:d:m:eUWD" opt; do case "$opt" in t) timeout=$OPTARG;; s) max_num_staged=$OPTARG;; @@ -63,7 +59,6 @@ function gitstatus_start() { c) max_num_conflicted=$OPTARG;; d) max_num_untracked=$OPTARG;; m) max_dirty=$OPTARG;; - r) ttl=$OPTARG;; e) extra_flags+='--recurse-untracked-dirs ';; U) extra_flags+='--ignore-status-show-untracked-files ';; W) extra_flags+='--ignore-bash-show-untracked-files ';; @@ -118,15 +113,9 @@ function gitstatus_start() { --max-num-conflicted="$max_num_conflicted" --max-num-untracked="$max_num_untracked" --dirty-max-index-size="$max_dirty" - --repo-ttl-seconds="$ttl" $extra_flags) - if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then - local tmpdir=$TMPDIR - else - local tmpdir=/tmp - fi - tmpdir="$(command mktemp -d "$tmpdir"/gitstatus.bash.$$.XXXXXXXXXX)" || return + tmpdir="$(command mktemp -d "${TMPDIR:-/tmp}"/gitstatus.bash.$$.XXXXXXXXXX)" || return if [[ -n "$log_level" ]]; then GITSTATUS_DAEMON_LOG="$tmpdir"/daemon.log @@ -275,22 +264,54 @@ function gitstatus_start() { return 1 fi - export _GITSTATUS_CLIENT_PID _GITSTATUS_REQ_FD _GITSTATUS_RESP_FD GITSTATUS_DAEMON_PID unset -f gitstatus_start_impl + + if [[ "${GITSTATUS_STOP_ON_EXEC:-1}" == 1 ]]; then + type -t _gitstatus_exec &>/dev/null || function _gitstatus_exec() { exec "$@"; } + type -t _gitstatus_builtin &>/dev/null || function _gitstatus_builtin() { builtin "$@"; } + + function _gitstatus_exec_wrapper() { + (( ! $# )) || gitstatus_stop + local ret=0 + _gitstatus_exec "$@" || ret=$? + [[ -n "${GITSTATUS_DAEMON_PID:-}" ]] || gitstatus_start || true + return $ret + } + + function _gitstatus_builtin_wrapper() { + while [[ "${1:-}" == builtin ]]; do shift; done + if [[ "${1:-}" == exec ]]; then + _gitstatus_exec_wrapper "${@:2}" + else + _gitstatus_builtin "$@" + fi + } + + alias exec=_gitstatus_exec_wrapper + alias builtin=_gitstatus_builtin_wrapper + + _GITSTATUS_EXEC_HOOK=1 + else + unset _GITSTATUS_EXEC_HOOK + fi } # Stops gitstatusd if it's running. function gitstatus_stop() { - if [[ "${_GITSTATUS_CLIENT_PID:-$BASHPID}" == "$BASHPID" ]]; then - [[ -z "${_GITSTATUS_REQ_FD:-}" ]] || exec {_GITSTATUS_REQ_FD}>&- || true - [[ -z "${_GITSTATUS_RESP_FD:-}" ]] || exec {_GITSTATUS_RESP_FD}>&- || true - [[ -z "${GITSTATUS_DAEMON_PID:-}" ]] || kill "$GITSTATUS_DAEMON_PID" &>/dev/null || true + [[ "${_GITSTATUS_CLIENT_PID:-$BASHPID}" == "$BASHPID" ]] || return 0 + [[ -z "${_GITSTATUS_REQ_FD:-}" ]] || exec {_GITSTATUS_REQ_FD}>&- || true + [[ -z "${_GITSTATUS_RESP_FD:-}" ]] || exec {_GITSTATUS_RESP_FD}>&- || true + [[ -z "${GITSTATUS_DAEMON_PID:-}" ]] || kill "$GITSTATUS_DAEMON_PID" &>/dev/null || true + if [[ -n "${_GITSTATUS_EXEC_HOOK:-}" ]]; then + unalias exec builtin &>/dev/null || true + function _gitstatus_exec_wrapper() { _gitstatus_exec "$@"; } + function _gitstatus_builtin_wrapper() { _gitstatus_builtin "$@"; } fi - unset _GITSTATUS_REQ_FD _GITSTATUS_RESP_FD GITSTATUS_DAEMON_PID + unset _GITSTATUS_REQ_FD _GITSTATUS_RESP_FD GITSTATUS_DAEMON_PID _GITSTATUS_EXEC_HOOK unset _GITSTATUS_DIRTY_MAX_INDEX_SIZE _GITSTATUS_CLIENT_PID } -# Retrieves status of a git repository from a directory under its working tree. +# Retrives status of a git repository from a directory under its working tree. # # Usage: gitstatus_query [OPTION]... # @@ -311,8 +332,6 @@ function gitstatus_stop() { # 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_COMMIT_ENCODING Encoding of the HEAD's commit message. Empty value means UTF-8. -# VCS_STATUS_COMMIT_SUMMARY The first paragraph of the HEAD's commit message as one line. # 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. @@ -360,7 +379,7 @@ function gitstatus_stop() { # shell or the call had failed. function gitstatus_query() { unset OPTIND - local opt dir= timeout=() no_diff=0 + local opt dir timeout=() no_diff=0 while getopts "d:c:t:p" opt "$@"; do case "$opt" in d) dir=$OPTARG;; @@ -371,7 +390,7 @@ function gitstatus_query() { done (( OPTIND == $# + 1 )) || { echo "usage: gitstatus_query [OPTION]..." >&2; return 1; } - [[ -n "${GITSTATUS_DAEMON_PID-}" ]] || return # not started + [[ -n "$GITSTATUS_DAEMON_PID" ]] || return # not started local req_id="$RANDOM.$RANDOM.$RANDOM.$RANDOM" if [[ -z "${GIT_DIR:-}" ]]; then @@ -416,8 +435,6 @@ function gitstatus_query() { VCS_STATUS_PUSH_COMMITS_BEHIND="${resp[24]:-0}" VCS_STATUS_NUM_SKIP_WORKTREE="${resp[25]:-0}" VCS_STATUS_NUM_ASSUME_UNCHANGED="${resp[26]:-0}" - VCS_STATUS_COMMIT_ENCODING="${resp[27]-}" - VCS_STATUS_COMMIT_SUMMARY="${resp[28]-}" VCS_STATUS_HAS_STAGED=$((VCS_STATUS_NUM_STAGED > 0)) if (( _GITSTATUS_DIRTY_MAX_INDEX_SIZE >= 0 && VCS_STATUS_INDEX_SIZE > _GITSTATUS_DIRTY_MAX_INDEX_SIZE_ )); then @@ -460,8 +477,6 @@ function gitstatus_query() { unset VCS_STATUS_PUSH_COMMITS_BEHIND unset VCS_STATUS_NUM_SKIP_WORKTREE unset VCS_STATUS_NUM_ASSUME_UNCHANGED - unset VCS_STATUS_COMMIT_ENCODING - unset VCS_STATUS_COMMIT_SUMMARY fi } diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index b74396d3..ca0fb311 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -15,8 +15,6 @@ # VCS_STATUS_COMMIT=c000eddcff0fb38df2d0137efe24d9d2d900f209 # VCS_STATUS_COMMITS_AHEAD=0 # VCS_STATUS_COMMITS_BEHIND=0 -# VCS_STATUS_COMMIT_ENCODING='' -# VCS_STATUS_COMMIT_SUMMARY='pull upstream changes from gitstatus' # VCS_STATUS_HAS_CONFLICTED=0 # VCS_STATUS_HAS_STAGED=0 # VCS_STATUS_HAS_UNSTAGED=1 @@ -59,7 +57,7 @@ zmodload -F zsh/files b:zf_rm || return typeset -g _gitstatus_plugin_dir"${1:-}"="${${(%):-%x}:A:h}" -# Retrieves status of a git repo from a directory under its working tree. +# Retrives status of a git repo from a directory under its working tree. # ## Usage: gitstatus_query [OPTION]... NAME # @@ -90,8 +88,6 @@ typeset -g _gitstatus_plugin_dir"${1:-}"="${${(%):-%x}:A:h}" # 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_COMMIT_ENCODING Encoding of the HEAD's commit message. Empty value means UTF-8. -# VCS_STATUS_COMMIT_SUMMARY The first paragraph of the HEAD's commit message as one line. # 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. @@ -185,21 +181,9 @@ function gitstatus_query"${1:-}"() { (( _GITSTATUS_STATE_$name == 2 )) || return if [[ -z $GIT_DIR ]]; then - if [[ $dir != /* ]]; then - if [[ $PWD == /* && $PWD -ef . ]]; then - dir=$PWD/$dir - else - dir=${dir:a} - fi - fi + [[ $dir == /* ]] || dir=${(%):-%/}/$dir else - if [[ $GIT_DIR == /* ]]; then - dir=:$GIT_DIR - elif [[ $PWD == /* && $PWD -ef . ]]; then - dir=:$PWD/$GIT_DIR - else - dir=:${GIT_DIR:a} - fi + [[ $GIT_DIR == /* ]] && dir=:$GIT_DIR || dir=:${(%):-%/}/$GIT_DIR fi if [[ $dir != (|:)/* ]]; then @@ -345,9 +329,7 @@ function _gitstatus_process_response"${1:-}"() { VCS_STATUS_PUSH_COMMITS_AHEAD \ VCS_STATUS_PUSH_COMMITS_BEHIND \ VCS_STATUS_NUM_SKIP_WORKTREE \ - VCS_STATUS_NUM_ASSUME_UNCHANGED \ - VCS_STATUS_COMMIT_ENCODING \ - VCS_STATUS_COMMIT_SUMMARY in "${(@)resp[3,29]}"; do + VCS_STATUS_NUM_ASSUME_UNCHANGED in "${(@)resp[3,27]}"; do done typeset -gi VCS_STATUS_{INDEX_SIZE,NUM_STAGED,NUM_UNSTAGED,NUM_CONFLICTED,NUM_UNTRACKED,COMMITS_AHEAD,COMMITS_BEHIND,STASHES,NUM_UNSTAGED_DELETED,NUM_STAGED_NEW,NUM_STAGED_DELETED,PUSH_COMMITS_AHEAD,PUSH_COMMITS_BEHIND,NUM_SKIP_WORKTREE,NUM_ASSUME_UNCHANGED} typeset -gi VCS_STATUS_HAS_STAGED=$((VCS_STATUS_NUM_STAGED > 0)) @@ -470,7 +452,7 @@ function _gitstatus_daemon"${1:-}"() { (( lock_fd == -1 )) && return { - if zsystem flock -- $file_prefix.lock && command sleep 5 && [[ -e $file_prefix.lock ]]; then + if zsystem flock -- $file_prefix.lock && [[ -e $file_prefix.lock ]]; then zf_rm -f -- $file_prefix.lock $file_prefix.fifo kill -- -$pgid fi @@ -574,12 +556,7 @@ function gitstatus_start"${1:-}"() { else typeset -gi _GITSTATUS_START_COUNTER local log_level=$GITSTATUS_LOG_LEVEL - if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then - local tmpdir=$TMPDIR - else - local tmpdir=/tmp - fi - local file_prefix=${tmpdir:A}/gitstatus.$name.$EUID + local file_prefix=${${TMPDIR:-/tmp}:A}/gitstatus.$name.$EUID file_prefix+=.$sysparams[pid].$EPOCHSECONDS.$((++_GITSTATUS_START_COUNTER)) (( GITSTATUS_ENABLE_LOGGING )) && : ${log_level:=INFO} if [[ -n $log_level ]]; then diff --git a/gitstatus/gitstatus.prompt.sh b/gitstatus/gitstatus.prompt.sh index f54c11ac..9c1a2138 100644 --- a/gitstatus/gitstatus.prompt.sh +++ b/gitstatus/gitstatus.prompt.sh @@ -2,7 +2,7 @@ # Source gitstatus.plugin.sh from $GITSTATUS_DIR or from the same directory # in which the current script resides if the variable isn't set. -if [[ -n "${GITSTATUS_DIR-}" ]]; then +if [[ -n "${GITSTATUS_DIR:-}" ]]; then source "$GITSTATUS_DIR" || return elif [[ "${BASH_SOURCE[0]}" == */* ]]; then source "${BASH_SOURCE[0]%/*}/gitstatus.plugin.sh" || return @@ -33,11 +33,11 @@ function gitstatus_prompt_update() { gitstatus_query "$@" || return 1 # error [[ "$VCS_STATUS_RESULT" == ok-sync ]] || return 0 # not a git repo - local reset=$'\001\e[0m\002' # no color - local clean=$'\001\e[38;5;076m\002' # green foreground - local untracked=$'\001\e[38;5;014m\002' # teal foreground - local modified=$'\001\e[38;5;011m\002' # yellow foreground - local conflicted=$'\001\e[38;5;196m\002' # red foreground + local reset=$'\e[0m' # no color + local clean=$'\e[38;5;076m' # green foreground + local untracked=$'\e[38;5;014m' # teal foreground + local modified=$'\e[38;5;011m' # yellow foreground + local conflicted=$'\e[38;5;196m' # red foreground local p @@ -85,15 +85,7 @@ function gitstatus_prompt_update() { gitstatus_stop && gitstatus_start -s -1 -u -1 -c -1 -d -1 # On every prompt, fetch git status and set GITSTATUS_PROMPT. -if [[ -z "${PROMPT_COMMAND[*]}" ]]; then - PROMPT_COMMAND=gitstatus_prompt_update -elif [[ ! "${PROMPT_COMMAND[*]}" =~ [[:space:]\;]?gitstatus_prompt_update[[:space:]\;]? ]]; then - # Note: If PROMPT_COMMAND is an array, this will modify its first element. - PROMPT_COMMAND=$'gitstatus_prompt_update\n'"$PROMPT_COMMAND" -fi - -# Retain 3 trailing components of the current directory. -PROMPT_DIRTRIM=3 +PROMPT_COMMAND=gitstatus_prompt_update # Enable promptvars so that ${GITSTATUS_PROMPT} in PS1 is expanded. shopt -s promptvars diff --git a/gitstatus/install b/gitstatus/install index 76f339e0..86824ece 100755 --- a/gitstatus/install +++ b/gitstatus/install @@ -245,30 +245,27 @@ END return 1 fi - if [ -n "${TMPDIR-}" -a '(' '(' -d "${TMPDIR-}" -a -w "${TMPDIR-}" ')' -o '!' '(' -d /tmp -a -w /tmp ')' ')' ]; then - local tmp="$TMPDIR" - else - local tmp=/tmp - fi + local tmpdir if ! command -v mktemp >/dev/null 2>&1 || - ! tmpdir="$(command mktemp -d "$tmp"/gitstatus-install.XXXXXXXXXX)"; then - tmpdir="$tmp/gitstatus-install.tmp.$$" + ! tmpdir="$(command mktemp -d "${TMPDIR:-/tmp}"/gitstatus-install.XXXXXXXXXX)"; then + tmpdir="${TMPDIR:-/tmp}/gitstatus-install.tmp.$$" if ! mkdir -p -- "$tmpdir"; then - if [ "$tmp" = /tmp ]; then + local dir="${TMPDIR:-/tmp}" + if [ -z "${TMPDIR:-}" ]; then local label='directory' else local label='directory (\033[1mTMPDIR\033[m)' fi - if [ ! -e "$tmp" ]; then - >&"$e" printf 'Temporary '"$label"' does not exist: \033[4;31m%s\033[0m\n' "$tmp" + if [ ! -e "$dir" ]; then + >&"$e" printf 'Temporary '"$label"' does not exist: \033[4;31m%s\033[0m\n' "$dir" >&"$e" printf '\n' >&"$e" printf 'Create it, then restart your shell.\n' - elif [ ! -d "$tmp" ]; then - >&"$e" printf 'Not a '"$label"': \033[4;31m%s\033[0m\n' "$tmp" + elif [ ! -d "$dir" ]; then + >&"$e" printf 'Not a '"$label"': \033[4;31m%s\033[0m\n' "$dir" >&"$e" printf '\n' >&"$e" printf 'Make it a directory, then restart your shell.\n' - elif [ ! -w "$tmp" ]; then - >&"$e" printf 'Temporary '"$label"' is not writable: \033[4;31m%s\033[0m\n' "$tmp" + elif [ ! -w "$dir" ]; then + >&"$e" printf 'Temporary '"$label"' is not writable: \033[4;31m%s\033[0m\n' "$dir" >&"$e" printf '\n' >&"$e" printf 'Make it writable, then restart your shell.\n' fi @@ -307,29 +304,27 @@ END local data_file="$tmpdir"/"$1".tar.gz local hash_file="$tmpdir"/"$1".tar.gz.sha256 local hash= - { - command -v shasum >/dev/null 2>/dev/null && - run_cmd shasum -b -a 256 -- "$data_file" >"$hash_file" /dev/null 2>/dev/null && - run_cmd sha256sum -b -- "$data_file" >"$hash_file" /dev/null 2>/dev/null && - run_cmd sha256 -- "$data_file" >"$hash_file" /dev/null 2>/dev/null; then + if run_cmd shasum -b -a 256 -- "$data_file" >"$hash_file"; then + IFS= read -r hash <"$hash_file" || hash= + hash="${hash%% *}" + fi + elif command -v sha256sum >/dev/null 2>/dev/null; then + if run_cmd sha256sum -b -- "$data_file" >"$hash_file"; then + IFS= read -r hash <"$hash_file" || hash= + hash="${hash%% *}" + fi + elif command -v sha256 >/dev/null 2>/dev/null; then + if run_cmd sha256 -- "$data_file" "$hash_file"; then + IFS= read -r hash <"$hash_file" || hash= + # Ignore sha256 output if it's from hashalot. It's incompatible. + if [ ${#hash} -lt 64 ]; then + hash= + else + hash="${hash##* }" + fi + fi + fi [ "$1" = 1 -a -z "$hash" -o "$hash" = "$sha256" ] } @@ -345,7 +340,7 @@ END fi fi local cmd part url ret - for cmd in 'curl -kfsSL' 'wget -qO-' 'curl -q -kfsSL' 'wget --no-config -qO-'; do + for cmd in 'curl -q -kfsSL' 'wget --no-config -qO-' 'wget -qO-' 'curl -kfsSL'; do part=0 while true; do if [ "$part" = 2 ]; then diff --git a/gitstatus/install.info b/gitstatus/install.info index 45807be4..e71a03ef 100644 --- a/gitstatus/install.info +++ b/gitstatus/install.info @@ -1,4 +1,4 @@ -# 3 +# 0 # # This file is used by ./install and indirectly by shell bindings. # @@ -8,27 +8,27 @@ # work fine. # Official gitstatusd binaries. -uname_s_glob="cygwin_nt-10.0"; uname_m_glob="i686"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.4"; sha256="5a8a809dcebdb6aa9b47d37e086c0485424a9d9c136770eec3c26cedf5bb75e3"; -uname_s_glob="cygwin_nt-10.0"; uname_m_glob="x86_64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.1"; sha256="c84cade0d6b86e04c27a6055f45851f6b46d6b88ba58772f7ca8ef4d295c800f"; -uname_s_glob="darwin"; uname_m_glob="arm64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.4"; sha256="eae979e990ca37c56ee39fadd0c3f392cbbd0c6bdfb9a603010be60d9e48910a"; -uname_s_glob="darwin"; uname_m_glob="x86_64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.4"; sha256="9fd3913ec1b6b856ab6e08a99a2343f0e8e809eb6b62ca4b0963163656c668e6"; -uname_s_glob="freebsd"; uname_m_glob="amd64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.4"; sha256="8e57ad642251e5acfa430aed82cd4ffe103db0bfadae4a15ccaf462c455d0442"; -uname_s_glob="linux"; uname_m_glob="aarch64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.4"; sha256="32b57eb28bf6d80b280e4020a0045184f8ca897b20b570c12948aa6838673225"; -uname_s_glob="linux"; uname_m_glob="armv6l"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.1"; sha256="4bf5a0d0a082f544a48536ad3675930d5d2cc6a8cf906710045e0788f51192b3"; -uname_s_glob="linux"; uname_m_glob="armv7l"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.1"; sha256="2b9deb29f86c8209114b71b94fc2e1ed936a1658808a1bee46f4a82fd6a1f8cc"; -uname_s_glob="linux"; uname_m_glob="armv8l"; file="gitstatusd-${uname_s}-aarch64"; version="v1.5.4"; sha256="32b57eb28bf6d80b280e4020a0045184f8ca897b20b570c12948aa6838673225"; -uname_s_glob="linux"; uname_m_glob="i686"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.4"; sha256="56d55e2e9a202d3072fa612d8fa1faa61243ffc86418a7fa64c2c9d9a82e0f64"; -uname_s_glob="linux"; uname_m_glob="ppc64le"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.4"; sha256="1afd072c8c26ef6ec2d9ac11cef96c84cd6f10e859665a6ffcfb6112c758547e"; -uname_s_glob="linux"; uname_m_glob="x86_64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.4"; sha256="9633816e7832109e530c9e2532b11a1edae08136d63aa7e40246c0339b7db304"; -uname_s_glob="msys_nt-10.0"; uname_m_glob="i686"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.1"; sha256="7f9b849fc52e7a95b9b933e25121ad5ae990a1871aad6616922ad7bcf1eebf20"; -uname_s_glob="msys_nt-10.0"; uname_m_glob="x86_64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.5.1"; sha256="5d3c626b5ee564dbc13ddba89752dc58b0efe925b26dbd8b2304849d9ba01732"; +uname_s_glob="cygwin_nt-10.0"; uname_m_glob="i686"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.3.1"; sha256="c96baef70b81b5a1d46adcc9e93721eaf4bdc295562bdd2baf210a6b416b9911"; +uname_s_glob="cygwin_nt-10.0"; uname_m_glob="x86_64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.3.1"; sha256="18b5be49f6eb9ff1cf25e76d6f2333c7402e686e05ce5b88ca107c80504210d8"; +uname_s_glob="darwin"; uname_m_glob="arm64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.3.1"; sha256="0394e2ac880c1e190ace0346499d4670861297ecc2f84315ecb8ba3c98aa68d9"; +uname_s_glob="darwin"; uname_m_glob="x86_64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.3.1"; sha256="26d582fe9a0b2090c28e84e5e32a6d42d6988cedff51e41ec5f789512c53b0fc"; +uname_s_glob="freebsd"; uname_m_glob="amd64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.3.1"; sha256="54a823373458a0908187ba8d1c5b8921015c844811916451674cc09fbdff88bb"; +uname_s_glob="linux"; uname_m_glob="aarch64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.3.1"; sha256="4e0a506eafb14b009cf6670f0e11399ac7e765cad17b9fcf38ef65516d248bfa"; +uname_s_glob="linux"; uname_m_glob="armv6l"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.3.1"; sha256="4cc78bf24c6cfb4580ae48b13e1f26b6b00869c612b5d662632f7561f7475252"; +uname_s_glob="linux"; uname_m_glob="armv7l"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.3.1"; sha256="80f5ebc8efe62a0c322e92d15d469e80f9d3ce967c5d5118138674c47f96747b"; +uname_s_glob="linux"; uname_m_glob="armv8l"; file="gitstatusd-${uname_s}-aarch64"; version="v1.3.1"; sha256="4e0a506eafb14b009cf6670f0e11399ac7e765cad17b9fcf38ef65516d248bfa"; +uname_s_glob="linux"; uname_m_glob="i686"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.3.1"; sha256="ba506fbecf4a4430533e661bb63c7b77f6b4836ea013bdf8a6eabeace456f3b9"; +uname_s_glob="linux"; uname_m_glob="ppc64le"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.3.1"; sha256="1bf907db28ac7d6516add51be47b73b1854b84ecf46de56ccb1479e6a7e29ed2"; +uname_s_glob="linux"; uname_m_glob="x86_64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.3.1"; sha256="91bcc1efafff8c896e8f172ff624d9407494f7a26b4ad1bf573f52623be2ca91"; +uname_s_glob="msys_nt-10.0"; uname_m_glob="i686"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.3.1"; sha256="618d2425c6a22fa3762fe6fe252f9ddb4ed9138df1377e48b2f119cd4875f400"; +uname_s_glob="msys_nt-10.0"; uname_m_glob="x86_64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.3.1"; sha256="bdfae7a7c0fd83d0214a7eabde3b7d8709336bd08697a74d48bea4a04c352676"; # Fallbacks to official gitstatusd binaries. -uname_s_glob="cygwin_nt-*"; uname_m_glob="i686"; file="gitstatusd-cygwin_nt-10.0-${uname_m}"; version="v1.5.2"; sha256="5a8a809dcebdb6aa9b47d37e086c0485424a9d9c136770eec3c26cedf5bb75e3"; -uname_s_glob="cygwin_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-cygwin_nt-10.0-${uname_m}"; version="v1.5.1"; sha256="c84cade0d6b86e04c27a6055f45851f6b46d6b88ba58772f7ca8ef4d295c800f"; -uname_s_glob="mingw32_nt-*"; uname_m_glob="i686"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.5.1"; sha256="7f9b849fc52e7a95b9b933e25121ad5ae990a1871aad6616922ad7bcf1eebf20"; -uname_s_glob="mingw32_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.5.1"; sha256="5d3c626b5ee564dbc13ddba89752dc58b0efe925b26dbd8b2304849d9ba01732"; -uname_s_glob="mingw64_nt-*"; uname_m_glob="i686"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.5.1"; sha256="7f9b849fc52e7a95b9b933e25121ad5ae990a1871aad6616922ad7bcf1eebf20"; -uname_s_glob="mingw64_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.5.1"; sha256="5d3c626b5ee564dbc13ddba89752dc58b0efe925b26dbd8b2304849d9ba01732"; -uname_s_glob="msys_nt-*"; uname_m_glob="i686"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.5.1"; sha256="7f9b849fc52e7a95b9b933e25121ad5ae990a1871aad6616922ad7bcf1eebf20"; -uname_s_glob="msys_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.5.1"; sha256="5d3c626b5ee564dbc13ddba89752dc58b0efe925b26dbd8b2304849d9ba01732"; +uname_s_glob="cygwin_nt-*"; uname_m_glob="i686"; file="gitstatusd-cygwin_nt-10.0-${uname_m}"; version="v1.3.1"; sha256="c96baef70b81b5a1d46adcc9e93721eaf4bdc295562bdd2baf210a6b416b9911"; +uname_s_glob="cygwin_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-cygwin_nt-10.0-${uname_m}"; version="v1.3.1"; sha256="18b5be49f6eb9ff1cf25e76d6f2333c7402e686e05ce5b88ca107c80504210d8"; +uname_s_glob="mingw32_nt-*"; uname_m_glob="i686"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.3.1"; sha256="618d2425c6a22fa3762fe6fe252f9ddb4ed9138df1377e48b2f119cd4875f400"; +uname_s_glob="mingw32_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.3.1"; sha256="bdfae7a7c0fd83d0214a7eabde3b7d8709336bd08697a74d48bea4a04c352676"; +uname_s_glob="mingw64_nt-*"; uname_m_glob="i686"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.3.1"; sha256="618d2425c6a22fa3762fe6fe252f9ddb4ed9138df1377e48b2f119cd4875f400"; +uname_s_glob="mingw64_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.3.1"; sha256="bdfae7a7c0fd83d0214a7eabde3b7d8709336bd08697a74d48bea4a04c352676"; +uname_s_glob="msys_nt-*"; uname_m_glob="i686"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.3.1"; sha256="618d2425c6a22fa3762fe6fe252f9ddb4ed9138df1377e48b2f119cd4875f400"; +uname_s_glob="msys_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.3.1"; sha256="bdfae7a7c0fd83d0214a7eabde3b7d8709336bd08697a74d48bea4a04c352676"; diff --git a/gitstatus/mbuild b/gitstatus/mbuild index 40316fdf..608e3aba 100755 --- a/gitstatus/mbuild +++ b/gitstatus/mbuild @@ -94,7 +94,9 @@ setopt no_unset extended_glob pipe_fail prompt_percent typeset_silent \ no_prompt_subst no_prompt_bang pushd_silent warn_create_global -if [[ $ZSH_VERSION != (5.<1->*|<6->.*) || $ZSH_VERSION == 5.4(|.*) ]]; then +autoload -Uz is-at-least + +if ! is-at-least 5.1 || [[ $ZSH_VERSION == 5.4.* ]]; then print -ru2 -- "[error] unsupported zsh version: $ZSH_VERSION" return 1 fi @@ -182,7 +184,7 @@ function build-unix() { case $2 in linux-ppc64le) ;; linux-*) flags+=(-d docker);; - darwin-arm64) intro='PATH="/opt/homebrew/bin:$PATH"';; + darwin-arm64) intro='PATH="/opt/local/bin:$PATH"';; darwin-*) intro='PATH="/usr/local/bin:$PATH"';; esac ssh $1 -- /bin/sh -uex <<<" @@ -210,11 +212,10 @@ function build-windows() { tmp='/cygdrive/c/tmp' ;| msys_nt-10.0-*) + flags+=(-s) tmp='/c/tmp' env='MSYSTEM=MSYS' - # TODO: fix this (some errors about PGP keys). - # flags+=(-s) - # intro='pacman -S --needed --noconfirm git; ' + intro='pacman -Syu --noconfirm; pacman -S --needed --noconfirm git; ' intro+='PATH="$PATH:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl"' while true; do # TODO: run autorebase only when getting an error that can be fixed by autorebasing. @@ -229,8 +230,6 @@ function build-windows() { done () { while true; do - # TODO: fix this (some errors about PGP keys). - break local -i fd exec {fd}< <( ssh $1 $c/$bin/env.exe $env c:/$bin/bash.exe -l 2>&1 <<<" @@ -269,52 +268,16 @@ function build-windows() { chmod +x $binaries/gitstatusd-$2 } -if [[ -r /proc/version && "$(/dev/null - ( - trap '' TERM PIPE - local fd - while true; do - sysopen -wo create,excl -u fd -- $1 && break - sleep 1 - done - exec {fd}>&- - while true; do - print || break - done - rm -- $1 - ) &! - ) - local REPLY - IFS= read -ru $fd - } -else - function flock() { - : >>$1 - zsystem flock $1 - } -fi - function build() ( setopt xtrace local platform=$1 local machine=$assets[$platform] - flock $locks/$machine + print -n >>$locks/$machine + zsystem flock $locks/$machine build-${protocol[(k)$platform]} $machine $platform local tmp=gitstatusd-$platform.tmp.$$.tar.gz ( cd -q -- $binaries; tar --owner=0 --group=0 -I 'gzip -9' -cf $tmp gitstatusd-$platform ) mv -f -- $binaries/$tmp $binaries/gitstatusd-$platform.tar.gz - # Make sure the last command is a built-in (important for flock). - : ) function mbuild() { @@ -399,8 +362,4 @@ function run-process-tree() { } mkdir -p -- $logs $locks $binaries - -() { - run-process-tree mbuild $@ - exit -} "$@" +run-process-tree mbuild $@ diff --git a/gitstatus/src/check.h b/gitstatus/src/check.h index 682675a2..82dceae1 100644 --- a/gitstatus/src/check.h +++ b/gitstatus/src/check.h @@ -23,7 +23,7 @@ #include // The argument must be an expression convertible to bool. -// Does nothing if the expression evaluates to true. Otherwise +// Does nothing if the expression evalutes to true. Otherwise // it's equivalent to LOG(FATAL). #define CHECK(cond...) \ static_cast(0), (!!(cond)) ? static_cast(0) : LOG(FATAL) << #cond << ": " diff --git a/gitstatus/src/dir.cc b/gitstatus/src/dir.cc index 39cf1c2c..e7ce7141 100644 --- a/gitstatus/src/dir.cc +++ b/gitstatus/src/dir.cc @@ -106,14 +106,14 @@ bool ListDir(int dir_fd, Arena& arena, std::vector& entries, bool precomp }; constexpr size_t kBufSize = 8 << 10; - const size_t orig_size = entries.size(); + entries.clear(); while (true) { char* buf = static_cast(arena.Allocate(kBufSize, alignof(linux_dirent64))); // Save 256 bytes for the rainy day. int n = syscall(SYS_getdents64, dir_fd, buf, kBufSize - 256); if (n < 0) { - entries.resize(orig_size); + entries.clear(); return false; } for (int pos = 0; pos < n;) { @@ -131,9 +131,9 @@ bool ListDir(int dir_fd, Arena& arena, std::vector& entries, bool precomp } if (case_sensitive) { - SortEntries(entries.data() + orig_size, entries.data() + entries.size()); + SortEntries(entries.data(), entries.data() + entries.size()); } else { - SortEntries(entries.data() + orig_size, entries.data() + entries.size()); + SortEntries(entries.data(), entries.data() + entries.size()); } return true; @@ -211,7 +211,7 @@ char* DirenvConvert(Arena& arena, struct dirent& ent, bool do_convert) { bool ListDir(int dir_fd, Arena& arena, std::vector& entries, bool precompose_unicode, bool case_sensitive) { - const size_t orig_size = entries.size(); + entries.clear(); dir_fd = dup(dir_fd); if (dir_fd < 0) return false; DIR* dir = fdopendir(dir_fd); @@ -225,10 +225,10 @@ bool ListDir(int dir_fd, Arena& arena, std::vector& entries, bool precomp entries.push_back(DirenvConvert(arena, *ent, precompose_unicode)); } if (errno) { - entries.resize(orig_size); + entries.clear(); return false; } - StrSort(entries.data() + orig_size, entries.data() + entries.size(), case_sensitive); + StrSort(entries.data(), entries.data() + entries.size(), case_sensitive); return true; } diff --git a/gitstatus/src/dir.h b/gitstatus/src/dir.h index 2a7533a3..42ab29bb 100644 --- a/gitstatus/src/dir.h +++ b/gitstatus/src/dir.h @@ -25,11 +25,11 @@ namespace gitstatus { -// On error, leaves entries unchanged and returns false. Does not throw. +// On error, clears entries and returns false. Does not throw. // -// On success, appends names of files from the specified directory to entries and returns true. -// Every appended entry is a null-terminated string. At -1 offset is its d_type. All elements -// point into the arena. They are sorted either by strcmp or strcasecmp depending on case_sensitive. +// On success, fills entries with the names of files from the specified directory and returns true. +// Every entry is a null-terminated string. At -1 offset is its d_type. All elements point into the +// arena. They are sorted either by strcmp or strcasecmp depending on case_sensitive. // // Does not close dir_fd. // diff --git a/gitstatus/src/git.cc b/gitstatus/src/git.cc index 552100cb..029b02bf 100644 --- a/gitstatus/src/git.cc +++ b/gitstatus/src/git.cc @@ -239,12 +239,4 @@ PushRemotePtr GetPushRemote(git_repository* repo, const git_reference* local) { return PushRemotePtr(res.release()); } -CommitMessage GetCommitMessage(git_repository* repo, const git_oid& id) { - git_commit* commit; - VERIFY(!git_commit_lookup(&commit, repo, &id)) << GitError(); - ON_SCOPE_EXIT(=) { git_commit_free(commit); }; - return {.encoding = git_commit_message_encoding(commit) ?: "", - .summary = git_commit_summary(commit) ?: ""}; -} - } // namespace gitstatus diff --git a/gitstatus/src/git.h b/gitstatus/src/git.h index b85f09f7..7e5a6f9d 100644 --- a/gitstatus/src/git.h +++ b/gitstatus/src/git.h @@ -48,15 +48,6 @@ git_reference* Head(git_repository* repo); // Returns the name of the local branch, or an empty string. const char* LocalBranchName(const git_reference* ref); -struct CommitMessage { - // Can be empty, meaning "UTF-8". - std::string encoding; - // The first paragraph of the commit's message as a one-liner. - std::string summary; -}; - -CommitMessage GetCommitMessage(git_repository* repo, const git_oid& id); - struct Remote { // Tip of the remote branch. git_reference* ref; diff --git a/gitstatus/src/gitstatus.cc b/gitstatus/src/gitstatus.cc index 81399ea7..5560ca8d 100644 --- a/gitstatus/src/gitstatus.cc +++ b/gitstatus/src/gitstatus.cc @@ -41,10 +41,6 @@ namespace { using namespace std::string_literals; -void Truncate(std::string& s, size_t max_len) { - if (s.size() > max_len) s.resize(max_len); -} - void ProcessRequest(const Options& opts, RepoCache& cache, Request req) { Timer timer; ON_SCOPE_EXIT(&) { timer.Report("request"); }; @@ -171,11 +167,6 @@ void ProcessRequest(const Options& opts, RepoCache& cache, Request req) { // The number of files in the index with assume-unchanged bit set. resp.Print(stats.num_assume_unchanged); - CommitMessage msg = head_target ? GetCommitMessage(repo->repo(), *head_target) : CommitMessage(); - Truncate(msg.summary, opts.max_commit_summary_length); - resp.Print(msg.encoding); - resp.Print(msg.summary); - resp.Dump("with git status"); } diff --git a/gitstatus/src/index.cc b/gitstatus/src/index.cc index 4d66876b..ae8ca54c 100644 --- a/gitstatus/src/index.cc +++ b/gitstatus/src/index.cc @@ -242,7 +242,6 @@ std::vector ScanDirs(git_index* index, int root_fd, IndexDir* const dir.st = st; } - entries.clear(); arena.Reuse(); if (!ListDir(*dir_fd, arena, entries, caps.precompose_unicode, caps.case_sensitive)) { AddUnmached(""); diff --git a/gitstatus/src/options.cc b/gitstatus/src/options.cc index b7abe5db..421e5854 100644 --- a/gitstatus/src/options.cc +++ b/gitstatus/src/options.cc @@ -53,15 +53,9 @@ long ParseInt(const char* s) { return res; } -size_t ParseSizeT(const char* s) { - static_assert(sizeof(long) <= sizeof(size_t), ""); - long res = ParseLong(s); - return res >= 0 ? res : -1; -} - void PrintUsage() { std::cout << "Usage: gitstatusd [OPTION]...\n" - << "Print machine-readable status of the git repos for directories in stdin.\n" + << "Print machine-readable status of the git repos for directores in stdin.\n" << "\n" << "OPTIONS\n" << " -l, --lock-fd=NUM [default=-1]\n" @@ -78,7 +72,7 @@ void PrintUsage() { << " maximum performance.\n" << "\n" << " -v, --log-level=STR [default=INFO]\n" - << " Don't write entries to log whose log level is below this. Log levels in\n" + << " Don't write entires to log whose log level is below this. Log levels in\n" << " increasing order: DEBUG, INFO, WARN, ERROR, FATAL.\n" << "\n" << " -r, --repo-ttl-seconds=NUM [default=3600]\n" @@ -87,18 +81,12 @@ void PrintUsage() { << " repo that's been closed is much slower than for a repo that hasn't been.\n" << " Negative value means infinity.\n" << "\n" - << " -z, --max-commit-summary-length=NUM [default=256]\n" - << " Truncate commit summary if it's longer than this many bytes.\n" - << "\n" << " -s, --max-num-staged=NUM [default=1]\n" << " Report at most this many staged changes; negative value means infinity.\n" << "\n" << " -u, --max-num-unstaged=NUM [default=1]\n" << " Report at most this many unstaged changes; negative value means infinity.\n" << "\n" - << " -c, --max-num-conflicted=NUM [default=1]\n" - << " Report at most this many conflicted changes; negative value means infinity.\n" - << "\n" << " -d, --max-num-untracked=NUM [default=1]\n" << " Report at most this many untracked files; negative value means infinity.\n" << "\n" @@ -141,7 +129,7 @@ void PrintUsage() { << "\n" << " 1. Request ID. Any string. Can be empty.\n" << " 2. Path to the directory for which git stats are being requested.\n" - << " If the first character is ':', it is removed and the remaining path\n" + << " If the first character is ':', it is removed and the remaning path\n" << " is treated as GIT_DIR.\n" << " 3. (Optional) '1' to disable computation of anything that requires reading\n" << " git index; '0' for the default behavior of computing everything.\n" @@ -182,8 +170,6 @@ void PrintUsage() { << " 25. Number of commits the current branch is behind push remote.\n" << " 26. Number of files in the index with skip-worktree bit set.\n" << " 27. Number of files in the index with assume-unchanged bit set.\n" - << " 28. Encoding of the HEAD's commit message. Empty value means UTF-8.\n" - << " 29. The first paragraph of the HEAD's commit message as one line.\n" << "\n" << "Note: Renamed files are reported as deleted plus new.\n" << "\n" @@ -226,8 +212,6 @@ void PrintUsage() { << " '0'\n" << " '0'\n" << " '0'\n" - << " ''\n" - << " 'add a build server for darwin-arm64'\n" << "\n" << "EXIT STATUS\n" << "\n" @@ -255,13 +239,12 @@ const char* Version() { Options ParseOptions(int argc, char** argv) { const struct option opts[] = {{"help", no_argument, nullptr, 'h'}, {"version", no_argument, nullptr, 'V'}, - {"version-glob", required_argument, nullptr, 'G'}, + {"version-glob", no_argument, nullptr, 'G'}, {"lock-fd", required_argument, nullptr, 'l'}, {"parent-pid", required_argument, nullptr, 'p'}, {"num-threads", required_argument, nullptr, 't'}, {"log-level", required_argument, nullptr, 'v'}, {"repo-ttl-seconds", required_argument, nullptr, 'r'}, - {"max-commit-summary-length", required_argument, nullptr, 'z'}, {"max-num-staged", required_argument, nullptr, 's'}, {"max-num-unstaged", required_argument, nullptr, 'u'}, {"max-num-conflicted", required_argument, nullptr, 'c'}, @@ -274,7 +257,7 @@ Options ParseOptions(int argc, char** argv) { {}}; Options res; while (true) { - switch (getopt_long(argc, argv, "hVG:l:p:t:v:r:z:s:u:c:d:m:eUWD", opts, nullptr)) { + switch (getopt_long(argc, argv, "hVG:l:p:t:v:r:s:u:c:d:m:eUWD", opts, nullptr)) { case -1: if (optind != argc) { std::cerr << "unexpected positional argument: " << argv[optind] << std::endl; @@ -323,23 +306,20 @@ Options ParseOptions(int argc, char** argv) { res.num_threads = n; break; } - case 'z': - res.max_commit_summary_length = ParseSizeT(optarg); - break; case 's': - res.max_num_staged = ParseSizeT(optarg); + res.max_num_staged = ParseLong(optarg); break; case 'u': - res.max_num_unstaged = ParseSizeT(optarg); + res.max_num_unstaged = ParseLong(optarg); break; case 'c': - res.max_num_conflicted = ParseSizeT(optarg); + res.max_num_conflicted = ParseLong(optarg); break; case 'd': - res.max_num_untracked = ParseSizeT(optarg); + res.max_num_untracked = ParseLong(optarg); break; case 'm': - res.dirty_max_index_size = ParseSizeT(optarg); + res.dirty_max_index_size = ParseLong(optarg); break; case 'e': res.recurse_untracked_dirs = true; diff --git a/gitstatus/src/options.h b/gitstatus/src/options.h index bb373155..7cbfeed8 100644 --- a/gitstatus/src/options.h +++ b/gitstatus/src/options.h @@ -27,8 +27,6 @@ namespace gitstatus { struct Limits { - // Truncate commit summary if it's longer than this many bytes. - size_t max_commit_summary_length = 256; // Report at most this many staged changes. size_t max_num_staged = 1; // Report at most this many unstaged changes. @@ -62,7 +60,7 @@ struct Options : Limits { // If non-negative, send signal 0 to the specified PID when not receiving any requests for one // second; exit if signal sending fails. int parent_pid = -1; - // Don't write entries to log whose log level is below this. Log levels in increasing order: + // Don't write entires to log whose log level is below this. Log levels in increasing order: // DEBUG, INFO, WARN, ERROR, FATAL. LogLevel log_level = INFO; // Close git repositories that haven't been used for this long. This is meant to release resources diff --git a/gitstatus/src/repo.cc b/gitstatus/src/repo.cc index a81594a4..d7ea7d3e 100644 --- a/gitstatus/src/repo.cc +++ b/gitstatus/src/repo.cc @@ -155,7 +155,7 @@ IndexStats Repo::GetIndexStats(const git_oid* head, git_config* cfg) { VERIFY(!git_repository_index(&git_index_, repo_)) << GitError(); // Query an attribute (doesn't matter which) to initialize repo's attribute // cache. It's a workaround for synchronization bugs (data races) in libgit2 - // that result from lazy cache initialization without synchronization. + // that result from lazy cache initialization without synchrnonization. // Thankfully, subsequent cache reads and writes are properly synchronized. const char* attr; VERIFY(!git_attr_get(&attr, repo_, 0, "x", "x")) << GitError(); diff --git a/gitstatus/src/tag_db.cc b/gitstatus/src/tag_db.cc index 8bd445c7..0e440791 100644 --- a/gitstatus/src/tag_db.cc +++ b/gitstatus/src/tag_db.cc @@ -155,8 +155,6 @@ void TagDb::ReadLooseTags() { int dir_fd = open(dirname.c_str(), O_RDONLY | O_DIRECTORY | O_CLOEXEC); if (dir_fd < 0) return; ON_SCOPE_EXIT(&) { CHECK(!close(dir_fd)) << Errno(); }; - // TODO: recursively traverse directories so that the file refs/tags/foo/bar gets interpreted - // as the tag foo/bar. See https://github.com/romkatv/gitstatus/issues/254. (void)ListDir(dir_fd, loose_arena_, loose_tags_, /* precompose_unicode = */ false, /* case_sensitive = */ true); } @@ -214,30 +212,14 @@ void TagDb::ParsePack() { char* p = &pack_[0]; char* e = p + pack_.size(); - // Usually packed-refs starts with the following line: - // - // # pack-refs with: peeled fully-peeled sorted - // - // However, some users can produce pack-refs without this line. - // See https://github.com/romkatv/powerlevel10k/issues/1428. - // I don't know how they do it. Without the header line we cannot - // assume that refs are sorted, which isn't a big deal because we - // can just sort them. What's worse is that refs cannot be assumed - // to be fully-peeled. We don't want to peel them, so we just drop - // all tags. - if (*p != '#') { - LOG(WARN) << "packed-refs doesn't have a header. Won't resolve tags."; - return; + if (*p == '#') { + char* eol = std::strchr(p, '\n'); + if (!eol) return; + *eol = 0; + if (!std::strstr(p, " fully-peeled") || !std::strstr(p, " sorted")) return; + p = eol + 1; } - char* eol = std::strchr(p, '\n'); - if (!eol) return; - *eol = 0; - if (!std::strstr(p, " fully-peeled") || !std::strstr(p, " sorted")) { - LOG(WARN) << "packed-refs has unexpected header. Won't resolve tags."; - } - p = eol + 1; - name2id_.reserve(pack_.size() / 128); id2name_.reserve(pack_.size() / 128); @@ -267,10 +249,7 @@ void TagDb::ParsePack() { id2name_.push_back(tag); } - if (!std::is_sorted(name2id_.begin(), name2id_.end(), ByName)) { - // "sorted" in the header of packed-refs promises that this won't trigger. - std::sort(name2id_.begin(), name2id_.end(), ByName); - } + VERIFY(std::is_sorted(name2id_.begin(), name2id_.end(), ByName)); id2name_dirty_ = true; GlobalThreadPool()->Schedule([this] { diff --git a/internal/configure.zsh b/internal/configure.zsh index 0e13bdec..4fb7cb6e 100644 --- a/internal/configure.zsh +++ b/internal/configure.zsh @@ -18,6 +18,7 @@ function _p9k_can_configure() { typeset -g __p9k_cfg_path=${__p9k_cfg_path_o:A} typeset -g __p9k_cfg_path_u=${${${(q)__p9k_cfg_path_o}/#(#b)${(q)HOME}(|\/*)/'~'$match[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 } [[ ! -d $__p9k_cfg_path ]] || { $0_error "$__p9k_cfg_path_u is a directory"; return 1 } @@ -58,10 +59,7 @@ function _p9k_can_configure() { $0_error "terminal size too small; must be at least $__p9k_wizard_columns columns by $__p9k_wizard_lines lines" return 1 } - [[ -t 0 && -t 1 ]] || { - $0_error "no TTY" - return 2 - } + [[ -t 0 && -t 1 ]] || { $0_error "no TTY"; return 2 } return 0 } always { unfunction $0_error diff --git a/internal/icons.zsh b/internal/icons.zsh index d34b2c0e..532ab0a6 100644 --- a/internal/icons.zsh +++ b/internal/icons.zsh @@ -52,7 +52,6 @@ function _p9k_init_icons() { LINUX_DEBIAN_ICON '\uE271'$s #  LINUX_RASPBIAN_ICON '\uE271'$s #  LINUX_UBUNTU_ICON '\uE271'$s #  - LINUX_KALI_ICON '\uE271'$s #  LINUX_CENTOS_ICON '\uE271'$s #  LINUX_COREOS_ICON '\uE271'$s #  LINUX_ELEMENTARY_ICON '\uE271'$s #  @@ -70,12 +69,6 @@ function _p9k_init_icons() { LINUX_SLACKWARE_ICON '\uE271'$s #  LINUX_VOID_ICON '\uE271'$s #  LINUX_ARTIX_ICON '\uE271'$s #  - LINUX_RHEL_ICON '\uE271'$s #  - LINUX_AMZN_ICON '\uE271'$s #  - LINUX_ENDEAVOUROS_ICON '\uE271'$s #  - LINUX_ROCKY_ICON '\uE271'$s #  - LINUX_GUIX_ICON '\uE271'$s #  - LINUX_NEON_ICON '\uE271'$s #  SUNOS_ICON '\U1F31E'$q # 🌞 HOME_ICON '\uE12C'$s #  HOME_SUB_ICON '\uE18D'$s #  @@ -106,23 +99,10 @@ function _p9k_init_icons() { VCS_GIT_GITHUB_ICON '\uE20E ' # VCS_GIT_BITBUCKET_ICON '\uE20E ' # VCS_GIT_GITLAB_ICON '\uE20E ' # - VCS_GIT_AZURE_ICON '\uE20E ' # - VCS_GIT_ARCHLINUX_ICON '\uE20E ' # - VCS_GIT_CODEBERG_ICON '\uE20E ' # - VCS_GIT_DEBIAN_ICON '\uE20E ' # - VCS_GIT_FREEBSD_ICON '\uE20E ' # - VCS_GIT_FREEDESKTOP_ICON '\uE20E ' # - VCS_GIT_GNOME_ICON '\uE20E ' # - VCS_GIT_GNU_ICON '\uE20E ' # - VCS_GIT_KDE_ICON '\uE20E ' # - VCS_GIT_LINUX_ICON '\uE20E ' # - VCS_GIT_GITEA_ICON '\uE20E ' # - VCS_GIT_SOURCEHUT_ICON '\uE20E ' # VCS_HG_ICON '\uE1C3 ' #  VCS_SVN_ICON 'svn'$q RUST_ICON 'R' PYTHON_ICON '\uE63C'$s #  (doesn't always work) - CHEZMOI_ICON '\uE12C'$s #  SWIFT_ICON 'Swift' GO_ICON 'Go' GOLANG_ICON 'Go' @@ -139,7 +119,6 @@ function _p9k_init_icons() { JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ - YAZI_ICON '\u2B50' # ⭐ MIDNIGHT_COMMANDER_ICON 'mc' VIM_ICON 'vim' TERRAFORM_ICON 'tf' @@ -153,8 +132,6 @@ function _p9k_init_icons() { LUA_ICON 'lua' PERL_ICON 'perl' NNN_ICON 'nnn' - LF_ICON 'lf' - XPLR_ICON 'xplr' TIMEWARRIOR_ICON 'tw' TASKWARRIOR_ICON 'task' NIX_SHELL_ICON 'nix' @@ -167,9 +144,6 @@ function _p9k_init_icons() { PACKAGE_ICON 'pkg' JULIA_ICON 'jl' SCALA_ICON 'scala' - TOOLBOX_ICON '\u2B22' # ⬢ - ARCH_ICON 'arch' - HISTORY_ICON 'hist' ) ;; 'awesome-fontconfig') @@ -210,7 +184,6 @@ function _p9k_init_icons() { LINUX_DEBIAN_ICON '\uF17C'$s #  LINUX_RASPBIAN_ICON '\uF17C'$s #  LINUX_UBUNTU_ICON '\uF17C'$s #  - LINUX_KALI_ICON '\uF17C'$s #  LINUX_CENTOS_ICON '\uF17C'$s #  LINUX_COREOS_ICON '\uF17C'$s #  LINUX_ELEMENTARY_ICON '\uF17C'$s #  @@ -228,12 +201,6 @@ function _p9k_init_icons() { LINUX_SLACKWARE_ICON '\uF17C'$s #  LINUX_VOID_ICON '\uF17C'$s #  LINUX_ARTIX_ICON '\uF17C'$s #  - LINUX_RHEL_ICON '\uF17C'$s #  - LINUX_AMZN_ICON '\uF17C'$s #  - LINUX_ENDEAVOUROS_ICON '\uF17C'$s #  - LINUX_ROCKY_ICON '\uF17C'$s #  - LINUX_GUIX_ICON '\uF17C'$s #  - LINUX_NEON_ICON '\uF17C'$s #  SUNOS_ICON '\uF185 ' #  HOME_ICON '\uF015'$s #  HOME_SUB_ICON '\uF07C'$s #  @@ -260,23 +227,10 @@ function _p9k_init_icons() { VCS_GIT_GITHUB_ICON '\uF113 ' #  VCS_GIT_BITBUCKET_ICON '\uF171 ' #  VCS_GIT_GITLAB_ICON '\uF296 ' #  - VCS_GIT_AZURE_ICON '\u2601 ' # ☁ - VCS_GIT_ARCHLINUX_ICON '\uF1D3 ' #  - VCS_GIT_CODEBERG_ICON '\uF1D3 ' #  - VCS_GIT_DEBIAN_ICON '\uF1D3 ' #  - VCS_GIT_FREEBSD_ICON '\uF1D3 ' #  - VCS_GIT_FREEDESKTOP_ICON '\uF1D3 ' #  - VCS_GIT_GNOME_ICON '\uF1D3 ' #  - VCS_GIT_GNU_ICON '\uF1D3 ' #  - VCS_GIT_KDE_ICON '\uF1D3 ' #  - VCS_GIT_LINUX_ICON '\uF1D3 ' #  - VCS_GIT_GITEA_ICON '\uF1D3 ' #  - VCS_GIT_SOURCEHUT_ICON '\uF1D3 ' #  VCS_HG_ICON '\uF0C3 ' #  VCS_SVN_ICON 'svn'$q RUST_ICON '\uE6A8' #  PYTHON_ICON '\uE63C'$s #  - CHEZMOI_ICON '\uF015'$s #  SWIFT_ICON 'Swift' GO_ICON 'Go' GOLANG_ICON 'Go' @@ -293,7 +247,6 @@ function _p9k_init_icons() { JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ - YAZI_ICON '\u2B50' # ⭐ MIDNIGHT_COMMANDER_ICON 'mc' VIM_ICON 'vim' TERRAFORM_ICON 'tf' @@ -307,8 +260,6 @@ function _p9k_init_icons() { LUA_ICON 'lua' PERL_ICON 'perl' NNN_ICON 'nnn' - LF_ICON 'lf' - XPLR_ICON 'xplr' TIMEWARRIOR_ICON 'tw' TASKWARRIOR_ICON 'task' NIX_SHELL_ICON 'nix' @@ -321,9 +272,6 @@ function _p9k_init_icons() { PACKAGE_ICON 'pkg' JULIA_ICON 'jl' SCALA_ICON 'scala' - TOOLBOX_ICON '\u2B22' # ⬢ - ARCH_ICON 'arch' - HISTORY_ICON 'hist' ) ;; 'awesome-mapped-fontconfig') @@ -369,7 +317,6 @@ function _p9k_init_icons() { LINUX_DEBIAN_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" LINUX_RASPBIAN_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" LINUX_UBUNTU_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_KALI_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" LINUX_CENTOS_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" LINUX_COREOS_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" LINUX_ELEMENTARY_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" @@ -387,12 +334,6 @@ function _p9k_init_icons() { LINUX_SLACKWARE_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" LINUX_VOID_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" LINUX_ARTIX_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_RHEL_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_AMZN_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_ENDEAVOUROS_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_ROCKY_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_GUIX_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" - LINUX_NEON_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}" SUNOS_ICON "${CODEPOINT_OF_AWESOME_SUN_O:+\\u$CODEPOINT_OF_AWESOME_SUN_O }" HOME_ICON "${CODEPOINT_OF_AWESOME_HOME:+\\u$CODEPOINT_OF_AWESOME_HOME$s}" HOME_SUB_ICON "${CODEPOINT_OF_AWESOME_FOLDER_OPEN:+\\u$CODEPOINT_OF_AWESOME_FOLDER_OPEN$s}" @@ -419,23 +360,10 @@ function _p9k_init_icons() { VCS_GIT_GITHUB_ICON "${CODEPOINT_OF_AWESOME_GITHUB_ALT:+\\u$CODEPOINT_OF_AWESOME_GITHUB_ALT }" VCS_GIT_BITBUCKET_ICON "${CODEPOINT_OF_AWESOME_BITBUCKET:+\\u$CODEPOINT_OF_AWESOME_BITBUCKET }" VCS_GIT_GITLAB_ICON "${CODEPOINT_OF_AWESOME_GITLAB:+\\u$CODEPOINT_OF_AWESOME_GITLAB }" - VCS_GIT_AZURE_ICON '\u2601 ' # ☁ - VCS_GIT_ARCHLINUX_ICON "${CODEPOINT_OF_AWESOME_GIT:+\\u$CODEPOINT_OF_AWESOME_GIT }" - VCS_GIT_CODEBERG_ICON "${CODEPOINT_OF_AWESOME_GIT:+\\u$CODEPOINT_OF_AWESOME_GIT }" - VCS_GIT_DEBIAN_ICON "${CODEPOINT_OF_AWESOME_GIT:+\\u$CODEPOINT_OF_AWESOME_GIT }" - VCS_GIT_FREEBSD_ICON "${CODEPOINT_OF_AWESOME_GIT:+\\u$CODEPOINT_OF_AWESOME_GIT }" - VCS_GIT_FREEDESKTOP_ICON "${CODEPOINT_OF_AWESOME_GIT:+\\u$CODEPOINT_OF_AWESOME_GIT }" - VCS_GIT_GNOME_ICON "${CODEPOINT_OF_AWESOME_GIT:+\\u$CODEPOINT_OF_AWESOME_GIT }" - VCS_GIT_GNU_ICON "${CODEPOINT_OF_AWESOME_GIT:+\\u$CODEPOINT_OF_AWESOME_GIT }" - VCS_GIT_KDE_ICON "${CODEPOINT_OF_AWESOME_GIT:+\\u$CODEPOINT_OF_AWESOME_GIT }" - VCS_GIT_LINUX_ICON "${CODEPOINT_OF_AWESOME_GIT:+\\u$CODEPOINT_OF_AWESOME_GIT }" - VCS_GIT_GITEA_ICON "${CODEPOINT_OF_AWESOME_GIT:+\\u$CODEPOINT_OF_AWESOME_GIT }" - VCS_GIT_SOURCEHUT_ICON "${CODEPOINT_OF_AWESOME_GIT:+\\u$CODEPOINT_OF_AWESOME_GIT }" VCS_HG_ICON "${CODEPOINT_OF_AWESOME_FLASK:+\\u$CODEPOINT_OF_AWESOME_FLASK }" VCS_SVN_ICON 'svn'$q RUST_ICON '\uE6A8' #  PYTHON_ICON '\U1F40D' # 🐍 - CHEZMOI_ICON "${CODEPOINT_OF_AWESOME_HOME:+\\u$CODEPOINT_OF_AWESOME_HOME$s}" SWIFT_ICON '\uE655'$s #  PUBLIC_IP_ICON "${CODEPOINT_OF_AWESOME_GLOBE:+\\u$CODEPOINT_OF_AWESOME_GLOBE$s}" LOCK_ICON "${CODEPOINT_OF_AWESOME_LOCK:+\\u$CODEPOINT_OF_AWESOME_LOCK}" @@ -450,7 +378,6 @@ function _p9k_init_icons() { JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ - YAZI_ICON '\u2B50' # ⭐ MIDNIGHT_COMMANDER_ICON 'mc' VIM_ICON 'vim' TERRAFORM_ICON 'tf' @@ -464,8 +391,6 @@ function _p9k_init_icons() { LUA_ICON 'lua' PERL_ICON 'perl' NNN_ICON 'nnn' - LF_ICON 'lf' - XPLR_ICON 'xplr' TIMEWARRIOR_ICON 'tw' TASKWARRIOR_ICON 'task' NIX_SHELL_ICON 'nix' @@ -478,169 +403,6 @@ function _p9k_init_icons() { PACKAGE_ICON 'pkg' JULIA_ICON 'jl' SCALA_ICON 'scala' - TOOLBOX_ICON '\u2B22' # ⬢ - ARCH_ICON 'arch' - HISTORY_ICON 'hist' - ) - ;; - 'nerdfont-v3') - # In this version of Nerd Fonts the Material icons are mapped to U+F0001-U+F19C3. - # The font may also have Material icons in the old range of U+F500-U+FD46 but - # powerlevel10k won't rely on them. - icons=( - RULER_CHAR '\u2500' # ─ - LEFT_SEGMENT_SEPARATOR '\uE0B0' #  - RIGHT_SEGMENT_SEPARATOR '\uE0B2' #  - LEFT_SEGMENT_END_SEPARATOR ' ' # - LEFT_SUBSEGMENT_SEPARATOR '\uE0B1' #  - RIGHT_SUBSEGMENT_SEPARATOR '\uE0B3' #  - CARRIAGE_RETURN_ICON '\u21B5' # ↵ - ROOT_ICON '\uE614'$q #  - SUDO_ICON '\uF09C'$s #  - RUBY_ICON '\uF219 ' #  - AWS_ICON '\uF270'$s #  - AWS_EB_ICON '\UF1BD'$q$q #  - BACKGROUND_JOBS_ICON '\uF013 ' #  - TEST_ICON '\uF188'$s #  - TODO_ICON '\u2611' # ☑ - BATTERY_ICON '\UF240 ' #  - DISK_ICON '\uF0A0'$s #  - OK_ICON '\uF00C'$s #  - FAIL_ICON '\uF00D' #  - SYMFONY_ICON '\uE757' #  - NODE_ICON '\uE617 ' #  - NODEJS_ICON '\uE617 ' #  - MULTILINE_FIRST_PROMPT_PREFIX '\u256D\U2500' # ╭─ - MULTILINE_NEWLINE_PROMPT_PREFIX '\u251C\U2500' # ├─ - MULTILINE_LAST_PROMPT_PREFIX '\u2570\U2500 ' # ╰─ - APPLE_ICON '\uF179' #  - WINDOWS_ICON '\uF17A'$s #  - FREEBSD_ICON '\UF30C ' #  - ANDROID_ICON '\uF17B' #  - LINUX_ARCH_ICON '\uF303' #  - LINUX_CENTOS_ICON '\uF304'$s #  - LINUX_COREOS_ICON '\uF305'$s #  - LINUX_DEBIAN_ICON '\uF306' #  - LINUX_RASPBIAN_ICON '\uF315' #  - LINUX_ELEMENTARY_ICON '\uF309'$s #  - LINUX_FEDORA_ICON '\uF30a'$s #  - LINUX_GENTOO_ICON '\uF30d'$s #  - LINUX_MAGEIA_ICON '\uF310' #  - LINUX_MINT_ICON '\uF30e'$s #  - LINUX_NIXOS_ICON '\uF313'$s #  - LINUX_MANJARO_ICON '\uF312'$s #  - LINUX_DEVUAN_ICON '\uF307'$s #  - LINUX_ALPINE_ICON '\uF300'$s #  - LINUX_AOSC_ICON '\uF301'$s #  - LINUX_OPENSUSE_ICON '\uF314'$s #  - LINUX_SABAYON_ICON '\uF317'$s #  - LINUX_SLACKWARE_ICON '\uF319'$s #  - LINUX_VOID_ICON '\UF32E'$s #  - LINUX_ARTIX_ICON '\UF31F'$s #  - LINUX_UBUNTU_ICON '\uF31b'$s #  - LINUX_KALI_ICON '\uF327'$s #  - LINUX_RHEL_ICON '\UF111B'$s # 󱄛 - LINUX_AMZN_ICON '\uF270'$s #  - LINUX_ENDEAVOUROS_ICON '\UF322'$s #  - LINUX_ROCKY_ICON '\UF32B'$s #  - LINUX_GUIX_ICON '\UF325'$s #  - LINUX_NEON_ICON '\uF17C' #  - LINUX_ICON '\uF17C' #  - SUNOS_ICON '\uF185 ' #  - HOME_ICON '\uF015'$s #  - HOME_SUB_ICON '\uF07C'$s #  - FOLDER_ICON '\uF115'$s #  - ETC_ICON '\uF013'$s #  - NETWORK_ICON '\UF0378'$s # 󰍸 - LOAD_ICON '\uF080 ' #  - SWAP_ICON '\uF464'$s #  - RAM_ICON '\uF0E4'$s #  - SERVER_ICON '\uF0AE'$s #  - VCS_UNTRACKED_ICON '\uF059'$s #  - VCS_UNSTAGED_ICON '\uF06A'$s #  - VCS_STAGED_ICON '\uF055'$s #  - VCS_STASH_ICON '\uF01C ' #  - VCS_INCOMING_CHANGES_ICON '\uF01A ' #  - VCS_OUTGOING_CHANGES_ICON '\uF01B ' #  - VCS_TAG_ICON '\uF02B ' #  - VCS_BOOKMARK_ICON '\uF461 ' #  - VCS_COMMIT_ICON '\uE729 ' #  - VCS_BRANCH_ICON '\uF126 ' #  - VCS_REMOTE_BRANCH_ICON '\uE728 ' #  - VCS_LOADING_ICON '' # - VCS_GIT_ICON '\uF1D3 ' #  - VCS_GIT_GITHUB_ICON '\uF113 ' #  - VCS_GIT_BITBUCKET_ICON '\uE703 ' #  - VCS_GIT_GITLAB_ICON '\uF296 ' #  - VCS_GIT_AZURE_ICON '\uEBE8 ' #  - VCS_GIT_ARCHLINUX_ICON '\uF303 ' #  - # v3.1 has \uF330. - VCS_GIT_CODEBERG_ICON '\uF1D3 ' #  - VCS_GIT_DEBIAN_ICON '\uF306 ' #  - VCS_GIT_FREEBSD_ICON '\UF30C ' #  - # v3.1 has \uF360. - VCS_GIT_FREEDESKTOP_ICON '\uF296 ' #  - # v3.1 has \uF361. - VCS_GIT_GNOME_ICON '\uF296 ' #  - VCS_GIT_GNU_ICON '\uE779 ' #  - # v3.1 has \uF332. - VCS_GIT_KDE_ICON '\uF296 ' #  - VCS_GIT_LINUX_ICON '\uF17C ' #  - # v3.1 has \uF339. - VCS_GIT_GITEA_ICON '\uF1D3 ' #  - VCS_GIT_SOURCEHUT_ICON '\uF1DB ' #  - VCS_HG_ICON '\uF0C3 ' #  - VCS_SVN_ICON '\uE72D'$q #  - RUST_ICON '\uE7A8'$q #  - PYTHON_ICON '\UE73C ' #  - CHEZMOI_ICON '\uF015'$s #  - SWIFT_ICON '\uE755' #  - GO_ICON '\uE626' #  - GOLANG_ICON '\uE626' #  - PUBLIC_IP_ICON '\UF0AC'$s #  - LOCK_ICON '\UF023' #  - NORDVPN_ICON '\UF023' #  - EXECUTION_TIME_ICON '\uF252'$s #  - SSH_ICON '\uF489'$s #  - VPN_ICON '\UF023' #  - KUBERNETES_ICON '\UF10FE' # 󱃾 - DROPBOX_ICON '\UF16B'$s #  - DATE_ICON '\uF073 ' #  - TIME_ICON '\uF017 ' #  - JAVA_ICON '\uE738' #  - LARAVEL_ICON '\ue73f'$q #  - RANGER_ICON '\uF00b ' #  - YAZI_ICON '\uF00b ' #  - MIDNIGHT_COMMANDER_ICON 'mc' # mc - VIM_ICON '\uE62B' #  - TERRAFORM_ICON '\uF1BB ' #  - PROXY_ICON '\u2194' # ↔ - DOTNET_ICON '\uE77F' #  - DOTNET_CORE_ICON '\uE77F' #  - AZURE_ICON '\uEBD8 ' #  - DIRENV_ICON '\u25BC' # ▼ - FLUTTER_ICON 'F' # F - GCLOUD_ICON '\UF02AD' # 󰊭 - LUA_ICON '\uE620' #  - PERL_ICON '\uE769' #  - NNN_ICON 'nnn' # nnn - LF_ICON 'lf' # lf - XPLR_ICON 'xplr' # xplr - TIMEWARRIOR_ICON '\uF49B' #  - TASKWARRIOR_ICON '\uF4A0 ' #  - NIX_SHELL_ICON '\uF313 ' #  - WIFI_ICON '\uF1EB ' #  - ERLANG_ICON '\uE7B1 ' #  - ELIXIR_ICON '\uE62D' #  - POSTGRES_ICON '\uE76E' #  - PHP_ICON '\uE608' #  - HASKELL_ICON '\uE61F' #  - PACKAGE_ICON '\UF03D7' # 󰏗 - JULIA_ICON '\uE624' #  - SCALA_ICON '\uE737' #  - TOOLBOX_ICON '\uE20F'$s #  - ARCH_ICON '\uE266' #  - HISTORY_ICON '\uF1DA'$s #  ) ;; 'nerdfont-complete'|'nerdfont-fontconfig') @@ -698,13 +460,6 @@ function _p9k_init_icons() { LINUX_VOID_ICON '\uF17C' #  LINUX_ARTIX_ICON '\uF17C' #  LINUX_UBUNTU_ICON '\uF31b'$s #  - LINUX_KALI_ICON '\uF17C' #  - LINUX_RHEL_ICON '\uF316'$s #  - LINUX_AMZN_ICON '\uF270'$s #  - LINUX_ENDEAVOUROS_ICON '\uF17C' #  - LINUX_ROCKY_ICON '\uF17C' #  - LINUX_GUIX_ICON '\uF325'$s #  - LINUX_NEON_ICON '\uF17C' #  LINUX_ICON '\uF17C' #  SUNOS_ICON '\uF185 ' #  HOME_ICON '\uF015'$s #  @@ -732,23 +487,10 @@ function _p9k_init_icons() { VCS_GIT_GITHUB_ICON '\uF113 ' #  VCS_GIT_BITBUCKET_ICON '\uE703 ' #  VCS_GIT_GITLAB_ICON '\uF296 ' #  - VCS_GIT_AZURE_ICON '\uFD03 ' # ﴃ - VCS_GIT_ARCHLINUX_ICON '\uF303 ' #  - VCS_GIT_CODEBERG_ICON '\uF1D3 ' #  - VCS_GIT_DEBIAN_ICON '\uF306 ' #  - VCS_GIT_FREEBSD_ICON '\UF30C ' #  - VCS_GIT_FREEDESKTOP_ICON '\uF296 ' #  - VCS_GIT_GNOME_ICON '\uF296 ' #  - VCS_GIT_GNU_ICON '\uE779 ' #  - VCS_GIT_KDE_ICON '\uF296 ' #  - VCS_GIT_LINUX_ICON '\uF17C ' #  - VCS_GIT_GITEA_ICON '\uF1D3 ' #  - VCS_GIT_SOURCEHUT_ICON '\uF1DB ' #  VCS_HG_ICON '\uF0C3 ' #  VCS_SVN_ICON '\uE72D'$q #  RUST_ICON '\uE7A8'$q #  PYTHON_ICON '\UE73C ' #  - CHEZMOI_ICON '\uF015'$s #  SWIFT_ICON '\uE755' #  GO_ICON '\uE626' #  GOLANG_ICON '\uE626' #  @@ -765,7 +507,6 @@ function _p9k_init_icons() { JAVA_ICON '\uE738' #  LARAVEL_ICON '\ue73f'$q #  RANGER_ICON '\uF00b ' #  - YAZI_ICON '\uF00b ' #  MIDNIGHT_COMMANDER_ICON 'mc' VIM_ICON '\uE62B' #  TERRAFORM_ICON '\uF1BB ' #  @@ -779,8 +520,6 @@ function _p9k_init_icons() { LUA_ICON '\uE620' #  PERL_ICON '\uE769' #  NNN_ICON 'nnn' - LF_ICON 'lf' - XPLR_ICON 'xplr' TIMEWARRIOR_ICON '\uF49B' #  TASKWARRIOR_ICON '\uF4A0 ' #  NIX_SHELL_ICON '\uF313 ' #  @@ -793,9 +532,6 @@ function _p9k_init_icons() { PACKAGE_ICON '\uF8D6' #  JULIA_ICON '\uE624' #  SCALA_ICON '\uE737' #  - TOOLBOX_ICON '\uE20F'$s #  - ARCH_ICON '\uE266' #  - HISTORY_ICON '\uF1DA'$s #  ) ;; ascii) @@ -834,7 +570,6 @@ function _p9k_init_icons() { LINUX_DEBIAN_ICON 'debian' LINUX_RASPBIAN_ICON 'pi' LINUX_UBUNTU_ICON 'ubuntu' - LINUX_KALI_ICON 'kali' LINUX_CENTOS_ICON 'centos' LINUX_COREOS_ICON 'coreos' LINUX_ELEMENTARY_ICON 'elementary' @@ -852,12 +587,6 @@ function _p9k_init_icons() { LINUX_SLACKWARE_ICON 'slack' LINUX_VOID_ICON 'void' LINUX_ARTIX_ICON 'artix' - LINUX_RHEL_ICON 'rhel' - LINUX_AMZN_ICON 'amzn' - LINUX_ENDEAVOUROS_ICON 'edvos' - LINUX_ROCKY_ICON 'rocky' - LINUX_GUIX_ICON 'guix' - LINUX_NEON_ICON 'neon' SUNOS_ICON 'sunos' HOME_ICON '' HOME_SUB_ICON '' @@ -884,23 +613,10 @@ function _p9k_init_icons() { VCS_GIT_GITHUB_ICON '' VCS_GIT_BITBUCKET_ICON '' VCS_GIT_GITLAB_ICON '' - VCS_GIT_AZURE_ICON '' - VCS_GIT_ARCHLINUX_ICON '' - VCS_GIT_CODEBERG_ICON '' - VCS_GIT_DEBIAN_ICON '' - VCS_GIT_FREEBSD_ICON '' - VCS_GIT_FREEDESKTOP_ICON '' - VCS_GIT_GNOME_ICON '' - VCS_GIT_GNU_ICON '' - VCS_GIT_KDE_ICON '' - VCS_GIT_LINUX_ICON '' - VCS_GIT_GITEA_ICON '' - VCS_GIT_SOURCEHUT_ICON '' VCS_HG_ICON '' VCS_SVN_ICON '' RUST_ICON 'rust' PYTHON_ICON 'py' - CHEZMOI_ICON 'chezmoi' SWIFT_ICON 'swift' GO_ICON 'go' GOLANG_ICON 'go' @@ -917,7 +633,6 @@ function _p9k_init_icons() { JAVA_ICON 'java' LARAVEL_ICON '' RANGER_ICON 'ranger' - YAZI_ICON 'yazi' MIDNIGHT_COMMANDER_ICON 'mc' VIM_ICON 'vim' TERRAFORM_ICON 'tf' @@ -931,8 +646,6 @@ function _p9k_init_icons() { LUA_ICON 'lua' PERL_ICON 'perl' NNN_ICON 'nnn' - LF_ICON 'lf' - XPLR_ICON 'xplr' TIMEWARRIOR_ICON 'tw' TASKWARRIOR_ICON 'task' NIX_SHELL_ICON 'nix' @@ -945,9 +658,6 @@ function _p9k_init_icons() { PACKAGE_ICON 'pkg' JULIA_ICON 'jl' SCALA_ICON 'scala' - TOOLBOX_ICON 'toolbox' - ARCH_ICON 'arch' - HISTORY_ICON 'hist' ) ;; *) @@ -988,7 +698,6 @@ function _p9k_init_icons() { LINUX_DEBIAN_ICON 'Deb' LINUX_RASPBIAN_ICON 'RPi' LINUX_UBUNTU_ICON 'Ubu' - LINUX_KALI_ICON 'Kal' LINUX_CENTOS_ICON 'Cen' LINUX_COREOS_ICON 'Cor' LINUX_ELEMENTARY_ICON 'Elm' @@ -1006,12 +715,6 @@ function _p9k_init_icons() { LINUX_SLACKWARE_ICON 'Sla' LINUX_VOID_ICON 'Vo' LINUX_ARTIX_ICON 'Art' - LINUX_RHEL_ICON 'RH' - LINUX_AMZN_ICON 'Amzn' - LINUX_ENDEAVOUROS_ICON 'Edv' - LINUX_ROCKY_ICON 'Roc' - LINUX_GUIX_ICON 'Guix' - LINUX_NEON_ICON 'Neon' SUNOS_ICON 'Sun' HOME_ICON '' HOME_SUB_ICON '' @@ -1038,23 +741,10 @@ function _p9k_init_icons() { VCS_GIT_GITHUB_ICON '' VCS_GIT_BITBUCKET_ICON '' VCS_GIT_GITLAB_ICON '' - VCS_GIT_AZURE_ICON '' - VCS_GIT_ARCHLINUX_ICON '' - VCS_GIT_CODEBERG_ICON '' - VCS_GIT_DEBIAN_ICON '' - VCS_GIT_FREEBSD_ICON '' - VCS_GIT_FREEDESKTOP_ICON '' - VCS_GIT_GNOME_ICON '' - VCS_GIT_GNU_ICON '' - VCS_GIT_KDE_ICON '' - VCS_GIT_LINUX_ICON '' - VCS_GIT_GITEA_ICON '' - VCS_GIT_SOURCEHUT_ICON '' VCS_HG_ICON '' VCS_SVN_ICON '' RUST_ICON 'R' PYTHON_ICON 'Py' - CHEZMOI_ICON 'Chez' SWIFT_ICON 'Swift' GO_ICON 'Go' GOLANG_ICON 'Go' @@ -1071,7 +761,6 @@ function _p9k_init_icons() { JAVA_ICON '\U2615' # ☕︎ LARAVEL_ICON '' RANGER_ICON '\u2B50' # ⭐ - YAZI_ICON '\u2B50' # ⭐ MIDNIGHT_COMMANDER_ICON 'mc' VIM_ICON 'vim' TERRAFORM_ICON 'tf' @@ -1085,8 +774,6 @@ function _p9k_init_icons() { LUA_ICON 'lua' PERL_ICON 'perl' NNN_ICON 'nnn' - LF_ICON 'lf' - XPLR_ICON 'xplr' TIMEWARRIOR_ICON 'tw' TASKWARRIOR_ICON 'task' NIX_SHELL_ICON 'nix' @@ -1099,9 +786,6 @@ function _p9k_init_icons() { PACKAGE_ICON 'pkg' JULIA_ICON 'jl' SCALA_ICON 'scala' - TOOLBOX_ICON '\u2B22' # ⬢ - ARCH_ICON 'arch' - HISTORY_ICON 'hist' ) ;; esac @@ -1126,7 +810,6 @@ function _p9k_init_icons() { icons[LEFT_SEGMENT_END_SEPARATOR]+=' ' icons[MULTILINE_LAST_PROMPT_PREFIX]+=' ' icons[VCS_TAG_ICON]+=' ' - icons[VCS_BOOKMARK_ICON]+=' ' icons[VCS_COMMIT_ICON]+=' ' icons[VCS_BRANCH_ICON]+=' ' icons[VCS_REMOTE_BRANCH_ICON]+=' ' diff --git a/internal/p10k.zsh b/internal/p10k.zsh index d2d261b2..c63564d8 100644 --- a/internal/p10k.zsh +++ b/internal/p10k.zsh @@ -3,7 +3,7 @@ if [[ $__p9k_sourced != 13 ]]; then >&2 print -P "[%F{1}ERROR%f]: Corrupted powerlevel10k installation." >&2 print -P "" if (( ${+functions[antigen]} )); then - >&2 print -P "If using %Bantigen%b, run the following command to fix:" + >&2 print -P "If using %Bantigen%b, run the folowing command to fix:" >&2 print -P "" >&2 print -P " %F{2}antigen%f reset" if [[ -d ~/.antigen ]]; then @@ -20,7 +20,7 @@ if [[ $__p9k_sourced != 13 ]]; then return 1 fi -if [[ $ZSH_VERSION != (5.<1->*|<6->.*) ]]; then +if ! autoload -Uz is-at-least || ! is-at-least 5.1; then () { >&2 echo -E "You are using ZSH version $ZSH_VERSION. The minimum required version for Powerlevel10k is 5.1." >&2 echo -E "Type 'echo \$ZSH_VERSION' to see your current zsh version." @@ -31,8 +31,8 @@ if [[ $ZSH_VERSION != (5.<1->*|<6->.*) ]]; then >&2 echo -E "The shell you are currently running is likely $cur." fi local other=${${:-zsh}:c} - if [[ -n $other ]] && $other -fc '[[ $ZSH_VERSION == (5.<1->*|<6->.*) ]]' &>/dev/null; then - local other_v="$($other -fc 'echo -E $ZSH_VERSION' 2>/dev/null)" + if [[ -n $other ]] && $other -c 'autoload -Uz is-at-least && is-at-least 5.1' &>/dev/null; then + local other_v="$($other -c 'echo -E $ZSH_VERSION' 2>/dev/null)" if [[ -n $other_v && $other_v != $ZSH_VERSION ]]; then >&2 echo -E "You have $other with version $other_v but this is not what you are using." if [[ -n $def && $def != ${other:A} ]]; then @@ -200,23 +200,19 @@ function _p9k_read_word() { } function _p9k_fetch_cwd() { - if [[ $PWD == /* && $PWD -ef . ]]; then - _p9k__cwd=$PWD - else - _p9k__cwd=${${${:-.}:a}:-.} - fi + _p9k__cwd=${(%):-%/} _p9k__cwd_a=${${_p9k__cwd:A}:-.} case $_p9k__cwd in - /|.) + ~|/|.) _p9k__parent_dirs=() _p9k__parent_mtimes=() _p9k__parent_mtimes_i=() _p9k__parent_mtimes_s= return ;; - ~|~/*) - local parent=${${${:-~/..}:a}%/}/ + ~/*) + local parent=~/ local parts=(${(s./.)_p9k__cwd#$parent}) ;; *) @@ -233,7 +229,7 @@ function _p9k_fetch_cwd() { _p9k__parent_mtimes_s="$_p9k__parent_mtimes_i" } -# Usage: _p9k_glob parent_dir_index pattern [glob_qual] +# Usage: _p9k_glob parent_dir_index pattern # # parent_dir_index indexes _p9k__parent_dirs. # @@ -250,16 +246,16 @@ function _p9k_glob() { fi local -a stat zstat -A stat +mtime -- $dir 2>/dev/null || stat=(-1) - eval 'local files=($dir/$~2('$3'N:t))' + local files=($dir/$~2(N:t)) _p9k__glob_cache[$dir/$2]="$stat[1]:$#files" return $#files } -# Usage: _p9k_upglob pattern [glob_qual] +# Usage: _p9k_upglob pattern # # Returns index within _p9k__parent_dirs or 0 if there is no match. # -# Search stops before reaching ~/../ or / and never matches in those directories. +# Pattern cannot have slashes. Never matches in / or ~. Search stops before reaching / or ~. # # Example: _p9k_upglob '*.csproj' function _p9k_upglob() { @@ -273,7 +269,7 @@ function _p9k_upglob() { cached[-1]=() local -i i for i in ${(@)${cached:|_p9k__parent_mtimes_i}%:*}; do - _p9k_glob $i "$@" && continue + _p9k_glob $i $1 && continue _p9k__upsearch_cache[$_p9k__cwd/$1]="${_p9k__parent_mtimes_i[1,i]} $i" return i done @@ -286,7 +282,7 @@ function _p9k_upglob() { local -i i=1 fi for ((; i <= $#_p9k__parent_mtimes; ++i)); do - _p9k_glob $i "$@" && continue + _p9k_glob $i $1 && continue _p9k__upsearch_cache[$_p9k__cwd/$1]="${_p9k__parent_mtimes_i[1,i]} $i" return i done @@ -305,7 +301,7 @@ function _p9k_upglob() { # _p9k_prompt_length $'%{a\b%Gb%}' => 1 function _p9k_prompt_length() { local -i COLUMNS=1024 - local -i x y=${#1} m + local -i x y=$#1 m if (( y )); then while (( ${${(%):-$1%$y(l.1.0)}[-1]} )); do x=y @@ -321,27 +317,19 @@ function _p9k_prompt_length() { typeset -gr __p9k_byte_suffix=('B' 'K' 'M' 'G' 'T' 'P' 'E' 'Z' 'Y') -# 512 => 512B -# 1800 => 1.76K -# 18000 => 17.6K +# 42 => 42B +# 1536 => 1.5K function _p9k_human_readable_bytes() { - typeset -F n=$1 + typeset -F 2 n=$1 local suf for suf in $__p9k_byte_suffix; do - (( n < 1024 )) && break + (( n < 100 )) && break (( n /= 1024 )) done - if (( n >= 100 )); then - printf -v _p9k__ret '%.0f.' $n - elif (( n >= 10 )); then - printf -v _p9k__ret '%.1f' $n - else - printf -v _p9k__ret '%.2f' $n - fi - _p9k__ret=${${_p9k__ret%%0#}%.}$suf + _p9k__ret=${${n%%0#}%.}$suf } -if [[ $ZSH_VERSION == (5.<4->*|<6->.*) ]]; then +if is-at-least 5.4; then function _p9k_print_params() { typeset -p -- "$@" } else # Cannot use `typeset -p` unconditionally because of bugs in zsh. @@ -532,7 +520,7 @@ _p9k_get_icon() { _p9k_translate_color() { if [[ $1 == <-> ]]; then # decimal color code: 255 _p9k__ret=${(l.3..0.)1} - elif [[ $1 == '#'[[:xdigit:]]## ]]; then # hexadecimal color code: #ffffff + elif [[ $1 == '#'[[:xdigit:]]## ]]; then # hexademical color code: #ffffff _p9k__ret=${${(L)1}//ı/i} else # named color: red # Strip prifixes if there are any. @@ -746,8 +734,8 @@ _p9k_left_prompt_segment() { fi fi - p+='${_p9k__c::='$content_exp_'}${_p9k__c::=${_p9k__c//'$'\r''}}' - p+='${_p9k__e::=${${_p9k__'${_p9k__line_index}l${${1#prompt_}%%[A-Z0-9_]#}'+00}:-' + p+="\${_p9k__c::=$content_exp_}" + p+='${_p9k__e::=${${_p9k__'${_p9k__line_index}l${${1#prompt_}%%[A-Z_]#}'+00}:-' if (( has_icon == -1 )); then p+='${${(%):-$_p9k__c%1(l.1.0)}[-1]}${${(%):-$_p9k__v%1(l.1.0)}[-1]}}' else @@ -771,12 +759,8 @@ _p9k_left_prompt_segment() { _p9k_foreground $_p9k__ret _p9k__ret=%b$bg$_p9k__ret _p9k__ret=${_p9k__ret//\}/\\\}} - if [[ $_p9k__ret != $style_ ]]; then - p+=$_p9k__ret'${_p9k__v}'$style_ - else - (( need_style )) && p+=$style_ - p+='${_p9k__v}' - fi + [[ $_p9k__ret != $style_ || $need_style == 1 ]] && p+=$_p9k__ret + p+='${_p9k__v}' _p9k_get_icon $1 LEFT_MIDDLE_WHITESPACE ' ' if [[ -n $_p9k__ret ]]; then @@ -977,8 +961,8 @@ _p9k_right_prompt_segment() { fi fi - p+='${_p9k__c::='$content_exp_'}${_p9k__c::=${_p9k__c//'$'\r''}}' - p+='${_p9k__e::=${${_p9k__'${_p9k__line_index}r${${1#prompt_}%%[A-Z0-9_]#}'+00}:-' + p+="\${_p9k__c::=$content_exp_}" + p+='${_p9k__e::=${${_p9k__'${_p9k__line_index}r${${1#prompt_}%%[A-Z_]#}'+00}:-' if (( has_icon == -1 )); then p+='${${(%):-$_p9k__c%1(l.1.0)}[-1]}${${(%):-$_p9k__v%1(l.1.0)}[-1]}}' else @@ -1027,12 +1011,8 @@ _p9k_right_prompt_segment() { _p9k_foreground $_p9k__ret _p9k__ret=%b$bg$_p9k__ret _p9k__ret=${_p9k__ret//\}/\\\}} - if [[ $_p9k__ret != $style_ ]]; then - p+=$_p9k__ret'${_p9k__v}'$style_ - else - (( need_style )) && p+=$style_ - p+='${_p9k__v}' - fi + [[ $_p9k__ret != $style_ || $need_style == 1 ]] && p+=$_p9k__ret + p+='${_p9k__v}' _p9k_get_icon $1 RIGHT_MIDDLE_WHITESPACE ' ' if [[ -n $_p9k__ret ]]; then @@ -1102,24 +1082,8 @@ function _p9k_prompt_segment() { "_p9k_${_p9k__prompt_side}_prompt_segment" "$@" function p9k_prompt_segment() { p10k segment "$@" } function _p9k_python_version() { - case $commands[python] in - "") - return 1 - ;; - ${PYENV_ROOT:-~/.pyenv}/shims/python) - local P9K_PYENV_PYTHON_VERSION _p9k__pyenv_version - local -i _POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=1 _POWERLEVEL9K_PYENV_SHOW_SYSTEM=1 - local _POWERLEVEL9K_PYENV_SOURCES=(shell local global) - if _p9k_pyenv_compute && [[ $P9K_PYENV_PYTHON_VERSION == ([[:digit:].]##)* ]]; then - _p9k__ret=$P9K_PYENV_PYTHON_VERSION - return 0 - fi - ;& # fall through - *) - _p9k_cached_cmd 1 '' python --version || return - [[ $_p9k__ret == (#b)Python\ ([[:digit:].]##)* ]] && _p9k__ret=$match[1] - ;; - esac + _p9k_cached_cmd 1 python --version || return + [[ $_p9k__ret == (#b)Python\ ([[:digit:].]##)* ]] && _p9k__ret=$match[1] } ################################################################ @@ -1147,62 +1111,18 @@ _p9k_prompt_anaconda_init() { typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${CONDA_PREFIX:-$CONDA_ENV_PATH}' } -# Populates array `reply` with "$#profile:$profile:$region" where $profile and $region -# come from the AWS config (~/.aws/config). -function _p9k_parse_aws_config() { - local cfg=$1 - typeset -ga reply=() - [[ -f $cfg && -r $cfg ]] || return - - local -a lines - lines=(${(f)"$(<$cfg)"}) || return - - local line profile - local -a match mbegin mend - for line in $lines; do - if [[ $line == [[:space:]]#'[default]'[[:space:]]#(|'#'*) ]]; then - # example: [default] - profile=default - elif [[ $line == (#b)'[profile'[[:space:]]##([^[:space:]]|[^[:space:]]*[^[:space:]])[[:space:]]#']'[[:space:]]#(|'#'*) ]]; then - # example: [profile prod] - profile=${(Q)match[1]} - elif [[ $line == (#b)[[:space:]]#region[[:space:]]#=[[:space:]]#([^[:space:]]|[^[:space:]]*[^[:space:]])[[:space:]]# ]]; then - # example: region = eu-west-1 - if [[ -n $profile ]]; then - reply+=$#profile:$profile:$match[1] - profile= - fi - fi - done -} - ################################################################ # AWS Profile prompt_aws() { - typeset -g P9K_AWS_PROFILE="${AWS_VAULT:-${AWSUME_PROFILE:-${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}}}" - local pat class state + local aws_profile="${AWS_VAULT:-${AWSUME_PROFILE:-${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}}}" + local pat class for pat class in "${_POWERLEVEL9K_AWS_CLASSES[@]}"; do - if [[ $P9K_AWS_PROFILE == ${~pat} ]]; then + if [[ $aws_profile == ${~pat} ]]; then [[ -n $class ]] && state=_${${(U)class}//İ/I} break fi done - - if [[ -n ${AWS_REGION:-$AWS_DEFAULT_REGION} ]]; then - typeset -g P9K_AWS_REGION=${AWS_REGION:-$AWS_DEFAULT_REGION} - else - local cfg=${AWS_CONFIG_FILE:-~/.aws/config} - if ! _p9k_cache_stat_get $0 $cfg; then - local -a reply - _p9k_parse_aws_config $cfg - _p9k_cache_stat_set $reply - fi - local prefix=$#P9K_AWS_PROFILE:$P9K_AWS_PROFILE: - local kv=$_p9k__cache_val[(r)${(b)prefix}*] - typeset -g P9K_AWS_REGION=${kv#$prefix} - fi - - _p9k_prompt_segment "$0$state" red white 'AWS_ICON' 0 '' "${P9K_AWS_PROFILE//\%/%%}" + _p9k_prompt_segment "$0$state" red white 'AWS_ICON' 0 '' "${aws_profile//\%/%%}" } _p9k_prompt_aws_init() { @@ -1212,7 +1132,7 @@ _p9k_prompt_aws_init() { ################################################################ # Current Elastic Beanstalk environment prompt_aws_eb_env() { - _p9k_upglob .elasticbeanstalk -/ && return + _p9k_upglob .elasticbeanstalk && return local dir=$_p9k__parent_dirs[$?] if ! _p9k_cache_stat_get $0 $dir/.elasticbeanstalk/config.yml; then @@ -1304,21 +1224,25 @@ function _p9k_read_file() { } function _p9k_fvm_old() { - _p9k_upglob fvm @ && return 1 + _p9k_upglob fvm && return 1 local fvm=$_p9k__parent_dirs[$?]/fvm - if [[ ${fvm:A} == (#b)*/versions/([^/]##)/bin/flutter ]]; then - _p9k_prompt_segment prompt_fvm blue $_p9k_color1 FLUTTER_ICON 0 '' ${match[1]//\%/%%} - return 0 + if [[ -L $fvm ]]; then + if [[ ${fvm:A} == (#b)*/versions/([^/]##)/bin/flutter ]]; then + _p9k_prompt_segment prompt_fvm blue $_p9k_color1 FLUTTER_ICON 0 '' ${match[1]//\%/%%} + return 0 + fi fi return 1 } function _p9k_fvm_new() { - _p9k_upglob .fvm/flutter_sdk @ && return 1 + _p9k_upglob .fvm && return 1 local sdk=$_p9k__parent_dirs[$?]/.fvm/flutter_sdk - if [[ ${sdk:A} == (#b)*/versions/([^/]##) ]]; then - _p9k_prompt_segment prompt_fvm blue $_p9k_color1 FLUTTER_ICON 0 '' ${match[1]//\%/%%} - return 0 + if [[ -L $sdk ]]; then + if [[ ${sdk:A} == (#b)*/versions/([^/]##) ]]; then + _p9k_prompt_segment prompt_fvm blue $_p9k_color1 FLUTTER_ICON 0 '' ${match[1]//\%/%%} + return 0 + fi fi return 1 } @@ -1345,7 +1269,7 @@ _p9k_prompt_battery_init() { return fi if [[ $_p9k_os != (Linux|Android) || - -z /sys/class/power_supply/(CMB*|BAT*|*battery)/(energy_full|charge_full|charge_counter)(#qN) ]]; then + -z /sys/class/power_supply/(CMB*|BAT*|battery)/(energy_full|charge_full|charge_counter)(#qN) ]]; then typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${:-}' fi } @@ -1403,16 +1327,13 @@ _p9k_prompt_battery_set_args() { Linux|Android) # See https://sourceforge.net/projects/acpiclient. - local -a bats=( /sys/class/power_supply/(CMB*|BAT*|*battery)/(FN) ) + local -a bats=( /sys/class/power_supply/(CMB*|BAT*|battery)/(FN) ) (( $#bats )) || return local -i energy_now energy_full power_now local -i is_full=1 is_calculating is_charching local dir for dir in $bats; do - _p9k_read_file $dir/status(N) && local bat_status=$_p9k__ret || continue - # Skip batteries with "Unknown" status: https://github.com/romkatv/powerlevel10k/pull/2562. - [[ $bat_status == Unknown ]] && continue local -i pow=0 full=0 if _p9k_read_file $dir/(energy_full|charge_full|charge_counter)(N); then (( energy_full += ${full::=_p9k__ret} )) @@ -1420,11 +1341,12 @@ _p9k_prompt_battery_set_args() { if _p9k_read_file $dir/(power|current)_now(N) && (( $#_p9k__ret < 9 )); then (( power_now += ${pow::=$_p9k__ret} )) fi - if _p9k_read_file $dir/capacity(N); then - (( energy_now += _p9k__ret * full / 100. + 0.5 )) - elif _p9k_read_file $dir/(energy|charge)_now(N); then + if _p9k_read_file $dir/(energy|charge)_now(N); then (( energy_now += _p9k__ret )) + elif _p9k_read_file $dir/capacity(N); then + (( energy_now += _p9k__ret * full / 100. + 0.5 )) fi + _p9k_read_file $dir/status(N) && local bat_status=$_p9k__ret || continue [[ $bat_status != Full ]] && is_full=0 [[ $bat_status == Charging ]] && is_charching=1 [[ $bat_status == (Charging|Discharging) && $pow == 0 ]] && is_calculating=1 @@ -1669,20 +1591,6 @@ prompt_host() { instant_prompt_host() { prompt_host; } -################################################################ -# Toolbox: https://github.com/containers/toolbox -function prompt_toolbox() { - _p9k_prompt_segment $0 $_p9k_color1 yellow TOOLBOX_ICON 0 '' $P9K_TOOLBOX_NAME -} - -_p9k_prompt_toolbox_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$P9K_TOOLBOX_NAME' -} - -function instant_prompt_toolbox() { - _p9k_prompt_segment prompt_toolbox $_p9k_color1 yellow TOOLBOX_ICON 1 '$P9K_TOOLBOX_NAME' '$P9K_TOOLBOX_NAME' -} - ################################################################ # The 'custom` prompt provides a way for users to invoke commands and display # the output in a segment. @@ -1746,22 +1654,14 @@ function _p9k_shorten_delim_len() { (( _p9k__ret >= 0 )) || _p9k_prompt_length $1 } -# Percents are duplicated because this function is currently used only -# where the result is going to be percent-expanded. -function _p9k_url_escape() { - emulate -L zsh -o no_multi_byte -o extended_glob - local MATCH MBEGIN MEND - _p9k__ret=${1//(#m)[^a-zA-Z0-9"\/:_.-!'()~"]/%%${(l:2::0:)$(([##16]#MATCH))}} -} - ################################################################ # Dir: current working directory prompt_dir() { if (( _POWERLEVEL9K_DIR_PATH_ABSOLUTE )); then - local p=${(V)_p9k__cwd} + local p=$_p9k__cwd local -a parts=("${(s:/:)p}") elif [[ -o auto_name_dirs ]]; then - local p=${(V)${_p9k__cwd/#(#b)$HOME(|\/*)/'~'$match[1]}} + local p=${_p9k__cwd/#(#b)$HOME(|\/*)/'~'$match[1]} local -a parts=("${(s:/:)p}") else local p=${(%):-%~} @@ -1775,15 +1675,15 @@ prompt_dir() { local -a parts=() for func in zsh_directory_name $zsh_directory_name_functions; do local reply=() - if (( $+functions[$func] )) && $func d $_p9k__cwd && [[ $p == '~['${(V)reply[1]}']'* ]]; then - parts+='~['${(V)reply[1]}']' + if (( $+functions[$func] )) && $func d $_p9k__cwd && [[ $p == '~['$reply[1]']'* ]]; then + parts+='~['$reply[1]']' break fi done if (( $#parts )); then parts+=(${(s:/:)${p#$parts[1]}}) else - p=${(V)_p9k__cwd} + p=$_p9k__cwd parts=("${(s:/:)p}") fi else @@ -1868,12 +1768,9 @@ prompt_dir() { fi ;; truncate_to_last) - shortenlen=${_POWERLEVEL9K_SHORTEN_DIR_LENGTH:-1} - (( shortenlen > 0 )) || shortenlen=1 - local -i i='shortenlen+1' - if [[ $#parts -gt i || $p[1] != / && $#parts -gt shortenlen ]]; then + if [[ $#parts -gt 2 || $p[1] != / && $#parts -gt 1 ]]; then fake_first=1 - parts[1,-i]=() + parts[1,-2]=() fi ;; truncate_to_first_and_last) @@ -1890,9 +1787,6 @@ prompt_dir() { delim=${_POWERLEVEL9K_SHORTEN_DELIMITER-'*'} shortenlen=${_POWERLEVEL9K_SHORTEN_DIR_LENGTH:-1} (( shortenlen >= 0 )) || shortenlen=1 - local rp=${(g:oce:)p} - local rparts=("${(@s:/:)rp}") - local -i i=2 e=$(($#parts - shortenlen)) if [[ -n $_POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER ]]; then (( e += shortenlen )) @@ -1906,9 +1800,9 @@ prompt_dir() { else local key= fi - if ! _p9k_cache_ephemeral_get $0 $e $i $_p9k__cwd $p || [[ $key != $_p9k__cache_val[1] ]]; then - local rtail=${(j./.)rparts[i,-1]} - local parent=$_p9k__cwd[1,-2-$#rtail] + if ! _p9k_cache_ephemeral_get $0 $e $i $_p9k__cwd || [[ $key != $_p9k__cache_val[1] ]]; then + local tail=${(j./.)parts[i,-1]} + local parent=$_p9k__cwd[1,-2-$#tail] _p9k_prompt_length $delim local -i real_delim_len=_p9k__ret [[ -n $parts[i-1] ]] && parts[i-1]="\${(Q)\${:-${(qqq)${(q)parts[i-1]}}}}"$'\2' @@ -1917,8 +1811,7 @@ prompt_dir() { local -i m=1 for (( ; i <= e; ++i, ++m )); do local sub=$parts[i] - local rsub=$rparts[i] - local dir=$parent/$rsub mtime=$mtimes[m] + local dir=$parent/$sub mtime=$mtimes[m] local pair=$_p9k__dir_stat_cache[$dir] if [[ $pair == ${mtime:-x}:* ]]; then parts[i]=${pair#*:} @@ -1926,22 +1819,22 @@ prompt_dir() { [[ $sub != *["~!#\`\$^&*()\\\"'<>?{}[]"]* ]] local -i q=$? if [[ -n $_POWERLEVEL9K_SHORTEN_FOLDER_MARKER && - -n $dir/${~_POWERLEVEL9K_SHORTEN_FOLDER_MARKER}(#qN) ]]; then + -n $parent/$sub/${~_POWERLEVEL9K_SHORTEN_FOLDER_MARKER}(#qN) ]]; then (( q )) && parts[i]="\${(Q)\${:-${(qqq)${(q)sub}}}}" parts[i]+=$'\2' else - local -i j=$rsub[(i)[^.]] - for (( ; j + d < $#rsub; ++j )); do - local -a matching=($parent/$rsub[1,j]*/(N)) + local -i j=$sub[(i)[^.]] + for (( ; j + d < $#sub; ++j )); do + local -a matching=($parent/$sub[1,j]*/(N)) (( $#matching == 1 )) && break done - local -i saved=$((${(m)#${(V)${rsub:$j}}} - d)) + local -i saved=$(($#sub - j - d)) if (( saved > 0 )); then if (( q )); then parts[i]='${${${_p9k__d:#-*}:+${(Q)${:-'${(qqq)${(q)sub}}'}}}:-${(Q)${:-' - parts[i]+=$'\3'${(qqq)${(q)${(V)${rsub[1,j]}}}}$'}}\1\3''${$((_p9k__d+='$saved'))+}}' + parts[i]+=$'\3'${(qqq)${(q)sub[1,j]}}$'}}\1\3''${$((_p9k__d+='$saved'))+}}' else - parts[i]='${${${_p9k__d:#-*}:+'$sub$'}:-\3'${(V)${rsub[1,j]}}$'\1\3''${$((_p9k__d+='$saved'))+}}' + parts[i]='${${${_p9k__d:#-*}:+'$sub$'}:-\3'$sub[1,j]$'\1\3''${$((_p9k__d+='$saved'))+}}' fi else (( q )) && parts[i]="\${(Q)\${:-${(qqq)${(q)sub}}}}" @@ -1949,7 +1842,7 @@ prompt_dir() { fi [[ -n $mtime ]] && _p9k__dir_stat_cache[$dir]="$mtime:$parts[i]" fi - parent+=/$rsub + parent+=/$sub done if [[ -n $_POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER ]]; then local _2=$'\2' @@ -2131,8 +2024,7 @@ prompt_dir() { local content="${(pj.$sep.)parts}" if (( _POWERLEVEL9K_DIR_HYPERLINK && _p9k_term_has_href )) && [[ $_p9k__cwd == /* ]]; then - _p9k_url_escape $_p9k__cwd - local header=$'%{\e]8;;file://'$_p9k__ret$'\a%}' + local header=$'%{\e]8;;file://'${${_p9k__cwd//\%/%%25}//'#'/%%23}$'\a%}' local footer=$'%{\e]8;;\a%}' if (( expand )); then _p9k_escape $header @@ -2174,7 +2066,7 @@ _p9k_prompt_docker_machine_init() { ################################################################ # GO prompt prompt_go_version() { - _p9k_cached_cmd 0 '' go version || return + _p9k_cached_cmd 0 go version || return [[ $_p9k__ret == (#b)*go([[:digit:].]##)* ]] || return local v=$match[1] if (( _POWERLEVEL9K_GO_VERSION_PROJECT_ONLY )); then @@ -2187,7 +2079,7 @@ prompt_go_version() { fi fi if [[ $_p9k__cwd/ != $p/* && $_p9k__cwd_a/ != $p/* ]]; then - _p9k_upglob go.mod -. && return + _p9k_upglob go.mod && return fi fi _p9k_prompt_segment "$0" "green" "grey93" "GO_ICON" 0 '' "${v//\%/%%}" @@ -2207,7 +2099,7 @@ prompt_history() { prompt_package() { unset P9K_PACKAGE_NAME P9K_PACKAGE_VERSION - _p9k_upglob package.json -. && return + _p9k_upglob package.json && return local file=$_p9k__parent_dirs[$?]/package.json if ! _p9k_cache_stat_get $0 $file; then @@ -2312,18 +2204,13 @@ _p9k_vpn_ip_render() { ################################################################ # Segment to display laravel version prompt_laravel_version() { - # TODO: add a '-/' or '-.' here depending on whether artisan is a directory or a file. _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)" - v="${${(M)v:#Laravel Framework *}#Laravel Framework }" - # In some versions the output is colorized. - # https://github.com/romkatv/powerlevel10k/issues/2534 - v=${${v#$'\e['<->m}%$'\e['<->m} - _p9k_cache_stat_set "$v" + _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]//\%/%%}" @@ -2349,9 +2236,9 @@ prompt_load() { _p9k_read_file /proc/loadavg || return local load=${${(A)=_p9k__ret}[_POWERLEVEL9K_LOAD_WHICH]//,/.} local -F pct='100. * load / _p9k_num_cpus' - if (( pct > _POWERLEVEL9K_LOAD_CRITICAL_PCT )); then + if (( pct > 70 )); then _p9k_prompt_segment $0_CRITICAL red "$_p9k_color1" LOAD_ICON 0 '' $load - elif (( pct > _POWERLEVEL9K_LOAD_WARNING_PCT )); then + elif (( pct > 50 )); then _p9k_prompt_segment $0_WARNING yellow "$_p9k_color1" LOAD_ICON 0 '' $load else _p9k_prompt_segment $0_NORMAL green "$_p9k_color1" LOAD_ICON 0 '' $load @@ -2384,9 +2271,9 @@ _p9k_prompt_load_async() { _p9k__load_warning= _p9k__load_critical= local -F pct='100. * _p9k__load_value / _p9k_num_cpus' - if (( pct > _POWERLEVEL9K_LOAD_CRITICAL_PCT )); then + if (( pct > 70 )); then _p9k__load_critical=1 - elif (( pct > _POWERLEVEL9K_LOAD_WARNING_PCT )); then + elif (( pct > 50 )); then _p9k__load_warning=1 else _p9k__load_normal=1 @@ -2404,20 +2291,18 @@ _p9k_prompt_load_sync() { _p9k_worker_reply $REPLY } -# Usage: _p9k_cached_cmd <0|1> [args...] +# Usage: _p9k_cached_cmd <0|1> [args...] # # The first argument says whether to capture stderr (1) or ignore it (0). -# The second argument can be empty or a file. If it's a file, the -# output of the command is presumed to potentially depend on it. function _p9k_cached_cmd() { - local cmd=$commands[$3] + local cmd=$commands[$2] [[ -n $cmd ]] || return - if ! _p9k_cache_stat_get $0" ${(q)*}" $2 $cmd; then + if ! _p9k_cache_stat_get $0" ${(q)*}" $cmd; then local out if (( $1 )); then - out="$($cmd "${@:4}" 2>&1)" + out="$($cmd "${@:3}" 2>&1)" else - out="$($cmd "${@:4}" 2>/dev/null)" + out="$($cmd "${@:3}" 2>/dev/null)" fi _p9k_cache_stat_set $(( ! $? )) "$out" fi @@ -2426,45 +2311,13 @@ function _p9k_cached_cmd() { } ################################################################ -# Segment to display Node version +# Segment to diplay Node version prompt_node_version() { - _p9k_upglob package.json -. - local -i idx=$? - (( idx || ! _POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY )) || return - - local node=$commands[node] - local -a file_deps env_deps - if [[ $node == ${NODENV_ROOT:-$HOME/.nodenv}/shims/node ]]; then - env_deps+=("$NODENV_VERSION") - file_deps+=(${NODENV_ROOT:-$HOME/.nodenv}/version) - if [[ $NODENV_DIR != (|.) ]]; then - [[ $NODENV_DIR == /* ]] && local dir=$NODENV_DIR || local dir="$_p9k__cwd_a/$NODENV_DIR" - dir=${dir:A} - if [[ $dir != $_p9k__cwd_a ]]; then - while true; do - if [[ -e $dir/.node-version ]]; then - file_deps+=($dir/.node-version) - break - fi - [[ $dir == (/|.) ]] && break - dir=${dir:h} - done - fi - fi - _p9k_upglob .node-version -. || file_deps+=($_p9k__parent_dirs[idx]/.node-version) - elif (( idx )); then - file_deps+=($_p9k__parent_dirs[idx]/package.json) + if (( _POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY )); then + _p9k_upglob package.json && return fi - - if ! _p9k_cache_stat_get "$0 $#env_deps ${(j: :)${(@q)env_deps}} ${(j: :)${(@q)file_deps}}" $file_deps $node; then - local out - out=$($node --version 2>/dev/null) - _p9k_cache_stat_set $(( ! $? )) "$out" - fi - (( $_p9k__cache_val[1] )) || return - local v=$_p9k__cache_val[2] - [[ $v == v?* ]] || return - _p9k_prompt_segment "$0" "green" "white" 'NODE_ICON' 0 '' "${${v#v}//\%/%%}" + _p9k_cached_cmd 0 node --version && [[ $_p9k__ret == v?* ]] || return + _p9k_prompt_segment "$0" "green" "white" 'NODE_ICON' 0 '' "${_p9k__ret#v}" } _p9k_prompt_node_version_init() { @@ -2557,10 +2410,10 @@ _p9k_nvm_ls_current() { local nvm_dir=${NVM_DIR:A} if [[ -n $nvm_dir && $node_path == $nvm_dir/versions/io.js/* ]]; then - _p9k_cached_cmd 0 '' iojs --version || return + _p9k_cached_cmd 0 iojs --version || return _p9k__ret=iojs-v${_p9k__ret#v} elif [[ -n $nvm_dir && $node_path == $nvm_dir/* ]]; then - _p9k_cached_cmd 0 '' node --version || return + _p9k_cached_cmd 0 node --version || return _p9k__ret=v${_p9k__ret#v} else _p9k__ret=system @@ -2573,13 +2426,7 @@ _p9k_nvm_ls_current() { prompt_nvm() { [[ -n $NVM_DIR ]] && _p9k_nvm_ls_current || return local current=$_p9k__ret - (( _POWERLEVEL9K_NVM_SHOW_SYSTEM )) || - [[ $current != system ]] || - return - (( _POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW )) || - ! _p9k_nvm_ls_default || - [[ $_p9k__ret != $current ]] || - return + ! _p9k_nvm_ls_default || [[ $_p9k__ret != $current ]] || return _p9k_prompt_segment "$0" "magenta" "black" 'NODE_ICON' 0 '' "${${current#v}//\%/%%}" } @@ -2591,7 +2438,7 @@ _p9k_prompt_nvm_init() { # Segment to display NodeEnv prompt_nodeenv() { local msg - if (( _POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION )) && _p9k_cached_cmd 0 '' node --version; then + if (( _POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION )) && _p9k_cached_cmd 0 node --version; then msg="${_p9k__ret//\%/%%} " fi msg+="$_POWERLEVEL9K_NODEENV_LEFT_DELIMITER${${NODE_VIRTUAL_ENV:t}//\%/%%}$_POWERLEVEL9K_NODEENV_RIGHT_DELIMITER" @@ -2641,7 +2488,7 @@ prompt_nodenv() { fi fi if [[ -z $_p9k__ret ]]; then - _p9k_upglob .node-version -. + _p9k_upglob .node-version local -i idx=$? if (( idx )) && _p9k_read_word $_p9k__parent_dirs[idx]/.node-version; then (( ${_POWERLEVEL9K_NODENV_SOURCES[(I)local]} )) || return @@ -2677,12 +2524,9 @@ _p9k_prompt_nodenv_init() { prompt_dotnet_version() { if (( _POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY )); then - _p9k_upglob 'project.json|global.json|packet.dependencies|*.csproj|*.fsproj|*.xproj|*.sln' -. && return + _p9k_upglob 'project.json|global.json|packet.dependencies|*.csproj|*.fsproj|*.xproj|*.sln' && return fi - - local cfg - _p9k_upglob global.json -. || cfg=$_p9k__parent_dirs[$?]/global.json - _p9k_cached_cmd 0 "$cfg" dotnet --version || return + _p9k_cached_cmd 0 dotnet --version || return _p9k_prompt_segment "$0" "magenta" "white" 'DOTNET_ICON' 0 '' "$_p9k__ret" } @@ -2704,9 +2548,9 @@ 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 + _p9k_upglob 'composer.json|*.php' && return fi - _p9k_cached_cmd 0 '' php --version || return + _p9k_cached_cmd 0 php --version || return [[ $_p9k__ret == (#b)(*$'\n')#'PHP '([[:digit:].]##)* ]] || return local v=$match[2] _p9k_prompt_segment "$0" "fuchsia" "grey93" 'PHP_ICON' 0 '' "${v//\%/%%}" @@ -2811,7 +2655,7 @@ prompt_rbenv() { fi fi if [[ -z $_p9k__ret ]]; then - _p9k_upglob .ruby-version -. + _p9k_upglob .ruby-version local -i idx=$? if (( idx )) && _p9k_read_word $_p9k__parent_dirs[idx]/.ruby-version; then (( ${_POWERLEVEL9K_RBENV_SOURCES[(I)local]} )) || return @@ -2874,7 +2718,7 @@ prompt_scalaenv() { fi fi if [[ -z $_p9k__ret ]]; then - _p9k_upglob .scala-version -. + _p9k_upglob .scala-version local -i idx=$? if (( idx )) && _p9k_read_word $_p9k__parent_dirs[idx]/.scala-version; then (( ${_POWERLEVEL9K_SCALAENV_SOURCES[(I)local]} )) || return @@ -2932,7 +2776,7 @@ prompt_phpenv() { fi fi if [[ -z $_p9k__ret ]]; then - _p9k_upglob .php-version -. + _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 @@ -2993,7 +2837,7 @@ prompt_luaenv() { fi fi if [[ -z $_p9k__ret ]]; then - _p9k_upglob .lua-version -. + _p9k_upglob .lua-version local -i idx=$? if (( idx )) && _p9k_read_word $_p9k__parent_dirs[idx]/.lua-version; then (( ${_POWERLEVEL9K_LUAENV_SOURCES[(I)local]} )) || return @@ -3054,7 +2898,7 @@ prompt_jenv() { fi fi if [[ -z $_p9k__ret ]]; then - _p9k_upglob .java-version -. + _p9k_upglob .java-version local -i idx=$? if (( idx )) && _p9k_read_word $_p9k__parent_dirs[idx]/.java-version; then (( ${_POWERLEVEL9K_JENV_SOURCES[(I)local]} )) || return @@ -3115,7 +2959,7 @@ prompt_plenv() { fi fi if [[ -z $_p9k__ret ]]; then - _p9k_upglob .perl-version -. + _p9k_upglob .perl-version local -i idx=$? if (( idx )) && _p9k_read_word $_p9k__parent_dirs[idx]/.perl-version; then (( ${_POWERLEVEL9K_PLENV_SOURCES[(I)local]} )) || return @@ -3147,31 +2991,13 @@ _p9k_prompt_plenv_init() { typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[plenv]:-${${+functions[plenv]}:#0}}' } -################################################################ -# Segment to display perlbrew information -# https://github.com/gugod/App-perlbrew - -prompt_perlbrew() { - if (( _POWERLEVEL9K_PERLBREW_PROJECT_ONLY )); then - _p9k_upglob 'cpanfile|.perltidyrc|(|MY)META.(yml|json)|(Makefile|Build).PL|*.(pl|pm|t|pod)' -. && return - fi - - local v=$PERLBREW_PERL - (( _POWERLEVEL9K_PERLBREW_SHOW_PREFIX )) || v=${v#*-} - [[ -n $v ]] || return - _p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PERL_ICON' 0 '' "${v//\%/%%}" -} - -_p9k_prompt_perlbrew_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$PERLBREW_PERL' -} - ################################################################ # Segment to display chruby information # see https://github.com/postmodern/chruby/issues/245 for chruby_auto issue with ZSH prompt_chruby() { - local v=${(M)RUBY_ENGINE:#$~_POWERLEVEL9K_CHRUBY_SHOW_ENGINE_PATTERN} - [[ $_POWERLEVEL9K_CHRUBY_SHOW_VERSION == 1 && -n $RUBY_VERSION ]] && v+=${v:+ }$RUBY_VERSION + local v + (( _POWERLEVEL9K_CHRUBY_SHOW_ENGINE )) && v=$RUBY_ENGINE + if [[ $_POWERLEVEL9K_CHRUBY_SHOW_VERSION == 1 && -n $RUBY_VERSION ]] && v+=${v:+ }$RUBY_VERSION _p9k_prompt_segment "$0" "red" "$_p9k_color1" 'RUBY_ICON' 0 '' "${v//\%/%%}" } @@ -3192,57 +3018,70 @@ instant_prompt_root_indicator() { prompt_root_indicator; } ################################################################ # Segment to display Rust version number prompt_rust_version() { - local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment $0 darkorange $_p9k_color1 RUST_ICON 1 '$P9K_RUST_VERSION' '${P9K_RUST_VERSION//\%/%%}' - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] + unset P9K_RUST_VERSION + if (( _POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY )); then + _p9k_upglob Cargo.toml && return + fi + local rustc=$commands[rustc] toolchain deps=() + if (( $+commands[ldd] )); then + if ! _p9k_cache_stat_get $0_so $rustc; then + local line so + for line in "${(@f)$(ldd $rustc 2>/dev/null)}"; do + [[ $line == (#b)[[:space:]]#librustc_driver[^[:space:]]#.so' => '(*)' (0x'[[:xdigit:]]#')' ]] || continue + so=$match[1] + break + done + _p9k_cache_stat_set "$so" + fi + deps+=$_p9k__cache_val[1] + fi + if (( $+commands[rustup] )); then + local rustup=$commands[rustup] + local rustup_home=${RUSTUP_HOME:-~/.rustup} + local cfg=($rustup_home/settings.toml(.N)) + deps+=($cfg $rustup_home/update-hashes/*(.N)) + if [[ -z ${toolchain::=$RUSTUP_TOOLCHAIN} ]]; then + if ! _p9k_cache_stat_get $0_overrides $rustup $cfg; then + local lines=(${(f)"$(rustup override list 2>/dev/null)"}) + if [[ $lines[1] == "no overrides" ]]; then + _p9k_cache_stat_set + else + local MATCH + local keys=(${(@)${lines%%[[:space:]]#[^[:space:]]#}/(#m)*/${(b)MATCH}/}) + local vals=(${(@)lines/(#m)*/$MATCH[(I)/] ${MATCH##*[[:space:]]}}) + _p9k_cache_stat_set ${keys:^vals} + fi + fi + local -A overrides=($_p9k__cache_val) + _p9k_upglob rust-toolchain + local dir=$_p9k__parent_dirs[$?] + local -i n m=${dir[(I)/]} + local pair + for pair in ${overrides[(K)$_p9k__cwd/]}; do + n=${pair%% *} + (( n <= m )) && continue + m=n + toolchain=${pair#* } + done + if [[ -z $toolchain && -n $dir ]]; then + _p9k_read_word $dir/rust-toolchain + toolchain=$_p9k__ret + fi + fi + fi + if ! _p9k_cache_stat_get $0_v$toolchain $rustc $deps; then + _p9k_cache_stat_set "$($rustc --version 2>/dev/null)" + fi + local v=${${_p9k__cache_val[1]#rustc }%% *} + [[ -n $v ]] || return + typeset -g P9K_RUST_VERSION=$_p9k__cache_val[1] + _p9k_prompt_segment "$0" "darkorange" "$_p9k_color1" 'RUST_ICON' 0 '' "${v//\%/%%}" } -function _p9k_prompt_rust_version_init() { - _p9k__async_segments_compute+='_p9k_rust_version_prefetch' +_p9k_prompt_rust_version_init() { typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[rustc]' } -_p9k_rust_version_prefetch() { - local rustc=$commands[rustc] - if [[ -z $rustc ]] || - { (( _POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY )) && _p9k_upglob Cargo.toml -. }; then - unset P9K_RUST_VERSION - return - fi - _p9k_worker_invoke rust_version \ - "_p9k_prompt_rust_version_compute ${(q)P9K_RUST_VERSION} ${(q)rustc} ${(q)_p9k__cwd_a}" -} - -_p9k_prompt_rust_version_compute() { - _p9k_worker_async \ - "_p9k_prompt_rust_version_async ${(q)1} ${(q)2} ${(q)3}" \ - _p9k_prompt_rust_version_sync -} - -_p9k_prompt_rust_version_async() { - typeset -g P9K_RUST_VERSION=$1 - local rustc=$2 cwd=$3 v - if pushd -q -- $cwd; then - { - v=${${"$($rustc --version)"#rustc }%% *} || v= - } always { - popd -q - } - fi - - [[ $v != $P9K_RUST_VERSION ]] || return - typeset -g P9K_RUST_VERSION=$v - _p9k_print_params P9K_RUST_VERSION - echo -E - 'reset=1' -} - -_p9k_prompt_rust_version_sync() { - if [[ -n $REPLY ]]; then - eval $REPLY - _p9k_worker_reply $REPLY - fi -} - # RSpec test ratio prompt_rspec_stats() { if [[ -d app && -d spec ]]; then @@ -3436,8 +3275,6 @@ _p9k_prompt_swap_async() { (( used_bytes *= 1024 )) fi - (( used_bytes >= 0 || (used_bytes = 0) )) - _p9k_human_readable_bytes $used_bytes [[ $_p9k__ret != $_p9k__swap_used ]] || return _p9k__swap_used=$_p9k__ret @@ -3711,7 +3548,7 @@ function +vi-hg-bookmarks() { if [[ -n "${hgbmarks[@]}" ]]; then hook_com[hg-bookmark-string]=" $(print_icon 'VCS_BOOKMARK_ICON')${hgbmarks[@]}" - # To signal that we want to use the string we just generated, set the special + # To signal that we want to use the sting we just generated, set the special # variable `ret' to something other than the default zero: ret=1 return 0 @@ -3720,9 +3557,20 @@ function +vi-hg-bookmarks() { function +vi-vcs-detect-changes() { if [[ "${hook_com[vcs]}" == "git" ]]; then + local remote="$(git ls-remote --get-url 2> /dev/null)" - _p9k_vcs_icon "$remote" - vcs_visual_identifier=$_p9k__ret + if [[ "$remote" =~ "github" ]] then + vcs_visual_identifier='VCS_GIT_GITHUB_ICON' + elif [[ "$remote" =~ "bitbucket" ]] then + vcs_visual_identifier='VCS_GIT_BITBUCKET_ICON' + elif [[ "$remote" =~ "stash" ]] then + vcs_visual_identifier='VCS_GIT_BITBUCKET_ICON' + elif [[ "$remote" =~ "gitlab" ]] then + vcs_visual_identifier='VCS_GIT_GITLAB_ICON' + else + vcs_visual_identifier='VCS_GIT_ICON' + fi + elif [[ "${hook_com[vcs]}" == "hg" ]]; then vcs_visual_identifier='VCS_HG_ICON' elif [[ "${hook_com[vcs]}" == "svn" ]]; then @@ -3855,14 +3703,13 @@ function _p9k_vcs_status_purge() { } function _p9k_vcs_icon() { - local pat icon - for pat icon in "${(@)_POWERLEVEL9K_VCS_GIT_REMOTE_ICONS}"; do - if [[ $1 == $~pat ]]; then - _p9k__ret=$icon - return - fi - done - _p9k__ret= + case "$VCS_STATUS_REMOTE_URL" in + *github*) _p9k__ret=VCS_GIT_GITHUB_ICON;; + *bitbucket*) _p9k__ret=VCS_GIT_BITBUCKET_ICON;; + *stash*) _p9k__ret=VCS_GIT_BITBUCKET_ICON;; + *gitlab*) _p9k__ret=VCS_GIT_GITLAB_ICON;; + *) _p9k__ret=VCS_GIT_ICON;; + esac } function _p9k_vcs_render() { @@ -3892,7 +3739,7 @@ function _p9k_vcs_render() { state=CLEAN fi fi - _p9k_vcs_icon "$VCS_STATUS_REMOTE_URL" + _p9k_vcs_icon _p9k_prompt_segment prompt_vcs_$state "${__p9k_vcs_states[$state]}" "$_p9k_color1" "$_p9k__ret" 0 '' "" return 0 fi @@ -3945,8 +3792,8 @@ function _p9k_vcs_render() { fi # It's weird that removing vcs-detect-changes from POWERLEVEL9K_VCS_GIT_HOOKS gets rid - # of the GIT icon. That's what vcs_info does, so we do the same in the name of compatibility. - _p9k_vcs_icon "$VCS_STATUS_REMOTE_URL" + # of the GIT icon. That's what vcs_info does, so we do the same in the name of compatiblity. + _p9k_vcs_icon icon=$_p9k__ret fi @@ -4243,49 +4090,6 @@ instant_prompt_vi_mode() { fi } -# Chezmoi shell indicator: https://www.chezmoi.io/ -prompt_chezmoi_shell() { - _p9k_prompt_segment $0 blue $_p9k_color1 CHEZMOI_ICON 0 '' '' -} - -_p9k_prompt_chezmoi_shell_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$CHEZMOI' -} - -function instant_prompt_chezmoi_shell() { - _p9k_prompt_segment prompt_chezmoi_shell blue $_p9k_color1 CHEZMOI_ICON 1 '$CHEZMOI_ICON' '' -} - -function _p9k_parse_virtualenv_cfg() { - typeset -ga reply=(0) - [[ -f $1 && -r $1 ]] || return - - local cfg - cfg=$(<$1) || return - - local -a match mbegin mend - [[ $'\n'$cfg$'\n' == (#b)*$'\n'prompt[$' \t']#=([^$'\n']#)$'\n'* ]] || return - local res=${${match[1]##[$' \t']#}%%[$' \t']#} - if [[ $res == (\"*\"|\'*\') ]]; then - # The string is quoted in python style, which isn't the same as quoting in zsh. - # For example, the literal 'foo"\'bar' denotes foo"'bar in python but in zsh - # it is malformed. - # - # We cheat a bit and impelement not exactly correct unquoting. It may produce - # different visual results but won't perform unintended expansions or bleed out - # any escape sequences. - # - # Note that venv performs unusual and obviously unintended expansions on the - # value of `prompt`: single-word expansions are performed twice by `activate`, - # and then again on every prompt if `prompt_subst` is in effect. While in general - # I am OK with being bug-compatible with other software, the bugs in venv are a - # bit too extreme for my comfort. I am going to disable all expansions and - # display the configured prompt literally. - res=${(Vg:e:)${res[2,-2]}} - fi - reply=(1 "$res") -} - ################################################################ # Virtualenv: current working virtualenv # More information on virtualenv (Python): @@ -4295,22 +4099,8 @@ prompt_virtualenv() { if (( _POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION )) && _p9k_python_version; then msg="${_p9k__ret//\%/%%} " fi - local cfg=$VIRTUAL_ENV/pyvenv.cfg - if ! _p9k_cache_stat_get $0 $cfg; then - local -a reply - _p9k_parse_virtualenv_cfg $cfg - _p9k_cache_stat_set "${reply[@]}" - fi - if (( _p9k__cache_val[1] )); then - local v=$_p9k__cache_val[2] - else - local v=${VIRTUAL_ENV:t} - if [[ $VIRTUAL_ENV_PROMPT == '('?*') ' && $VIRTUAL_ENV_PROMPT != "($v) " ]]; then - v=$VIRTUAL_ENV_PROMPT[2,-3] - elif [[ $v == $~_POWERLEVEL9K_VIRTUALENV_GENERIC_NAMES ]]; then - v=${VIRTUAL_ENV:h:t} - fi - fi + local v=${VIRTUAL_ENV:t} + [[ $v == $~_POWERLEVEL9K_VIRTUALENV_GENERIC_NAMES ]] && v=${VIRTUAL_ENV:h:t} msg+="$_POWERLEVEL9K_VIRTUALENV_LEFT_DELIMITER${v//\%/%%}$_POWERLEVEL9K_VIRTUALENV_RIGHT_DELIMITER" case $_POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV in false) @@ -4345,7 +4135,7 @@ function _p9k_read_pyenv_like_version_file() { [[ -n $fd ]] && exec {fd}>&- } local MATCH - local versions=(${${${${(f)content}/(#m)*/${MATCH[(w)1]}}##\#*}#$2}) + local versions=(${(@)${(f)content}/(#m)*/${MATCH[(w)1]#$2}}) _p9k__ret=${(j.:.)versions} _p9k__read_pyenv_like_version_file_cache[$1:$2]=$stat[1]:$_p9k__ret fi @@ -4356,7 +4146,10 @@ function _p9k_pyenv_global_version() { _p9k_read_pyenv_like_version_file ${PYENV_ROOT:-$HOME/.pyenv}/version python- || _p9k__ret=system } -function _p9k_pyenv_compute() { +################################################################ +# Segment to display pyenv information +# https://github.com/pyenv/pyenv#choosing-the-python-version +prompt_pyenv() { unset P9K_PYENV_PYTHON_VERSION _p9k__pyenv_version local v=${(j.:.)${(@)${(s.:.)PYENV_VERSION}#python-}} @@ -4380,7 +4173,7 @@ function _p9k_pyenv_compute() { fi fi if [[ -z $_p9k__ret ]]; then - _p9k_upglob .python-version -. + _p9k_upglob .python-version local -i idx=$? if (( idx )) && _p9k_read_pyenv_like_version_file $_p9k__parent_dirs[idx]/.python-version python-; then (( ${_POWERLEVEL9K_PYENV_SOURCES[(I)local]} )) || return @@ -4398,34 +4191,24 @@ function _p9k_pyenv_compute() { if (( !_POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW )); then _p9k_pyenv_global_version - [[ $v == $_p9k__ret ]] && return 1 + [[ $v == $_p9k__ret ]] && return fi if (( !_POWERLEVEL9K_PYENV_SHOW_SYSTEM )); then - [[ $v == system ]] && return 1 + [[ $v == system ]] && return fi local versions=${PYENV_ROOT:-$HOME/.pyenv}/versions versions=${versions:A} - local name version - for name in ${(s.:.)v}; do - version=$versions/$name - version=${version:A} - if [[ $version(#qN/) == (#b)$versions/([^/]##)* ]]; then - typeset -g P9K_PYENV_PYTHON_VERSION=$match[1] - break - fi - done + local version=$versions/$v + version=${version:A} + if [[ $version == (#b)$versions/([^/]##)* ]]; then + typeset -g P9K_PYENV_PYTHON_VERSION=$match[1] + fi typeset -g _p9k__pyenv_version=$v -} -################################################################ -# Segment to display pyenv information -# https://github.com/pyenv/pyenv#choosing-the-python-version -prompt_pyenv() { - _p9k_pyenv_compute || return - _p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '' "${_p9k__pyenv_version//\%/%%}" + _p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '' "${v//\%/%%}" } _p9k_prompt_pyenv_init() { @@ -4460,7 +4243,7 @@ prompt_goenv() { fi fi if [[ -z $_p9k__ret ]]; then - _p9k_upglob .go-version -. + _p9k_upglob .go-version local -i idx=$? if (( idx )) && _p9k_read_pyenv_like_version_file $_p9k__parent_dirs[idx]/.go-version go-; then (( ${_POWERLEVEL9K_GOENV_SOURCES[(I)local]} )) || return @@ -4509,7 +4292,7 @@ _p9k_prompt_openfoam_init() { ################################################################ # Segment to display Swift version prompt_swift_version() { - _p9k_cached_cmd 0 '' swift --version || return + _p9k_cached_cmd 0 swift --version || return [[ $_p9k__ret == (#b)[^[:digit:]]#([[:digit:].]##)* ]] || return _p9k_prompt_segment "$0" "magenta" "white" 'SWIFT_ICON' 0 '' "${match[1]//\%/%%}" } @@ -4544,7 +4327,7 @@ prompt_kubecontext() { { (( pos <= $#cfg )) || return shift $pos cfg - pos=${cfg[(i) name: ${(b)name}]} + pos=${cfg[(i) name: $name]} (( pos <= $#cfg )) || return (( --pos )) for ((; pos > 0; --pos)); do @@ -4579,7 +4362,7 @@ prompt_kubecontext() { text=$cloud_cluster fi # arn:aws:eks:us-east-1:123456789012:cluster/cluster-01 - elif [[ $cluster == (#b)arn:aws[[:alnum:]-]#:eks:([[:alnum:]-]##):([[:digit:]]##):cluster/(?*) ]]; then + elif [[ $cluster == (#b)arn:aws:eks:([[:alnum:]-]##):([[:digit:]]##):cluster/(?*) ]]; then cloud_name=eks cloud_zone=$match[1] cloud_account=$match[2] @@ -4602,7 +4385,7 @@ prompt_kubecontext() { fi done fi - _p9k_cache_stat_set "${(g::)name}" "${(g::)namespace}" "${(g::)cluster}" "${(g::)user}" "${(g::)cloud_name}" "${(g::)cloud_account}" "${(g::)cloud_zone}" "${(g::)cloud_cluster}" "${(g::)text}" "$state" + _p9k_cache_stat_set "$name" "$namespace" "$cluster" "$user" "$cloud_name" "$cloud_account" "$cloud_zone" "$cloud_cluster" "$text" "$state" fi typeset -g P9K_KUBECONTEXT_NAME=$_p9k__cache_val[1] @@ -4645,7 +4428,7 @@ _p9k_prompt_dropbox_init() { # print Java version number prompt_java_version() { if (( _POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY )); then - _p9k_upglob 'pom.xml|build.gradle.kts|build.sbt|deps.edn|project.clj|build.boot|*.(java|class|jar|gradle|clj|cljc)' -. && return + _p9k_upglob 'pom.xml|build.gradle.kts|build.sbt|deps.edn|project.clj|build.boot|*.(java|class|jar|gradle|clj|cljc)' && return fi local java=$commands[java] @@ -4666,10 +4449,9 @@ _p9k_prompt_java_version_init() { } prompt_azure() { - local name cfg=${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json - if _p9k_cache_stat_get $0 $cfg; then - name=$_p9k__cache_val[1] - else + local cfg=${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json + if ! _p9k_cache_stat_get $0 $cfg; then + local 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 @@ -4677,15 +4459,8 @@ prompt_azure() { fi _p9k_cache_stat_set "$name" fi - [[ -n $name ]] || return - local pat class state - for pat class in "${_POWERLEVEL9K_AZURE_CLASSES[@]}"; do - if [[ $name == ${~pat} ]]; then - [[ -n $class ]] && state=_${${(U)class}//İ/I} - break - fi - done - _p9k_prompt_segment "$0$state" "blue" "white" "AZURE_ICON" 0 '' "${name//\%/%%}" + [[ -n $_p9k__cache_val[1] ]] || return + _p9k_prompt_segment "$0" "blue" "white" "AZURE_ICON" 0 '' "${_p9k__cache_val[1]//\%/%%}" } _p9k_prompt_azure_init() { @@ -4709,9 +4484,9 @@ _p9k_gcloud_prefetch() { # P9K_GCLOUD_PROJECT is deprecated; it's always equal to P9K_GCLOUD_PROJECT_ID unset P9K_GCLOUD_CONFIGURATION P9K_GCLOUD_ACCOUNT P9K_GCLOUD_PROJECT P9K_GCLOUD_PROJECT_ID P9K_GCLOUD_PROJECT_NAME (( $+commands[gcloud] )) || return - _p9k_read_word ${CLOUDSDK_CONFIG:-~/.config/gcloud}/active_config || return + _p9k_read_word ~/.config/gcloud/active_config || return P9K_GCLOUD_CONFIGURATION=$_p9k__ret - if ! _p9k_cache_stat_get $0 ${CLOUDSDK_CONFIG:-~/.config/gcloud}/configurations/config_$P9K_GCLOUD_CONFIGURATION; then + if ! _p9k_cache_stat_get $0 ~/.config/gcloud/configurations/config_$P9K_GCLOUD_CONFIGURATION; then local pair account project_id pair="$(gcloud config configurations describe $P9K_GCLOUD_CONFIGURATION \ --format=$'value[separator="\1"](properties.core.account,properties.core.project)')" @@ -4822,60 +4597,34 @@ typeset -gra __p9k_nordvpn_tag=( ) function _p9k_fetch_nordvpn_status() { - setopt err_return no_multi_byte + setopt err_return local REPLY - zsocket /run/nordvpn/nordvpnd.sock - local -i fd=REPLY + zsocket $1 + local -i fd=$REPLY { - print -nu $fd 'PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n\0\0\0\4\1\0\0\0\0\0\0;\1\4\0\0\0\1\203\206E\213b\270\327\2762\322z\230\326j\246A\206\240\344\35\23\235\t_\213\35u\320b\r&=LMedz\212\232\312\310\264\307`+\262\332\340@\2te\206M\2035\5\261\37\0\0\5\0\1\0\0\0\1\0\0\0\0\0\0\0\25\1\4\0\0\0\3\203\206E\215b\270\327\2762\322z\230\334\221\246\324\177\302\301\300\277\0\0\5\0\1\0\0\0\3\0\0\0\0\0' - local val - local -i len n wire tag + >&$fd echo -nE - $'PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n\0\0\0\4\1\0\0\0\0\0\0N\1\4\0\0\0\1\203\206E\221bA\226\223\325\\k\337\31i=LnH\323j?A\223\266\243y\270\303\fYmLT{$\357]R.\203\223\257_\213\35u\320b\r&=LMedz\212\232\312\310\264\307`+\210K\203@\2te\206M\2035\5\261\37\0\0\5\0\1\0\0\0\1\0\0\0\0\0' + local tag len val + local -i n { - IFS='' read -t 0.25 -r val - val=$'\n' + IFS='' read -t 0.25 -r tag + tag=$'\n' while true; do - tag=$((#val)) - wire='tag & 7' + tag=$((#tag)) (( (tag >>= 3) && tag <= $#__p9k_nordvpn_tag )) || break - if (( wire == 0 )); then - # varint - sysread -s 1 -t 0.25 val - n=$((#val)) - (( n < 128 )) || break # bail on multi-byte varints - if (( tag == 2 )); then - # P9K_NORDVPN_TECHNOLOGY - case $n in - 1) typeset -g P9K_NORDVPN_TECHNOLOGY=OPENVPN;; - 2) typeset -g P9K_NORDVPN_TECHNOLOGY=NORDLYNX;; - 3) typeset -g P9K_NORDVPN_TECHNOLOGY=SKYLARK;; - *) typeset -g P9K_NORDVPN_TECHNOLOGY=UNKNOWN;; - esac - elif (( tag == 3 )); then - # P9K_NORDVPN_PROTOCOL - case $n in - 1) typeset -g P9K_NORDVPN_PROTOCOL=UDP;; - 2) typeset -g P9K_NORDVPN_PROTOCOL=TCP;; - *) typeset -g P9K_NORDVPN_PROTOCOL=UNKNOWN;; - esac - else - break - fi - else - # length-delimited - (( wire == 2 )) || break - (( tag != 2 && tag != 3 )) || break - [[ -t $fd ]] || true # https://www.zsh.org/mla/workers/2020/msg00207.html - sysread -s 1 -t 0.25 val - len=$((#val)) - val= - while (( $#val < len )); do - [[ -t $fd ]] || true # https://www.zsh.org/mla/workers/2020/msg00207.html - sysread -s $(( len - $#val )) -t 0.25 'val[$#val+1]' - done - typeset -g $__p9k_nordvpn_tag[tag]=$val - fi + tag=$__p9k_nordvpn_tag[tag] [[ -t $fd ]] || true # https://www.zsh.org/mla/workers/2020/msg00207.html - sysread -s 1 -t 0.25 val + sysread -s 1 -t 0.25 len + len=$((#len)) + val= + while true; do + (( len )) || break + [[ -t $fd ]] || true # https://www.zsh.org/mla/workers/2020/msg00207.html + sysread -c n -s $len -t 0.25 'val[$#val+1]' + len+=-n + done + typeset -g $tag=$val + [[ -t $fd ]] || true # https://www.zsh.org/mla/workers/2020/msg00207.html + sysread -s 1 -t 0.25 tag done } <&$fd } always { @@ -4885,6 +4634,13 @@ function _p9k_fetch_nordvpn_status() { # Shows the state of NordVPN connection. Works only on Linux. Can be in the following 5 states. # +# MISSING: NordVPN is not installed or nordvpnd is not running. By default the segment is not +# shown in this state. To make it visible, override POWERLEVEL9K_NORDVPN_MISSING_CONTENT_EXPANSION +# and/or POWERLEVEL9K_NORDVPN_MISSING_VISUAL_IDENTIFIER_EXPANSION. +# +# # Display this icon when NordVPN is not installed or nordvpnd is not running +# POWERLEVEL9K_NORDVPN_MISSING_VISUAL_IDENTIFIER_EXPANSION='⭐' +# # CONNECTED: NordVPN is connected. By default shows NORDVPN_ICON as icon and country code as # content. In addition, the following variables are set for the use by # POWERLEVEL9K_NORDVPN_CONNECTED_VISUAL_IDENTIFIER_EXPANSION and @@ -4919,8 +4675,14 @@ function _p9k_fetch_nordvpn_status() { # POWERLEVEL9K_NORDVPN_CONNECTING_BACKGROUND=cyan function prompt_nordvpn() { unset $__p9k_nordvpn_tag P9K_NORDVPN_COUNTRY_CODE - [[ -e /run/nordvpn/nordvpnd.sock ]] || return - _p9k_fetch_nordvpn_status 2>/dev/null || return + if [[ -e /run/nordvpn/nordvpnd.sock ]]; then + sock=/run/nordvpn/nordvpnd.sock + elif [[ -e /run/nordvpnd.sock ]]; then + sock=/run/nordvpnd.sock + else + return + fi + _p9k_fetch_nordvpn_status $sock 2>/dev/null if [[ $P9K_NORDVPN_SERVER == (#b)([[:alpha:]]##)[[:digit:]]##.nordvpn.com ]]; then typeset -g P9K_NORDVPN_COUNTRY_CODE=${${(U)match[1]}//İ/I} fi @@ -4955,18 +4717,6 @@ function instant_prompt_ranger() { _p9k_prompt_segment prompt_ranger $_p9k_color1 yellow RANGER_ICON 1 '$RANGER_LEVEL' '$RANGER_LEVEL' } -function prompt_yazi() { - _p9k_prompt_segment $0 $_p9k_color1 yellow YAZI_ICON 0 '' $YAZI_LEVEL -} - -_p9k_prompt_yazi_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$YAZI_LEVEL' -} - -function instant_prompt_yazi() { - _p9k_prompt_segment prompt_yazi $_p9k_color1 yellow YAZI_ICON 1 '$YAZI_LEVEL' '$YAZI_LEVEL' -} - function prompt_midnight_commander() { local -i len=$#_p9k__prompt _p9k__has_upglob _p9k_prompt_segment $0 $_p9k_color1 yellow MIDNIGHT_COMMANDER_ICON 0 '' '' @@ -4993,32 +4743,6 @@ function instant_prompt_nnn() { _p9k_prompt_segment prompt_nnn 6 $_p9k_color1 NNN_ICON 1 '${NNNLVL:#0}' '$NNNLVL' } -function prompt_lf() { - _p9k_prompt_segment $0 6 $_p9k_color1 LF_ICON 0 '' $LF_LEVEL -} - -_p9k_prompt_lf_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${LF_LEVEL:#0}' -} - -function instant_prompt_lf() { - _p9k_prompt_segment prompt_lf 6 $_p9k_color1 LF_ICON 1 '${LF_LEVEL:#0}' '$LF_LEVEL' -} - -function prompt_xplr() { - local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment $0 6 $_p9k_color1 XPLR_ICON 0 '' '' - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -_p9k_prompt_xplr_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$XPLR_PID' -} - -function instant_prompt_xplr() { - _p9k_prompt_segment prompt_xplr 6 $_p9k_color1 XPLR_ICON 0 '$XPLR_PID' '' -} - function prompt_vim_shell() { local -i len=$#_p9k__prompt _p9k__has_upglob _p9k_prompt_segment $0 green $_p9k_color1 VIM_ICON 0 '' '' @@ -5038,11 +4762,11 @@ function prompt_nix_shell() { } _p9k_prompt_nix_shell_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k_nix_shell_cond + typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${IN_NIX_SHELL:#0}' } function instant_prompt_nix_shell() { - _p9k_prompt_segment prompt_nix_shell 4 $_p9k_color1 NIX_SHELL_ICON 1 "$_p9k_nix_shell_cond" '${(M)IN_NIX_SHELL:#(pure|impure)}' + _p9k_prompt_segment prompt_nix_shell 4 $_p9k_color1 NIX_SHELL_ICON 1 '${IN_NIX_SHELL:#0}' '${(M)IN_NIX_SHELL:#(pure|impure)}' } function prompt_terraform() { @@ -5051,7 +4775,7 @@ function prompt_terraform() { _p9k_read_word ${${TF_DATA_DIR:-.terraform}:A}/environment && ws=$_p9k__ret fi [[ -z $ws || $ws == default && $_POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT == 0 ]] && return - local pat class state + local pat class for pat class in "${_POWERLEVEL9K_TERRAFORM_CLASSES[@]}"; do if [[ $ws == ${~pat} ]]; then [[ -n $class ]] && state=_${${(U)class}//İ/I} @@ -5065,23 +4789,6 @@ _p9k_prompt_terraform_init() { typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[terraform]' } -function prompt_terraform_version() { - local v cfg terraform=${commands[terraform]} - _p9k_upglob .terraform-version -. || cfg=$_p9k__parent_dirs[$?]/.terraform-version - if _p9k_cache_stat_get $0.$TFENV_TERRAFORM_VERSION $terraform $cfg; then - v=$_p9k__cache_val[1] - else - v=${${"$(terraform --version 2>/dev/null)"#Terraform v}%%$'\n'*} || v= - _p9k_cache_stat_set "$v" - fi - [[ -n $v ]] || return - _p9k_prompt_segment $0 $_p9k_color1 blue TERRAFORM_ICON 0 '' ${v//\%/%%} -} - -_p9k_prompt_terraform_version_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[terraform]' -} - function prompt_proxy() { local -U p=( $all_proxy $http_proxy $https_proxy $ftp_proxy @@ -5097,18 +4804,18 @@ _p9k_prompt_proxy_init() { function prompt_direnv() { local -i len=$#_p9k__prompt _p9k__has_upglob - _p9k_prompt_segment $0 $_p9k_color1 yellow DIRENV_ICON 0 '${DIRENV_DIR-}' '' + _p9k_prompt_segment $0 $_p9k_color1 yellow DIRENV_ICON 0 '$DIRENV_DIR' '' (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] } _p9k_prompt_direnv_init() { # DIRENV_DIR is set in a precmd hook. If our hook isn't the last, DIRENV_DIR might # still get set before prompt is expanded. - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${DIRENV_DIR-${precmd_functions[-1]:#_p9k_precmd}}' + typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${DIRENV_DIR:-${precmd_functions[-1]:#_p9k_precmd}}' } function instant_prompt_direnv() { - if [[ -n ${DIRENV_DIR:-} && $precmd_functions[-1] == _p9k_precmd ]]; then + if [[ -n $DIRENV_DIR && $precmd_functions[-1] == _p9k_precmd ]]; then _p9k_prompt_segment prompt_direnv $_p9k_color1 yellow DIRENV_ICON 0 '' '' fi } @@ -5124,11 +4831,8 @@ function _p9k_timewarrior_clear() { } function prompt_timewarrior() { - local dir - [[ -n ${dir::=$TIMEWARRIORDB} || -n ${dir::=~/.timewarrior}(#q-/N) ]] || - dir=${XDG_DATA_HOME:-~/.local/share}/timewarrior - dir+=/data local -a stat + local dir=${TIMEWARRIORDB:-~/.timewarrior}/data [[ $dir == $_p9k_timewarrior_dir ]] || _p9k_timewarrior_clear if [[ -n $_p9k_timewarrior_file_name ]]; then zstat -A stat +mtime -- $dir $_p9k_timewarrior_file_name 2>/dev/null || stat=() @@ -5194,7 +4898,7 @@ function _p9k_taskwarrior_init_meta() { local last_sig=$_p9k_taskwarrior_meta_sig { local cfg - cfg="$(command task show data.location rc.color=0 rc._forcecolor=0 /dev/null)" || return + cfg="$(command task show data.location /dev/null)" || return local lines=(${(@M)${(f)cfg}:#data.location[[:space:]]##[^[:space:]]*}) (( $#lines == 1 )) || return local dir=${lines[1]##data.location[[:space:]]#} @@ -5234,10 +4938,7 @@ function _p9k_taskwarrior_check_data() { } function _p9k_taskwarrior_init_data() { - local -a stat files=( - $_p9k_taskwarrior_data_dir/{pending,completed}.data - $_p9k_taskwarrior_data_dir/taskchampion.sqlite3 - ) + local -a stat files=($_p9k_taskwarrior_data_dir/{pending,completed}.data) _p9k_taskwarrior_data_files=($^files(N)) _p9k_taskwarrior_data_non_files=(${files:|_p9k_taskwarrior_data_files}) if (( $#_p9k_taskwarrior_data_files )); then @@ -5253,7 +4954,7 @@ function _p9k_taskwarrior_init_data() { local name val for name in PENDING OVERDUE; do - val="$(command task +$name count rc.color=0 rc._forcecolor=0 /dev/null)" || continue + val="$(command task +$name count /dev/null)" || continue [[ $val == <1-> ]] || continue _p9k_taskwarrior_counters[$name]=$val done @@ -5262,11 +4963,9 @@ function _p9k_taskwarrior_init_data() { if (( _p9k_taskwarrior_counters[PENDING] > _p9k_taskwarrior_counters[OVERDUE] )); then local -a ts - ts=($(command task +PENDING -OVERDUE list rc.verbose=nothing rc.color=0 rc._forcecolor=0 \ + ts=($(command task +PENDING -OVERDUE list rc.verbose=nothing \ rc.report.list.labels= rc.report.list.columns=due.epoch /dev/null)) || ts=() - # The second condition is a workaround for a bug in taskwarrior v3.0.1. - # https://github.com/romkatv/powerlevel10k/issues/2648. - if (( $#ts && ! ${#${(@)ts:#(|-)<->(|.<->)}} )); then + if (( $#ts )); then _p9k_taskwarrior_next_due=${${(on)ts}[1]} (( _p9k_taskwarrior_next_due > EPOCHSECONDS )) || _p9k_taskwarrior_next_due=$((EPOCHSECONDS+60)) fi @@ -5511,7 +5210,7 @@ function _p9k_asdf_init_meta() { files+=$parse [[ -x $parse ]] && has_parse=1 local name - for name in ${$($list_names 2>/dev/null)%$'\r'}; do + for name in $($list_names 2>/dev/null); do [[ $name == (*/*|.tool-versions) ]] && continue _p9k_asdf_file_info[$name]+="${plugin:t} $has_parse " done @@ -5565,8 +5264,8 @@ function _p9k_asdf_parse_version_file() { local v=($(${ASDF_DATA_DIR:-~/.asdf}/plugins/$plugin/bin/parse-legacy-file $file 2>/dev/null)) else { local v=($(<$file)) } 2>/dev/null + v=(${v%$'\r'}) fi - v=(${v%$'\r'}) v=${v[(r)$_p9k_asdf_plugins[$plugin]]:-$v[1]} _p9k_asdf_file2versions[$plugin:$file]=$stat[1]:"$v" _p9k__state_dump_scheduled=1 @@ -5604,14 +5303,10 @@ function prompt_asdf() { local -A versions local -a stat + zstat -A stat +mtime ~ 2>/dev/null || return + local dirs=($_p9k__parent_dirs ~) + local mtimes=($_p9k__parent_mtimes $stat[1]) local -i has_global - local dirs=($_p9k__parent_dirs) - local mtimes=($_p9k__parent_mtimes) - if [[ $dirs[-1] != ~ ]]; then - zstat -A stat +mtime ~ 2>/dev/null || return - dirs+=(~) - mtimes+=($stat[1]) - fi local elem for elem in ${(@)${:-{1..$#dirs}}/(#m)*/${${:-$MATCH:$_p9k__asdf_dir2files[$dirs[MATCH]]}#$MATCH:$mtimes[MATCH]:}}; do @@ -5715,7 +5410,7 @@ prompt_haskell_stack() { _p9k_haskell_stack_version $STACK_YAML else (( ${_POWERLEVEL9K_HASKELL_STACK_SOURCES[(I)local|global]} )) || return - if _p9k_upglob stack.yaml -.; then + if _p9k_upglob stack.yaml; then (( _POWERLEVEL9K_HASKELL_STACK_PROMPT_ALWAYS_SHOW )) || return (( ${_POWERLEVEL9K_HASKELL_STACK_SOURCES[(I)global]} )) || return _p9k_haskell_stack_version ${STACK_ROOT:-~/.stack}/global-project/stack.yaml @@ -5742,64 +5437,6 @@ _p9k_prompt_haskell_stack_init() { typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[stack]' } -################################################################ -# CPU Architecture -prompt_cpu_arch() { - local -i len=$#_p9k__prompt _p9k__has_upglob - - local state text - if _p9k_cache_ephemeral_get $0; then - state=$_p9k__cache_val[1] - text=$_p9k__cache_val[2] - else - local cmd - for cmd in machine arch; do - (( $+commands[$cmd] )) || continue - if text=$(command -- $cmd) 2>/dev/null && [[ $text == [a-zA-Z][a-zA-Z0-9_]# ]]; then - break - else - text= - fi - done - state=_${${(U)text}//İ/I} - _p9k_cache_ephemeral_set "$state" "$text" - fi - if [[ -n $text ]]; then - _p9k_prompt_segment "$0$state" "yellow" "$_p9k_color1" 'ARCH_ICON' 0 '' "$text" - fi - - (( _p9k__has_upglob )) || typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k__prompt[len+1,-1] -} - -_p9k_prompt_cpu_arch_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[machine]$commands[arch]' -} - -################################################################ -# Oh My Zsh per-directory-history local/global indicator -prompt_per_directory_history() { - if [[ $_per_directory_history_is_global == true ]]; then - _p9k_prompt_segment ${0}_GLOBAL 3 $_p9k_color1 HISTORY_ICON 0 '' global - else - _p9k_prompt_segment ${0}_LOCAL 5 $_p9k_color1 HISTORY_ICON 0 '' local - fi -} - -instant_prompt_per_directory_history() { - case $HISTORY_START_WITH_GLOBAL in - true) - _p9k_prompt_segment prompt_per_directory_history_GLOBAL 3 $_p9k_color1 HISTORY_ICON 0 '' global - ;; - ?*) - _p9k_prompt_segment prompt_per_directory_history_LOCAL 5 $_p9k_color1 HISTORY_ICON 0 '' local - ;; - esac -} - -_p9k_prompt_per_directory_history_init() { - typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$PER_DIRECTORY_HISTORY_TOGGLE' -} - # Use two preexec hooks to survive https://github.com/MichaelAquilina/zsh-you-should-use with # YSU_HARDCORE=1. See https://github.com/romkatv/powerlevel10k/issues/427. _p9k_preexec1() { @@ -5812,7 +5449,6 @@ _p9k_preexec2() { typeset -g _p9k__preexec_cmd=$2 _p9k__timer_start=EPOCHREALTIME P9K_TTY=old - (( ! $+_p9k__iterm_cmd )) || _p9k_iterm2_preexec } function _p9k_prompt_net_iface_init() { @@ -5822,8 +5458,6 @@ function _p9k_prompt_net_iface_init() { typeset -g P9K_IP_INTERFACE= typeset -g P9K_IP_TX_BYTES= typeset -g P9K_IP_RX_BYTES= - typeset -g P9K_IP_TX_BYTES_DELTA= - typeset -g P9K_IP_RX_BYTES_DELTA= typeset -g P9K_IP_TX_RATE= typeset -g P9K_IP_RX_RATE= typeset -g _p9__ip_timestamp= @@ -5853,19 +5487,19 @@ function _p9k_prompt_net_iface_async() { # netstat -inbI en0 local iface ip line var typeset -a iface2ip ips ifaces - if (( $+commands[ip] )) && [[ $+commands[ifconfig] == 0 || $OSTYPE == linux* ]]; then - for line in ${(f)"$(command ip -4 a show 2>/dev/null)"}; do - if [[ $line == (#b)<->:[[:space:]]##([^:]##):[[:space:]]##\<([^\>]#)\>* ]]; then - [[ ,$match[2], == *,UP,* ]] && iface=$match[1] || iface= + if (( $+commands[ifconfig] )); then + for line in ${(f)"$(command ifconfig 2>/dev/null)"}; do + if [[ $line == (#b)([^[:space:]]##):[[:space:]]##flags=([[:xdigit:]]##)'<'* ]]; then + [[ $match[2] == *[13579bdfBDF] ]] && iface=$match[1] || iface= elif [[ -n $iface && $line == (#b)[[:space:]]##inet[[:space:]]##([0-9.]##)* ]]; then iface2ip+=($iface $match[1]) iface= fi done - elif (( $+commands[ifconfig] )); then - for line in ${(f)"$(command ifconfig 2>/dev/null)"}; do - if [[ $line == (#b)([^[:space:]]##):[[:space:]]##flags=([[:xdigit:]]##)'<'* ]]; then - [[ $match[2] == *[13579bdfBDF] ]] && iface=$match[1] || iface= + elif (( $+commands[ip] )); then + for line in ${(f)"$(command ip -4 a show 2>/dev/null)"}; do + if [[ $line == (#b)<->:[[:space:]]##([^:]##):[[:space:]]##\<([^\>]#)\>* ]]; then + [[ ,$match[2], == *,UP,* ]] && iface=$match[1] || iface= elif [[ -n $iface && $line == (#b)[[:space:]]##inet[[:space:]]##([0-9.]##)* ]]; then iface2ip+=($iface $match[1]) iface= @@ -5954,16 +5588,6 @@ function _p9k_prompt_net_iface_async() { _p9k__public_ip_not_vpn=$public_ip_not_vpn P9K_IP_IP=$ip_ip P9K_IP_INTERFACE=$ip_interface - if [[ -n $ip_tx_bytes && -n $P9K_IP_TX_BYTES ]]; then - P9K_IP_TX_BYTES_DELTA=$((ip_tx_bytes - P9K_IP_TX_BYTES)) - else - P9K_IP_TX_BYTES_DELTA= - fi - if [[ -n $ip_rx_bytes && -n $P9K_IP_RX_BYTES ]]; then - P9K_IP_RX_BYTES_DELTA=$((ip_rx_bytes - P9K_IP_RX_BYTES)) - else - P9K_IP_RX_BYTES_DELTA= - fi P9K_IP_TX_BYTES=$ip_tx_bytes P9K_IP_RX_BYTES=$ip_rx_bytes P9K_IP_TX_RATE=$ip_tx_rate @@ -5977,8 +5601,6 @@ function _p9k_prompt_net_iface_async() { P9K_IP_INTERFACE \ P9K_IP_TX_BYTES \ P9K_IP_RX_BYTES \ - P9K_IP_TX_BYTES_DELTA \ - P9K_IP_RX_BYTES_DELTA \ P9K_IP_TX_RATE \ P9K_IP_RX_RATE \ _p9__ip_timestamp \ @@ -5999,7 +5621,7 @@ function _p9k_set_prompt() { PROMPT= RPROMPT= - [[ $1 == instant_ ]] || PROMPT+='${$((_p9k_on_expand()))+}%{${_p9k__raw_msg-}${_p9k__raw_msg::=}%}' + [[ $1 == instant_ ]] || PROMPT+='${$((_p9k_on_expand()))+}' PROMPT+=$_p9k_prompt_prefix_left local -i _p9k__has_upglob @@ -6155,7 +5777,7 @@ _p9k_set_instant_prompt() { [[ -n $RPROMPT ]] || unset RPROMPT } -typeset -gri __p9k_instant_prompt_version=47 +typeset -gri __p9k_instant_prompt_version=38 _p9k_dump_instant_prompt() { local user=${(%):-%n} @@ -6189,7 +5811,7 @@ _p9k_dump_instant_prompt() { typeset -gi __p9k_instant_prompt_disabled=1 [[ \$ZSH_VERSION == ${(q)ZSH_VERSION} && \$ZSH_PATCHLEVEL == ${(q)ZSH_PATCHLEVEL} && $screen \${(M)TERM:#(screen*|tmux*)} && - \${#\${(M)VTE_VERSION:#(<1-4602>|4801)}} == "${#${(M)VTE_VERSION:#(<1-4602>|4801)}}" && + \${#\${(M)VTE_VERSION:#(<1-4602>|4801)}} == ${#${(M)VTE_VERSION:#(<1-4602>|4801)}} && \$POWERLEVEL9K_DISABLE_INSTANT_PROMPT != 'true' && \$POWERLEVEL9K_INSTANT_PROMPT != 'off' ]] || return typeset -g __p9k_instant_prompt_param_sig=${(q+)_p9k__param_sig} @@ -6199,13 +5821,10 @@ _p9k_dump_instant_prompt() { local PROMPT_EOL_MARK=${(q)PROMPT_EOL_MARK-%B%S%#%s%b} [[ -n \$SSH_CLIENT || -n \$SSH_TTY || -n \$SSH_CONNECTION ]] && local ssh=1 || local ssh=0 local cr=\$'\r' lf=\$'\n' esc=\$'\e[' rs=$'\x1e' us=$'\x1f' - local -i height=${_POWERLEVEL9K_INSTANT_PROMPT_COMMAND_LINES-1} + local -i height=$_POWERLEVEL9K_INSTANT_PROMPT_COMMAND_LINES local prompt_dir=${(q)prompt_dir}" - if (( ! ${+_POWERLEVEL9K_INSTANT_PROMPT_COMMAND_LINES} )); then - >&$fd print -r -- ' - (( _z4h_can_save_restore_screen == 1 )) && height=0' - fi >&$fd print -r -- ' + (( _z4h_can_save_restore_screen == 1 )) && height=0 local real_gitstatus_header if [[ -r $gitstatus_dir/install.info ]]; then IFS= read -r real_gitstatus_header <$gitstatus_dir/install.info || real_gitstatus_header=borked @@ -6366,9 +5985,6 @@ _p9k_dump_instant_prompt() { unfunction p10k-on-post-widget' fi >&$fd print -r -- ' - () { -'$functions[_p9k_init_toolbox]' - } trap "unset -m _p9k__\*; unfunction p10k" EXIT local -a _p9k_t=("${(@ps:$us:)${tail%%$rs*}}") if [[ $+VTE_VERSION == 1 || $TERM_PROGRAM == Hyper ]] && (( $+commands[stty] )); then @@ -6406,12 +6022,11 @@ _p9k_dump_instant_prompt() { (( __p9k_ksh_arrays )) && >&$fd print -r -- ' unsetopt ksh_arrays' (( __p9k_sh_glob )) && >&$fd print -r -- ' unsetopt sh_glob' >&$fd print -r -- ' - local -i prompt_height=${#${__p9k_used_instant_prompt[1]//[^$lf]}} - (( height += prompt_height )) + (( height += ${#${__p9k_used_instant_prompt[1]//[^$lf]}} )) local _p9k__ret function _p9k_prompt_length() { local -i COLUMNS=1024 - local -i x y=${#1} m + local -i x y=$#1 m if (( y )); then while (( ${${(%):-$1%$y(l.1.0)}[-1]} )); do x=y @@ -6424,49 +6039,28 @@ _p9k_dump_instant_prompt() { fi typeset -g _p9k__ret=$x } - local out=${(%):-%b%k%f%s%u} - if [[ $P9K_TTY == old && ( $+VTE_VERSION == 0 && $TERM_PROGRAM != Hyper || $+_p9k__g == 0 ) ]]; then + local out + if [[ $+VTE_VERSION == 0 && $TERM_PROGRAM != Hyper ]] || (( ! $+_p9k__g )); then local mark=${(e)PROMPT_EOL_MARK} [[ $mark == "%B%S%#%s%b" ]] && _p9k__ret=1 || _p9k_prompt_length $mark local -i fill=$((COLUMNS > _p9k__ret ? COLUMNS - _p9k__ret : 0)) - out+="${(%):-$mark${(pl.$fill.. .)}$cr%b%k%f%s%u%E}" - else - out+="${(%):-$cr%E}" - fi - if (( _z4h_can_save_restore_screen != 1 )); then - (( height )) && out+="${(pl.$height..$lf.)}$esc${height}A" - out+="$terminfo[sc]" + out+="${(%):-%b%k%f%s%u$mark${(pl.$fill.. .)}$cr%b%k%f%s%u%E}" fi + (( _z4h_can_save_restore_screen == 1 )) || out+="${(pl.$height..$lf.)}$esc${height}A$terminfo[sc]" out+=${(%):-"$__p9k_used_instant_prompt[1]$__p9k_used_instant_prompt[2]"} if [[ -n $__p9k_used_instant_prompt[3] ]]; then _p9k_prompt_length "$__p9k_used_instant_prompt[2]" local -i left_len=_p9k__ret _p9k_prompt_length "$__p9k_used_instant_prompt[3]" - if (( _p9k__ret )); then - local -i gap=$((COLUMNS - left_len - _p9k__ret - ZLE_RPROMPT_INDENT)) - if (( gap >= 40 )); then - out+="${(pl.$gap.. .)}${(%):-${__p9k_used_instant_prompt[3]}%b%k%f%s%u}$cr$esc${left_len}C" - fi + local -i gap=$((COLUMNS - left_len - _p9k__ret - ZLE_RPROMPT_INDENT)) + if (( gap >= 40 )); then + out+="${(pl.$gap.. .)}${(%):-${__p9k_used_instant_prompt[3]}%b%k%f%s%u}$cr$esc${left_len}C" fi fi - if (( _z4h_can_save_restore_screen == 1 )); then - if (( height )); then - out+="$cr${(pl:$((height-prompt_height))::\n:)}$esc${height}A$terminfo[sc]$out" - else - out+="$cr${(pl:$((height-prompt_height))::\n:)}$terminfo[sc]$out" - fi - fi - if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then - local tmpdir=$TMPDIR - else - local tmpdir=/tmp - fi - typeset -g __p9k_instant_prompt_output=$tmpdir/p10k-instant-prompt-output-${(%):-%n}-$$ - { : > $__p9k_instant_prompt_output } || return - print -rn -- "${out}${esc}?2004h" || return - if (( $+commands[stty] )); then - command stty -icanon 2>/dev/null - fi + (( _z4h_can_save_restore_screen == 1 )) && out+="$cr$esc${height}A$terminfo[sc]$out" + typeset -g __p9k_instant_prompt_output=${TMPDIR:-/tmp}/p10k-instant-prompt-output-${(%):-%n}-$$ + { echo -n > $__p9k_instant_prompt_output } || return + print -rn -- "$out" || return local fd_null sysopen -ru fd_null /dev/null || return exec {__p9k_fd_0}<&0 {__p9k_fd_1}>&1 {__p9k_fd_2}>&2 0<&$fd_null 1>$__p9k_instant_prompt_output @@ -6622,7 +6216,7 @@ function _p9k_dump_state() { unset __p9k_cached_param_pat __p9k_cached_param_sig (( $+_p9k_preinit )) && { print -r -- $_p9k_preinit >&$fd || return } print -r -- '_p9k_restore_state_impl() {' >&$fd || return - typeset -pm '_POWERLEVEL9K_*|_p9k_[^_]*|icons' >&$fd || return + typeset -pm '_POWERLEVEL9K_*|_p9k_[^_]*|icons|OS|DEFAULT_COLOR|DEFAULT_COLOR_INVERTED' >&$fd || return print -r -- '}' >&$fd || return } always { exec {fd}>&- @@ -6691,12 +6285,7 @@ function _p9k_clear_instant_prompt() { unset _z4h_saved_screen fi print -rn -- $terminfo[rc]${(%):-%b%k%f%s%u}$terminfo[ed] - local unexpected=${${content//$'\e[?'<->'c'}//$'\e['<->' q'} - unexpected=${(S)unexpected//$'\eP'(|*[^$'\e'])($'\e\e')#$'\e\\'} - unexpected=${(S)unexpected//$'\e'[^$'\a\e']#($'\a'|$'\e\\')} - # Visual Studio Code prints this garbage. - unexpected=${${unexpected//$'\033[1;32mShell integration activated\033[0m\n'}//$'\r'} - typeset -g P9K_STARTUP_CONSOLE_OUTPUT=("$content" "$unexpected") + local unexpected=${${${(S)content//$'\e[?'<->'c'}//$'\e['<->' q'}//$'\e'[^$'\a\e']#($'\a'|$'\e\\')} if [[ -n $unexpected ]]; then local omz1='[Oh My Zsh] Would you like to update? [Y/n]: ' local omz2='Updating Oh My Zsh' @@ -6740,9 +6329,9 @@ function _p9k_clear_instant_prompt() { echo -E - "" echo -E - "${(%):-For details, see:}" if (( _p9k_term_has_href )); then - echo - "${(%):-\e]8;;https://github.com/romkatv/powerlevel10k#instant-prompt\ahttps://github.com/romkatv/powerlevel10k#instant-prompt\e]8;;\a}" + echo - "${(%):-\e]8;;https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt\ahttps://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt\e]8;;\a}" else - echo - "${(%):-https://github.com/romkatv/powerlevel10k#instant-prompt}" + echo - "${(%):-https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt}" fi echo -E - "" echo - "${(%):-%3F-- console output produced during zsh initialization follows --%f}" @@ -7054,10 +6643,6 @@ _p9k_precmd_impl() { _p9k__zle_state=insert (( ++_p9k__prompt_idx )) - - if (( $+_p9k__iterm_cmd )); then - _p9k_iterm2_precmd $__p9k_new_status - fi fi _p9k_fetch_cwd @@ -7158,7 +6743,7 @@ function _p9k_reset_prompt() { zle .reset-prompt (( ${+functions[z4h]} )) || zle -R } always { - (( _p9k__can_hide_cursor )) && print -rn -- $_p9k__cnorm + (( _p9k__can_hide_cursor )) && echoti cnorm _p9k__cursor_hidden=0 } fi @@ -7170,14 +6755,14 @@ function _p9k_reset_prompt() { # ZSH_PATCHLEVEL=zsh-5.4.2-159-gd8d9fee13. Released in 5.5. # # Fix: https://github.com/zsh-users/zsh/commit/64d13738357c9b9c212adbe17f271716abbcf6ea. -# ZSH_PATCHLEVEL=zsh-5.7.1-50-g64d137383. Released in 5.7.2. +# ZSH_PATCHLEVEL=zsh-5.7.1-50-g64d137383. # # Test: PROMPT="${(pl:$((COLUMNS))::-:)}<%1(l.%2(l.FAIL.PASS).FAIL)> " zsh -dfis <<= 50 )) - [[ $ZSH_VERSION == 5.<5-7>* && $ZSH_VERSION != 5.7.<2->* ]] + is-at-least 5.5 && ! is-at-least 5.7.2 } typeset -g _p9k__param_pat @@ -7280,14 +6865,6 @@ _p9k_init_vars() { typeset -gi _p9k__restore_prompt_fd typeset -gi _p9k__redraw_fd typeset -gi _p9k__can_hide_cursor=$(( $+terminfo[civis] && $+terminfo[cnorm] )) - if (( _p9k__can_hide_cursor )); then - # See https://github.com/romkatv/powerlevel10k/issues/1699 - if [[ $terminfo[cnorm] == *$'\e[?25h'(|'\e'*) ]]; then - typeset -g _p9k__cnorm=$'\e[?25h' - else - typeset -g _p9k__cnorm=$terminfo[cnorm] - fi - fi typeset -gi _p9k__cursor_hidden typeset -gi _p9k__non_hermetic_expansion typeset -g _p9k__time @@ -7418,11 +6995,6 @@ _p9k_init_params() { _p9k_declare -s POWERLEVEL9K_TRANSIENT_PROMPT off [[ $_POWERLEVEL9K_TRANSIENT_PROMPT == (off|always|same-dir) ]] || _POWERLEVEL9K_TRANSIENT_PROMPT=off - _p9k_declare -b POWERLEVEL9K_TERM_SHELL_INTEGRATION 0 - if [[ __p9k_force_term_shell_integration -eq 1 || $ITERM_SHELL_INTEGRATION_INSTALLED == Yes ]]; then - _POWERLEVEL9K_TERM_SHELL_INTEGRATION=1 - fi - _p9k_declare -s POWERLEVEL9K_WORKER_LOG_LEVEL _p9k_declare -i POWERLEVEL9K_COMMANDS_MAX_TOKEN_COUNT 64 _p9k_declare -a POWERLEVEL9K_HOOK_WIDGETS -- @@ -7430,7 +7002,7 @@ _p9k_init_params() { _p9k_declare -b POWERLEVEL9K_TODO_HIDE_ZERO_FILTERED 0 _p9k_declare -b POWERLEVEL9K_DISABLE_HOT_RELOAD 0 _p9k_declare -F POWERLEVEL9K_NEW_TTY_MAX_AGE_SECONDS 5 - _p9k_declare -i POWERLEVEL9K_INSTANT_PROMPT_COMMAND_LINES + _p9k_declare -i POWERLEVEL9K_INSTANT_PROMPT_COMMAND_LINES 1 _p9k_declare -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS -- context dir vcs _p9k_declare -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS -- status root_indicator background_jobs history time _p9k_declare -b POWERLEVEL9K_DISABLE_RPROMPT 0 @@ -7454,36 +7026,6 @@ _p9k_init_params() { _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 -a POWERLEVEL9K_VCS_GIT_REMOTE_ICONS - if (( $+_POWERLEVEL9K_VCS_GIT_REMOTE_ICONS )); then - (( $#_POWERLEVEL9K_VCS_GIT_REMOTE_ICONS & 1 )) && _POWERLEVEL9K_VCS_GIT_REMOTE_ICONS+=('') - else - local domain= icon= domain2icon=( - 'archlinux.org' VCS_GIT_ARCHLINUX_ICON - 'dev.azure.com|visualstudio.com' VCS_GIT_AZURE_ICON - 'bitbucket.org' VCS_GIT_BITBUCKET_ICON - 'codeberg.org' VCS_GIT_CODEBERG_ICON - 'debian.org' VCS_GIT_DEBIAN_ICON - 'freebsd.org' VCS_GIT_FREEBSD_ICON - 'freedesktop.org' VCS_GIT_FREEDESKTOP_ICON - 'gitea.com|gitea.io' VCS_GIT_GITEA_ICON - 'github.com' VCS_GIT_GITHUB_ICON - 'gitlab.com' VCS_GIT_GITLAB_ICON - 'gnome.org' VCS_GIT_GNOME_ICON - 'gnu.org' VCS_GIT_GNU_ICON - 'kde.org' VCS_GIT_KDE_ICON - 'kernel.org' VCS_GIT_LINUX_ICON - 'sr.ht' VCS_GIT_SOURCEHUT_ICON - ) - typeset -ga _POWERLEVEL9K_VCS_GIT_REMOTE_ICONS - for domain icon in "${domain2icon[@]}"; do - _POWERLEVEL9K_VCS_GIT_REMOTE_ICONS+=( - '(|[A-Za-z0-9][A-Za-z0-9+.-]#://)(|[^:/?#]#[.@])((#i)'$domain')(|[/:?#]*)' - $icon - ) - done - _POWERLEVEL9K_VCS_GIT_REMOTE_ICONS+=('*' VCS_GIT_ICON) - fi _p9k_declare -i POWERLEVEL9K_CHANGESET_HASH_LENGTH 8 # Specifies the maximum number of elements in the cache. When the cache grows over this limit, # it gets cleared. This is meant to avoid memory leaks when a rogue prompt is filling the cache @@ -7505,7 +7047,6 @@ _p9k_init_params() { case $parameters[POWERLEVEL9K_BATTERY_STAGES] in scalar*) typeset -ga _POWERLEVEL9K_BATTERY_STAGES=("${(@s::)${(g::)POWERLEVEL9K_BATTERY_STAGES}}");; array*) typeset -ga _POWERLEVEL9K_BATTERY_STAGES=("${(@g::)POWERLEVEL9K_BATTERY_STAGES}");; - *) typeset -ga _POWERLEVEL9K_BATTERY_STAGES=();; esac local state for state in CHARGED CHARGING LOW DISCONNECTED; do @@ -7632,7 +7173,7 @@ _p9k_init_params() { _p9k_declare -s POWERLEVEL9K_IP_INTERFACE "" : ${_POWERLEVEL9K_IP_INTERFACE:='.*'} _p9k_segment_in_use ip || _POWERLEVEL9K_IP_INTERFACE= - _p9k_declare -s POWERLEVEL9K_VPN_IP_INTERFACE "(gpd|wg|(.*tun)|tailscale)[0-9]*|(zt.*)" + _p9k_declare -s POWERLEVEL9K_VPN_IP_INTERFACE "(gpd|wg|(.*tun)|tailscale)[0-9]*" : ${_POWERLEVEL9K_VPN_IP_INTERFACE:='.*'} _p9k_segment_in_use vpn_ip || _POWERLEVEL9K_VPN_IP_INTERFACE= _p9k_declare -b POWERLEVEL9K_VPN_IP_SHOW_ALL 0 @@ -7642,21 +7183,15 @@ _p9k_init_params() { 15) _POWERLEVEL9K_LOAD_WHICH=3;; *) _POWERLEVEL9K_LOAD_WHICH=2;; esac - _p9k_declare -F POWERLEVEL9K_LOAD_WARNING_PCT 50 - _p9k_declare -F POWERLEVEL9K_LOAD_CRITICAL_PCT 70 _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_PERLBREW_PROJECT_ONLY 1 - _p9k_declare -b POWERLEVEL9K_PERLBREW_SHOW_PREFIX 0 _p9k_declare -b POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY 0 _p9k_declare -b POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -a POWERLEVEL9K_NODENV_SOURCES -- shell local global _p9k_declare -b POWERLEVEL9K_NODENV_SHOW_SYSTEM 1 - _p9k_declare -b POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW 0 - _p9k_declare -b POWERLEVEL9K_NVM_SHOW_SYSTEM 1 _p9k_declare -b POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -a POWERLEVEL9K_RBENV_SOURCES -- shell local global _p9k_declare -b POWERLEVEL9K_RBENV_SHOW_SYSTEM 1 @@ -7700,10 +7235,6 @@ _p9k_init_params() { _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 -s POWERLEVEL9K_CHRUBY_SHOW_ENGINE_PATTERN - if (( _POWERLEVEL9K_CHRUBY_SHOW_ENGINE )); then - : ${_POWERLEVEL9K_CHRUBY_SHOW_ENGINE_PATTERN=*} - fi _p9k_declare -b POWERLEVEL9K_STATUS_CROSS 0 _p9k_declare -b POWERLEVEL9K_STATUS_OK 1 _p9k_declare -b POWERLEVEL9K_STATUS_OK_PIPE 1 @@ -7738,7 +7269,6 @@ _p9k_init_params() { _p9k_declare -i POWERLEVEL9K_VCS_COMMITS_AHEAD_MAX_NUM -1 _p9k_declare -i POWERLEVEL9K_VCS_COMMITS_BEHIND_MAX_NUM -1 _p9k_declare -b POWERLEVEL9K_VCS_RECURSE_UNTRACKED_DIRS 0 - _p9k_declare -F POWERLEVEL9K_GITSTATUS_INIT_TIMEOUT_SEC 10 _p9k_declare -b POWERLEVEL9K_DISABLE_GITSTATUS 0 _p9k_declare -e POWERLEVEL9K_VI_INSERT_MODE_STRING "INSERT" _p9k_declare -e POWERLEVEL9K_VI_COMMAND_MODE_STRING "NORMAL" @@ -7782,7 +7312,6 @@ _p9k_init_params() { # POWERLEVEL9K_KUBECONTEXT_OTHER_BACKGROUND=yellow _p9k_declare -a POWERLEVEL9K_KUBECONTEXT_CLASSES -- _p9k_declare -a POWERLEVEL9K_AWS_CLASSES -- - _p9k_declare -a POWERLEVEL9K_AZURE_CLASSES -- _p9k_declare -a POWERLEVEL9K_TERRAFORM_CLASSES -- _p9k_declare -b POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT 0 _p9k_declare -a POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES -- 'service_account:*' SERVICE_ACCOUNT @@ -7804,12 +7333,6 @@ _p9k_init_params() { # If set to true, time will update every second. _p9k_declare -b POWERLEVEL9K_EXPERIMENTAL_TIME_REALTIME 0 - _p9k_declare -b POWERLEVEL9K_NIX_SHELL_INFER_FROM_PATH 0 - typeset -g _p9k_nix_shell_cond='${IN_NIX_SHELL:#0}' - if (( _POWERLEVEL9K_NIX_SHELL_INFER_FROM_PATH )); then - _p9k_nix_shell_cond+='${path[(r)/nix/store/*]}' - fi - local -i i=1 while (( i <= $#_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS )); do local segment=${${(U)_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[i]}//İ/I} @@ -7847,7 +7370,7 @@ function _p9k_on_widget_zle-keymap-select() { _p9k_check_visual_mode; __p9k_rese function _p9k_on_widget_overwrite-mode() { _p9k_check_visual_mode; __p9k_reset_state=2; } function _p9k_on_widget_vi-replace() { _p9k_check_visual_mode; __p9k_reset_state=2; } -if [[ $ZSH_VERSION == (5.<3->*|<6->.*) ]]; then +if is-at-least 5.3; then function _p9k_check_visual_mode() { [[ ${KEYMAP:-} == vicmd ]] || return 0 local region=${${REGION_ACTIVE:-0}/2/1} @@ -7866,7 +7389,7 @@ function _p9k_on_widget_deactivate-region() { _p9k_check_visual_mode; } function _p9k_on_widget_zle-line-init() { (( _p9k__cursor_hidden )) || return 0 _p9k__cursor_hidden=0 - print -rn -- $_p9k__cnorm + echoti cnorm } function _p9k_on_widget_zle-line-finish() { @@ -7990,23 +7513,17 @@ function _p9k_widget() { res=$? } } - (( ! __p9k_enabled )) || [[ $CONTEXT != start ]] || _p9k_widget_hook "$@" - return res -} - -function _p9k_widget_zle-line-pre-redraw-impl() { - (( __p9k_enabled )) && [[ $CONTEXT == start ]] || return 0 - ! (( ${+functions[p10k-on-post-widget]} || ${#_p9k_show_on_command} || _p9k__restore_prompt_fd || _p9k__redraw_fd )) && - [[ ${KEYMAP:-} != vicmd ]] && - return - (( PENDING || KEYS_QUEUED_COUNT )) && { - (( _p9k__redraw_fd )) || { - sysopen -o cloexec -ru _p9k__redraw_fd /dev/null - zle -F $_p9k__redraw_fd _p9k_redraw + (( ! __p9k_enabled )) || [[ $CONTEXT != start ]] || { + [[ $1 == zle-line-pre-redraw ]] && (( PENDING || KEYS_QUEUED_COUNT )) && { + (( _p9k__redraw_fd )) || { + sysopen -o cloexec -ru _p9k__redraw_fd /dev/null + zle -F $_p9k__redraw_fd _p9k_redraw + } + return res } - return + _p9k_widget_hook "$@" } - _p9k_widget_hook zle-line-pre-redraw + return res } function _p9k_widget_send-break() { @@ -8021,10 +7538,9 @@ typeset -gi __p9k_widgets_wrapped=0 function _p9k_wrap_widgets() { (( __p9k_widgets_wrapped )) && return - typeset -gir __p9k_widgets_wrapped=1 local -a widget_list - if [[ $ZSH_VERSION == (5.<3->*|<6->.*) ]]; then + if is-at-least 5.3; then local -aU widget_list=( zle-line-pre-redraw zle-line-init @@ -8045,12 +7561,7 @@ function _p9k_wrap_widgets() { # There is no zle-line-pre-redraw in zsh < 5.3, so we have to wrap all widgets # with key bindings. This costs extra 3ms: 1.5ms to fetch the list of widgets and # another 1.5ms to wrap them. - if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then - local tmpdir=$TMPDIR - else - local tmpdir=/tmp - fi - local keymap tmp=$tmpdir/p10k.bindings.$sysparams[pid] + local keymap tmp=${TMPDIR:-/tmp}/p10k.bindings.$sysparams[pid] { for keymap in $keymaps; do bindkey -M $keymap; done >$tmp local -aU widget_list=( @@ -8068,44 +7579,15 @@ function _p9k_wrap_widgets() { zf_rm -f -- $tmp } fi - local widget for widget in $widget_list; do if (( ! $+functions[_p9k_widget_$widget] )); then functions[_p9k_widget_$widget]='_p9k_widget '${(q)widget}' "$@"' fi - if [[ $widget == zle-* && - $widgets[$widget] == user:azhw:* && - $functions[add-zle-hook-widget] ]]; then - add-zle-hook-widget $widget _p9k_widget_$widget - else - # The leading dot is to work around bugs in zsh-syntax-highlighting. - zle -A $widget ._p9k_orig_$widget - zle -N $widget _p9k_widget_$widget - fi + # The leading dot is to work around bugs in zsh-syntax-highlighting. + zle -A $widget ._p9k_orig_$widget + zle -N $widget _p9k_widget_$widget done 2>/dev/null # `zle -A` fails for inexisting widgets and complains to stderr - - case ${widgets[._p9k_orig_zle-line-pre-redraw]:-} in - user:-z4h-zle-line-pre-redraw) - function _p9k_widget_zle-line-pre-redraw() { - -z4h-zle-line-pre-redraw "$@" - _p9k_widget_zle-line-pre-redraw-impl - } - ;; - ?*) - function _p9k_widget_zle-line-pre-redraw() { - zle ._p9k_orig_zle-line-pre-redraw -- "$@" - local -i res=$? - _p9k_widget_zle-line-pre-redraw-impl - return res - } - ;; - '') - function _p9k_widget_zle-line-pre-redraw() { - _p9k_widget_zle-line-pre-redraw-impl - } - ;; - esac } function _p9k_restore_prompt() { @@ -8370,7 +7852,7 @@ _p9k_init_prompt() { _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' '' && - [[ $ZSH_VERSION != (5.7.<2->*|5.<8->*|<6->.*) ]]; then + ! 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}}' @@ -8379,20 +7861,13 @@ _p9k_init_prompt() { _p9k_prompt_prefix_left+='${${_p9k__ind::=${${ZLE_RPROMPT_INDENT:-1}/#-*/0}}+}' fi - if (( _POWERLEVEL9K_TERM_SHELL_INTEGRATION )); then - _p9k_prompt_prefix_left+=$'%{\e]133;A\a%}' - _p9k_prompt_suffix_left+=$'%{\e]133;B\a%}' - if [[ $TERM_PROGRAM == WarpTerminal ]]; then - _p9k_prompt_prefix_right=$'%{\e]133;P;k=r\a%}'$_p9k_prompt_prefix_right - _p9k_prompt_suffix_right+=$'%{\e]133;B\a%}' - fi + if [[ $ITERM_SHELL_INTEGRATION_INSTALLED == Yes ]]; then if (( $+_z4h_iterm_cmd && _z4h_can_save_restore_screen == 1 )); then _p9k_prompt_prefix_left+=$'%{\ePtmux;\e\e]133;A\a\e\\%}' _p9k_prompt_suffix_left+=$'%{\ePtmux;\e\e]133;B\a\e\\%}' - if [[ $TERM_PROGRAM == WarpTerminal ]]; then - _p9k_prompt_prefix_right=$'%{\ePtmux;\e\e]133;P;k=r\a\e\\%}'$_p9k_prompt_prefix_right - _p9k_prompt_suffix_right+=$'%{\ePtmux;\e\e]133;B\a\e\\%}' - fi + else + _p9k_prompt_prefix_left+=$'%{\e]133;A\a%}' + _p9k_prompt_suffix_left+=$'%{\e]133;B\a%}' fi fi @@ -8469,9 +7944,8 @@ _p9k_init_ssh() { # # License: https://github.com/sindresorhus/pure/blob/e8abf9d37185ec9b7b4398ca9c5eba555a1028eb/license. - [[ -n $P9K_SSH && $_P9K_SSH_TTY == $TTY ]] && return + [[ -n $P9K_SSH ]] && return typeset -gix P9K_SSH=0 - typeset -gx _P9K_SSH_TTY=$TTY if [[ -n $SSH_CLIENT || -n $SSH_TTY || -n $SSH_CONNECTION ]]; then P9K_SSH=1 return 0 @@ -8493,21 +7967,6 @@ _p9k_init_ssh() { [[ $w =~ "\(?($ipv4|$ipv6|$hostname)\)?\$" ]] && P9K_SSH=1 } -_p9k_init_toolbox() { - [[ -z $P9K_TOOLBOX_NAME ]] || return 0 - if [[ -f /run/.containerenv && -r /run/.containerenv ]]; then - local name=(${(Q)${${(@M)${(f)"$(&2 echo -E - "" >&2 echo -E - "${(%):-[%1FERROR%f]: When using instant prompt, Powerlevel10k must be loaded before the first prompt.}" @@ -9007,9 +8422,9 @@ _p9k_init() { >&2 echo -E - "" >&2 echo -E - "${(%):- - %BRecommended%b: Change the way Powerlevel10k is loaded from %B$__p9k_zshrc_u%b.}" if (( _p9k_term_has_href )); then - >&2 echo - "${(%):- See \e]8;;https://github.com/romkatv/powerlevel10k#installation\ahttps://github.com/romkatv/powerlevel10k#installation\e]8;;\a.}" + >&2 echo - "${(%):- See \e]8;;https://github.com/romkatv/powerlevel10k/blob/master/README.md#installation\ahttps://github.com/romkatv/powerlevel10k/blob/master/README.md#installation\e]8;;\a.}" else - >&2 echo - "${(%):- See https://github.com/romkatv/powerlevel10k#installation.}" + >&2 echo - "${(%):- See https://github.com/romkatv/powerlevel10k/blob/master/README.md#installation.}" fi if (( $+zsh_defer_options )); then >&2 echo -E - "" @@ -9038,7 +8453,7 @@ _p9k_init() { >&2 echo -E - "${(%):- * You %Bwill%b see this error message every time you start zsh.}" >&2 echo -E - "${(%):- * Zsh will start %Bslowly%b.}" >&2 echo -E - "" - } 2>>$tty + } 2>>$TTY fi } @@ -9060,7 +8475,7 @@ _p9k_deinit() { fi (( $+_p9k__iterm2_precmd )) && functions[iterm2_precmd]=$_p9k__iterm2_precmd (( $+_p9k__iterm2_decorate_prompt )) && functions[iterm2_decorate_prompt]=$_p9k__iterm2_decorate_prompt - unset -m '(_POWERLEVEL9K_|P9K_|_p9k_)*~(P9K_SSH|_P9K_SSH_TTY|P9K_TOOLBOX_NAME|P9K_TTY|_P9K_TTY)' + unset -m '(_POWERLEVEL9K_|P9K_|_p9k_)*~(P9K_SSH|P9K_TTY|_P9K_TTY)' [[ -n $__p9k_locale ]] || unset __p9k_locale } @@ -9069,7 +8484,7 @@ typeset -gi __p9k_configured=0 typeset -gri __p9k_instant_prompt_disabled=1 # `typeset -g` doesn't roundtrip in zsh prior to 5.4. -if [[ $ZSH_VERSION == (5.<4->*|<6->.*) ]]; then +if is-at-least 5.4; then typeset -gri __p9k_dumps_enabled=1 else typeset -gri __p9k_dumps_enabled=0 @@ -9077,17 +8492,6 @@ fi _p9k_do_nothing() { true; } -_p9k_precmd_first() { - eval "$__p9k_intro" - if [[ -n $KITTY_SHELL_INTEGRATION && KITTY_SHELL_INTEGRATION[(wIe)no-prompt-mark] -eq 0 ]]; then - KITTY_SHELL_INTEGRATION+=' no-prompt-mark' - (( $+__p9k_force_term_shell_integration )) || typeset -gri __p9k_force_term_shell_integration=1 - elif [[ $TERM_PROGRAM == WarpTerminal ]]; then - (( $+__p9k_force_term_shell_integration )) || typeset -gri __p9k_force_term_shell_integration=1 - fi - typeset -ga precmd_functions=(${precmd_functions:#_p9k_precmd_first}) -} - _p9k_setup() { (( __p9k_enabled )) && return @@ -9100,7 +8504,7 @@ _p9k_setup() { prompt_powerlevel9k_teardown __p9k_enabled=1 typeset -ga preexec_functions=(_p9k_preexec1 $preexec_functions _p9k_preexec2) - typeset -ga precmd_functions=(_p9k_do_nothing _p9k_precmd_first $precmd_functions _p9k_precmd) + typeset -ga precmd_functions=(_p9k_do_nothing $precmd_functions _p9k_precmd) } prompt_powerlevel9k_setup() { @@ -9483,9 +8887,5 @@ if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file && -n $__p9k_instant_p zf_rm -f -- $__p9k_instant_prompt_dump_file{,.zwc} 2>/dev/null fi -typeset -g P9K_VERSION=1.20.10 -unset VSCODE_SHELL_INTEGRATION - _p9k_init_ssh -_p9k_init_toolbox prompt_powerlevel9k_setup diff --git a/internal/parser.zsh b/internal/parser.zsh index 6c16adcd..dc2082de 100644 --- a/internal/parser.zsh +++ b/internal/parser.zsh @@ -152,7 +152,7 @@ function _p9k_parse_buffer() { local -r var="\$$id|\${$id}|\"\$$id\"|\"\${$id}\"" local -i e ic c=${2:-'1 << 62'} - local skip n s r state token cmd prev + local skip n s r state cmd prev local -a aln alp alf v if [[ -o interactive_comments ]]; then diff --git a/internal/wizard.zsh b/internal/wizard.zsh index 8d20675c..793c8ef3 100644 --- a/internal/wizard.zsh +++ b/internal/wizard.zsh @@ -14,11 +14,22 @@ if (( OPTIND <= ARGC )); then return 1 fi +if (( $+terminfo[smcup] && $+terminfo[rmcup] )) && echoti smcup 2>/dev/null; then + function restore_screen() { + echoti rmcup 2>/dev/null + function restore_screen() {} + } +else + function restore_screen() {} +fi + local -i in_z4h_wizard=0 [[ $force == 0 && $+functions[z4h] == 1 && -n $Z4H && -e $Z4H/welcome ]] && in_z4h_wizard=1 local -i success=0 +{ # always + local -ri force local -r font_base_url='https://github.com/romkatv/powerlevel10k-media/raw/master' @@ -222,12 +233,7 @@ function hide_cursor() { } function show_cursor() { - local cnorm=${terminfo[cnorm]-} - if [[ $cnorm == *$'\e[?25h'(|'\e'*) ]]; then - print -n '\e[?25h' - else - print -n $cnorm - fi + echoti cnorm 2>/dev/null } function consume_input() { @@ -744,7 +750,7 @@ function ask_python() { return 0 } -function ask_quotes() { +function ask_arrow() { add_widget 0 flowing -c %BDoes this look like%b "%2F><%f" %Bbut taller and "fatter?%b" add_widget 0 print -P "" add_widget 0 flowing -c -- "---> \u276F\u276E <---" @@ -758,35 +764,6 @@ function ask_quotes() { add_widget 2 add_widget 0 print -P "(r) Restart from the beginning." ask ynr - case $choice in - r) return 1;; - y) cap_quotes=1;; - n) cap_quotes=0;; - esac - return 0 -} - -function ask_arrow() { - # This condition holds as long as zsh is compiled with unicode 9 support. - if (( ${(m)#${(g::)1}} != 1 )); then - cap_arrow=0 - return - fi - [[ -n $2 ]] && add_widget 0 flowing -c "$2" - add_widget 0 flowing -c %BDoes this look like an%b "%2Fupwards arrow%f%B?%b" - add_widget 0 flowing -c reference: "$(href https://graphemica.com/%F0%9F%A0%89)" - add_widget 0 print -P "" - add_widget 0 flowing -c -- "---> $1 <---" - add_widget 0 print -P "" - add_widget 3 - add_widget 0 print -P "%B(y) Yes.%b" - add_widget 0 print -P "" - add_widget 1 - add_widget 0 print -P "%B(n) No.%b" - add_widget 0 print -P "" - add_widget 2 - add_widget 0 print -P "(r) Restart from the beginning." - ask ynr case $choice in r) return 1;; y) cap_arrow=1;; @@ -795,35 +772,25 @@ function ask_arrow() { return 0 } -function print_indented() { - local -i max_width=$1 - local text=$2 - local -i indent='(wizard_columns - max_width) / 2' - print -P "${(l:$indent:: :)}$text" -} - -function ask_width() { - add_widget 0 flowing -c %BWhat digit is the%b "%2Fdownwards arrow%f" %Bpointing "at?%b" +function ask_debian() { + add_widget 0 flowing -c %BDoes this look like a%b "%2FDebian logo%f" "%B(swirl/spiral)?%b" + add_widget 0 flowing -c reference: "$(href https://debian.org/logos/openlogo-nd.svg)" add_widget 0 print -P "" - add_widget 0 print_indented 11 '%3F\UF0734%f %3F\UF0734%f %3F\UF0734%f %2F\UF072E%f' - add_widget 0 print_indented 11 ' 111222' + add_widget 0 flowing -c -- "---> \uF306 <---" add_widget 0 print -P "" add_widget 3 - add_widget 0 print -P "%B(1) It is pointing at '1'.%b" + add_widget 0 print -P "%B(y) Yes.%b" add_widget 0 print -P "" add_widget 1 - add_widget 0 print -P "%B(2) It is pointing at '2'.%b" - add_widget 0 print -P "" - add_widget 1 - add_widget 0 print -P "%B(3) Something else.%b" + add_widget 0 print -P "%B(n) No.%b" add_widget 0 print -P "" add_widget 2 add_widget 0 print -P "(r) Restart from the beginning." - ask 123r + ask ynr case $choice in r) return 1;; - 1) cap_arrow=1;; - 2|3) cap_arrow=0;; + y) cap_debian=1;; + n) cap_debian=0;; esac return 0 } @@ -949,9 +916,9 @@ function ask_charset() { POWERLEVEL9K_ICON_PADDING=none cap_diamond=0 cap_python=0 - cap_arrow=0 + cap_debian=0 cap_lock=0 - cap_quotes=0 + cap_arrow=0 ;; esac return 0 @@ -1027,15 +994,6 @@ function ask_color() { return 0 } -function print_frame_marker() { - local label="(1) $color_name[1]." - local -i n='wizard_columns - 7' - local -i m=$((n - $#label)) - print -P "${(l:$n:: :)}frame" - print -P "%B$label%b${(l:$m:: :)} |" - print -P "${(l:$n:: :)} v" -} - function ask_ornaments_color() { [[ $style != (rainbow|lean*) || $num_lines == 1 ]] && return [[ $gap_char == ' ' && $left_frame == 0 && $right_frame == 0 ]] && return @@ -1043,17 +1001,10 @@ function ask_ornaments_color() { [[ $gap_char != ' ' ]] && ornaments+=Connection (( left_frame || right_frame )) && ornaments+=Frame add_widget 0 flowing -c "%B${(j: & :)ornaments} Color%b" - if (( left_frame || right_frame )); then - add_widget 0 print_frame_marker - add_widget 3 print -P "%B(1) $color_name[1].%b" - add_prompt_n color=1 - add_widget 0 print - add_widget 2 - else - add_widget 1 - add_widget 0 print -P "%B(1) $color_name[1].%b" - add_prompt color=1 - fi + add_widget 0 print + add_widget 1 + add_widget 0 print -P "%B(1) $color_name[1].%b" + add_prompt color=1 add_widget 0 print -P "%B(2) $color_name[2].%b" add_prompt color=2 add_widget 0 print -P "%B(3) $color_name[3].%b" @@ -1075,19 +1026,19 @@ function ask_time() { add_widget 0 flowing -c "%BShow current time?%b" add_widget 0 print add_widget 1 - add_widget 0 print -P "%B(n) No.%b" + add_widget 0 print -P "%B(1) No.%b" add_prompt time= - add_widget 0 print -P "%B(1) 12-hour format.%b" - add_prompt time=$time_12h add_widget 0 print -P "%B(2) 24-hour format.%b" add_prompt time=$time_24h + add_widget 0 print -P "%B(3) 12-hour format.%b" + add_prompt time=$time_12h add_widget 0 print -P "(r) Restart from the beginning." - ask n12r + ask 123r case $choice in r) return 1;; - n) time=;; - 1) time=$time_12h; options+='12h time';; + 1) time=;; 2) time=$time_24h; options+='24h time';; + 3) time=$time_12h; options+='12h time';; esac return 0 } @@ -1106,7 +1057,7 @@ function ask_use_rprompt() { case $choice in r) return 1;; 1) ;; - 2) pure_use_rprompt=; options+=rprompt;; + 2) pure_use_rprompt=; options+=rpromt;; esac return 0 } @@ -1126,26 +1077,18 @@ function os_icon_name() { if [[ -r /etc/os-release ]]; then local lines=(${(f)"$(*|<6->.*) ]]; then + if ! is-at-least 5.4; then instant_prompt=off options+=instant_prompt=auto-off return 0 @@ -1606,19 +1546,9 @@ function ask_config_overwrite() { case $choice in r) return 1;; y) - if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then - local tmpdir=$TMPDIR - local tmpdir_u='$TMPDIR' - else - local tmpdir=/tmp - local tmpdir_u=/tmp - fi - if (( ! $+commands[mktemp] )) || - ! config_backup=$(mktemp $tmpdir/$__p9k_cfg_basename.XXXXXXXXXX 2>/dev/null); then - config_backup=$tmpdir/$__p9k_cfg_basename.$EPOCHREALTIME - fi - cp $__p9k_cfg_path $config_backup || quit -c - config_backup_u=$tmpdir_u/${(q-)config_backup:t} + config_backup="$(mktemp ${TMPDIR:-/tmp}/$__p9k_cfg_basename.XXXXXXXXXX)" || quit -c + cp $__p9k_cfg_path $config_backup || quit -c + config_backup_u=${${TMPDIR:+\$TMPDIR}:-/tmp}/${(q-)config_backup:t} ;; esac return 0 @@ -1635,12 +1565,40 @@ function ask_zshrc_edit() { if (( $+functions[z4h] )); then zshrc_has_cfg=1 zshrc_has_instant_prompt=1 - return fi - check_zshrc_integration || quit -c [[ $instant_prompt == off ]] && zshrc_has_instant_prompt=1 - (( zshrc_has_cfg && zshrc_has_instant_prompt )) && return + + if [[ -e $__p9k_zshrc ]]; then + zshrc_content="$(<$__p9k_zshrc)" || quit -c + local lines=(${(f)zshrc_content}) + local f0=$__p9k_cfg_path_o + local f1=${(q)f0} + local f2=${(q-)f0} + local f3=${(qq)f0} + local f4=${(qqq)f0} + local g1=${${(q)__p9k_cfg_path_o}/#(#b)${(q)HOME}\//'~/'} + local h0='${ZDOTDIR:-~}/.p10k.zsh' + local h1='${ZDOTDIR:-$HOME}/.p10k.zsh' + local h2='"${ZDOTDIR:-$HOME}/.p10k.zsh"' + local h3='"${ZDOTDIR:-$HOME}"/.p10k.zsh' + local h4='${ZDOTDIR}/.p10k.zsh' + local h5='"${ZDOTDIR}/.p10k.zsh"' + local h6='"${ZDOTDIR}"/.p10k.zsh' + local h7='$ZDOTDIR/.p10k.zsh' + local h8='"$ZDOTDIR/.p10k.zsh"' + local h9='"$ZDOTDIR"/.p10k.zsh' + local h10='$POWERLEVEL9K_CONFIG_FILE' + local h11='"$POWERLEVEL9K_CONFIG_FILE"' + if [[ -n ${(@M)lines:#(#b)[^#]#([^[:IDENT:]]|)source[[:space:]]##($f1|$f2|$f3|$f4|$g1|$h0|$h1|$h2|$h3|$h4|$h5|$h6|$h7|$h8|$h9|$h10|$h11)(|[[:space:]]*|'#'*)} ]]; then + zshrc_has_cfg=1 + fi + local pre='${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh' + if [[ -n ${(@M)lines:#(#b)[^#]#([^[:IDENT:]]|)source[[:space:]]##($pre|\"$pre\")(|[[:space:]]*|'#'*)} ]]; then + zshrc_has_instant_prompt=1 + fi + (( zshrc_has_cfg && zshrc_has_instant_prompt )) && return + fi add_widget 0 flowing -c %BApply changes to "%b%2F${__p9k_zshrc_u//\\/\\\\}%f%B?%b" add_widget 0 print -P "" @@ -1679,26 +1637,16 @@ function ask_zshrc_edit() { y) write_zshrc=1 if [[ -n $zshrc_content ]]; then - if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then - local tmpdir=$TMPDIR - local tmpdir_u='$TMPDIR' - else - local tmpdir=/tmp - local tmpdir_u=/tmp - fi - if (( ! $+commands[mktemp] )) || - ! zshrc_backup="$(mktemp $tmpdir/.zshrc.XXXXXXXXXX 2>/dev/null)"; then - zshrc_backup=$tmpdir/.zshrc.$EPOCHREALTIME - fi - cp -p $__p9k_zshrc $zshrc_backup || quit -c + zshrc_backup="$(mktemp ${TMPDIR:-/tmp}/.zshrc.XXXXXXXXXX)" || quit -c + cp -p $__p9k_zshrc $zshrc_backup || quit -c local -i writable=1 if [[ ! -w $zshrc_backup ]]; then - chmod u+w -- $zshrc_backup || quit -c + chmod u+w -- $zshrc_backup || quit -c writable=0 fi - print -r -- $zshrc_content >$zshrc_backup || quit -c - (( writable )) || chmod u-w -- $zshrc_backup || quit -c - zshrc_backup_u=$tmpdir_u/${(q-)zshrc_backup:t} + print -r -- $zshrc_content >$zshrc_backup || quit -c + (( writable )) || chmod u-w -- $zshrc_backup || quit -c + zshrc_backup_u=${${TMPDIR:+\$TMPDIR}:-/tmp}/${(q-)zshrc_backup:t} fi ;; esac @@ -1747,8 +1695,6 @@ function generate_config() { sub NORDVPN_VISUAL_IDENTIFIER_EXPANSION "'nord'" uncomment 'typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION' sub RANGER_VISUAL_IDENTIFIER_EXPANSION "'▲'" - uncomment 'typeset -g POWERLEVEL9K_YAZI_VISUAL_IDENTIFIER_EXPANSION' - sub YAZI_VISUAL_IDENTIFIER_EXPANSION "'▲'" uncomment 'typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION' sub KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION "'○'" uncomment 'typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION' @@ -1770,14 +1716,9 @@ function generate_config() { sub PYTHON_ICON "'🐍'" fi - case $POWERLEVEL9K_MODE in - nerdfont-complete) - sub BATTERY_STAGES "'\uf58d\uf579\uf57a\uf57b\uf57c\uf57d\uf57e\uf57f\uf580\uf581\uf578'" - ;; - nerdfont-v3) - sub BATTERY_STAGES "'\UF008E\UF007A\UF007B\UF007C\UF007D\UF007E\UF007F\UF0080\UF0081\UF0082\UF0079'" - ;; - esac + if [[ $POWERLEVEL9K_MODE == nerdfont-complete ]]; then + sub BATTERY_STAGES "'\uf58d\uf579\uf57a\uf57b\uf57c\uf57d\uf57e\uf57f\uf580\uf581\uf578'" + fi if [[ $style == (classic|rainbow) ]]; then if [[ $style == classic ]]; then @@ -1826,7 +1767,6 @@ function generate_config() { uncomment 'typeset -g POWERLEVEL9K_CONTEXT_PREFIX' uncomment 'typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX' uncomment 'typeset -g POWERLEVEL9K_TIME_PREFIX' - uncomment 'typeset -g POWERLEVEL9K_TOOLBOX_PREFIX' if [[ $style == (lean|classic) ]]; then [[ $style == classic ]] && local fg="%$prefix_color[$color]F" || local fg="%f" sub VCS_PREFIX "'${fg}on '" @@ -1834,7 +1774,6 @@ function generate_config() { sub CONTEXT_PREFIX "'${fg}with '" sub KUBECONTEXT_PREFIX "'${fg}at '" sub TIME_PREFIX "'${fg}at '" - sub TOOLBOX_PREFIX "'${fg}in '" fi fi @@ -1957,7 +1896,7 @@ function generate_config() { command mkdir -p -- ${__p9k_cfg_path:h} || return if [[ -e $__p9k_cfg_path ]]; then - zf_rm -f -- $__p9k_cfg_path || return + unlink $__p9k_cfg_path || return fi print -lr -- "$header" "$lines[@]" >$__p9k_cfg_path } @@ -2009,84 +1948,16 @@ fi" || return return 0 } -function check_zshrc_integration() { - typeset -g zshrc_content= - typeset -gi zshrc_has_cfg=0 zshrc_has_instant_prompt=0 - [[ -e $__p9k_zshrc ]] || return 0 - zshrc_content="$(<$__p9k_zshrc)" || return - local lines=(${(f)zshrc_content}) - local f0=$__p9k_cfg_path_o - local f1=${(q)f0} - local f2=${(q-)f0} - local f3=${(qq)f0} - local f4=${(qqq)f0} - local g1=${${(q)__p9k_cfg_path_o}/#(#b)${(q)HOME}\//'~/'} - local h0='${ZDOTDIR:-~}/.p10k.zsh' - local h1='${ZDOTDIR:-$HOME}/.p10k.zsh' - local h2='"${ZDOTDIR:-$HOME}/.p10k.zsh"' - local h3='"${ZDOTDIR:-$HOME}"/.p10k.zsh' - local h4='${ZDOTDIR}/.p10k.zsh' - local h5='"${ZDOTDIR}/.p10k.zsh"' - local h6='"${ZDOTDIR}"/.p10k.zsh' - local h7='$ZDOTDIR/.p10k.zsh' - local h8='"$ZDOTDIR/.p10k.zsh"' - local h9='"$ZDOTDIR"/.p10k.zsh' - local h10='$POWERLEVEL9K_CONFIG_FILE' - local h11='"$POWERLEVEL9K_CONFIG_FILE"' - if [[ -n ${(@M)lines:#(#b)[^#]#([^[:IDENT:]]|)source[[:space:]]##(|--[[:space:]]##)($f1|$f2|$f3|$f4|$g1|$h0|$h1|$h2|$h3|$h4|$h5|$h6|$h7|$h8|$h9|$h10|$h11)(|[[:space:]]*|'#'*)} ]]; then - zshrc_has_cfg=1 - fi - local pre='${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh' - if [[ -n ${(@M)lines:#(#b)[^#]#([^[:IDENT:]]|)source[[:space:]]##($pre|\"$pre\")(|[[:space:]]*|'#'*)} ]]; then - zshrc_has_instant_prompt=1 - fi - return 0 -} - -() { - (( force )) && return - _p9k_can_configure -q || return 0 - local zshrc_content zshrc_has_cfg zshrc_has_instant_prompt - check_zshrc_integration 2>/dev/null || return 0 - (( zshrc_has_cfg )) || return 0 - [[ -s $__p9k_cfg_path ]] || return 0 - print -P "" - flowing \ - Powerlevel10k configuration file "($__p9k_cfg_path_u)" was not sourced. This \ - might have been caused by errors in zsh startup files, most likely in \ - $__p9k_zshrc_u. See above for any indication of such errors and fix them. If \ - there are no errors, try running Powerlevel10k configuration wizard: - print -P '' - print -P ' %2Fp10k%f %Bconfigure%b' - print -P '' - flowing \ - If you do nothing, you will see this message again when you start zsh. You can \ - suppress it by defining %BPOWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true%b in \ - $__p9k_zshrc_u. - print -P '' - return 1 -} || return - -if (( $+terminfo[smcup] && $+terminfo[rmcup] )) && echoti smcup 2>/dev/null; then - function restore_screen() { - echoti rmcup 2>/dev/null - function restore_screen() {} - } -else - function restore_screen() {} -fi - -{ # always - if (( force )); then _p9k_can_configure || return else _p9k_can_configure -q || return fi -zmodload zsh/terminfo zsh/datetime || return +zmodload zsh/terminfo || return +autoload -Uz is-at-least || return -if [[ $ZSH_VERSION == (5.7.<1->*|5.<8->*|<6->.*) && $COLORTERM == (24bit|truecolor) ]]; then +if is-at-least 5.7.1 && [[ $COLORTERM == (24bit|truecolor) ]]; then local -ir has_truecolor=1 else local -ir has_truecolor=0 @@ -2101,7 +1972,7 @@ while true; do local gap_char=' ' prompt_char='❯' down_triangle='\uE0BC' up_triangle='\uE0BA' slanted_bar='\u2571' local left_subsep= right_subsep= left_tail= right_tail= left_head= right_head= time= local -i num_lines=2 empty_line=0 color=2 left_frame=1 right_frame=1 transient_prompt=0 - local -i cap_diamond=0 cap_python=0 cap_arrow=0 cap_lock=0 cap_quotes=0 + local -i cap_diamond=0 cap_python=0 cap_debian=0 cap_lock=0 cap_arrow=0 local -a extra_icons=('' '' '') local -a frame_color=(244 242 240 238) local -a color_name=(Lightest Light Dark Darkest) @@ -2115,7 +1986,7 @@ while true; do unset pure_use_rprompt - if [[ -o multibyte && $TERM != (dumb|linux) && $langinfo[CODESET] == (utf|UTF)(-|)8 ]]; then + if [[ $TERM != (dumb|linux) && $langinfo[CODESET] == (utf|UTF)(-|)8 ]]; then ask_font || continue ask_diamond || continue if [[ $AWESOME_GLYPHS_LOADED == 1 ]]; then @@ -2135,27 +2006,19 @@ while true; do if (( cap_diamond )); then POWERLEVEL9K_MODE=powerline else - ask_quotes || continue - (( cap_quotes )) && POWERLEVEL9K_MODE=compatible || POWERLEVEL9K_MODE=ascii + ask_arrow || continue + (( cap_arrow )) && POWERLEVEL9K_MODE=compatible || POWERLEVEL9K_MODE=ascii fi fi elif (( ! cap_diamond )); then POWERLEVEL9K_MODE=awesome-fontconfig else - ask_arrow '\UF0737' || continue - if (( cap_arrow )); then - ask_width || continue - fi - if (( cap_arrow )); then - POWERLEVEL9K_MODE=nerdfont-v3 + ask_debian || continue + if (( cap_debian )); then + POWERLEVEL9K_MODE=nerdfont-complete else - ask_arrow '\uFC35' "Let's try another one." || continue - if (( cap_arrow )); then - POWERLEVEL9K_MODE=nerdfont-complete - else - POWERLEVEL9K_MODE=awesome-fontconfig - ask_python || continue - fi + POWERLEVEL9K_MODE=awesome-fontconfig + ask_python || continue fi fi fi @@ -2227,12 +2090,12 @@ restore_screen if (( !in_z4h_wizard )); then print - flowing +c New config: "%U${__p9k_cfg_path_u//\\/\\\\}%u." + flowing +c New config: "%B${__p9k_cfg_path_u//\\/\\\\}%b." if [[ -n $config_backup ]]; then - flowing +c Backup of the old config: "%U${config_backup_u//\\/\\\\}%u." + flowing +c Backup of the old config: "%B${config_backup_u//\\/\\\\}%b." fi if [[ -n $zshrc_backup ]]; then - flowing +c Backup of "%U${__p9k_zshrc_u//\\/\\\\}%u:" "%U${zshrc_backup_u//\\/\\\\}%u." + flowing +c Backup of "%B${__p9k_zshrc_u//\\/\\\\}%b:" "%B${zshrc_backup_u//\\/\\\\}%b." fi fi diff --git a/internal/worker.zsh b/internal/worker.zsh index 269e8aad..8eb21af3 100644 --- a/internal/worker.zsh +++ b/internal/worker.zsh @@ -181,13 +181,7 @@ function _p9k_worker_start() { setopt monitor || return { [[ -n $_p9k__worker_resp_fd ]] && return - - if [[ -n "$TMPDIR" && ( ( -d "$TMPDIR" && -w "$TMPDIR" ) || ! ( -d /tmp && -w /tmp ) ) ]]; then - local tmpdir=$TMPDIR - else - local tmpdir=/tmp - fi - _p9k__worker_file_prefix=$tmpdir/p10k.worker.$EUID.$sysparams[pid].$EPOCHSECONDS + _p9k__worker_file_prefix=${TMPDIR:-/tmp}/p10k.worker.$EUID.$sysparams[pid].$EPOCHSECONDS sysopen -r -o cloexec -u _p9k__worker_resp_fd <( exec 0