diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..86e55ee4
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,14 @@
+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
+ $(MAKE) -C gitstatus pkg
diff --git a/README.md b/README.md
index 3f0cae42..22c68d62 100644
--- a/README.md
+++ b/README.md
@@ -2,48 +2,59 @@
[](
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).

-Ready to [get started](#get-started)? See below.
+- [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)
-To see what Powerlevel10k is about go to [features](#features).
+## Getting started
-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
+1. [Install the recommended font](#meslo-nerd-font-patched-for-powerlevel10k). *Optional but highly
recommended.*
-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. [Install Powerlevel10k](#installation) itself.
+1. Restart Zsh with `exec 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
+
+ 
+
All styles except [Pure](#pure-compatibility) are functionally equivalent. They display the same
information and differ only in presentation.
@@ -82,17 +93,21 @@ 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
+
+ 
+
Note how the effect of every command is instantly reflected by the very next prompt.
| Command | Prompt Indicator | Meaning |
|-------------------------------|:----------------:|----------------------------------------------------------------------:|
-| `timew start hack linux` | `๐ก๏ธ hack linux` | time tracking enabled in [timewarrior](https://timewarrior.net/) |
+| `timew start hack linux` | `โ hack linux` | time tracking enabled in [timewarrior](https://timewarrior.net/) |
| `touch x y` | `?2` | 2 untracked files in the Git repo |
| `rm COPYING` | `!1` | 1 unstaged change in the Git repo |
-| `echo 2.7.3 >.python-version` | `๐ 2.7.3` | the current python version in [pyenv](https://github.com/pyenv/pyenv) |
+| `echo 3.7.3 >.python-version` | `๐ 3.7.3` | the current python version in [pyenv](https://github.com/pyenv/pyenv) |
Other Zsh themes capable of displaying the same information either produce prompt lag or print
prompt that doesn't reflect the current state of the system and then refresh it later. With
@@ -105,8 +120,12 @@ Powerlevel10k you get fast prompt *and* up-to-date information.
Powerlevel10k understands all [Powerlevel9k](https://github.com/Powerlevel9k/powerlevel9k)
configuration parameters.
-
+
+ Screen recording
+
+ 
+
[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
@@ -128,8 +147,12 @@ 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
+
+ 
+
You can still use Powerlevel10k features such as [transient prompt](#transient-prompt) or
[instant prompt](#instant-prompt) when sporting Pure style.
@@ -148,22 +171,33 @@ 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 can remove Zsh startup lag **even if it's not caused by a theme**.
-
+
+ Screen recording
+
+ 
+
This feature is called *Instant Prompt*. You need to explicitly enable it through `p10k configure`
-or [manually](#how-do-i-enable-instant-prompt). It does what it says on the tin -- prints prompt
+or [manually](#how-do-i-configure-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.
-*FAQ:* [How do I enable instant prompt?](#how-do-i-enable-instant-prompt)
+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)
### Show on command
@@ -175,16 +209,19 @@ 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
+
+ 
+
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 kubectl, helm, kubens, kubectx, oc, istioctl or kogito.
-typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito'
+# 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'
```
To customize when different prompt segments are shown, open `~/.p10k.zsh`, search for
@@ -196,8 +233,12 @@ 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
+
+ 
+
Transient prompt makes it much easier to copy-paste series of commands from the terminal scrollback.
@@ -211,8 +252,12 @@ 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
+
+ 
+
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
@@ -235,8 +280,12 @@ Directory segments are shown in one of three colors:
Powerlevel10k can be configured to look like any other Zsh theme out there.
-
+
+ Screen recording
+
+ 
+
[Pure](#pure-compatibility), [Powerlevel9k](#powerlevel9k-compatibility) and [robbyrussell](
#how-to-make-powerlevel10k-look-like-robbyrussell-oh-my-zsh-theme) emulations are built-in.
@@ -256,81 +305,97 @@ To ~~ridiculous~~ extravagant:
### Batteries included
-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.
+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.
| Segment | Meaning |
|--------:|---------|
-| `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: `โฏ`, `โฎ`, `โ
ค`, `โถ` 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 |
+| `asdf` | tool versions from [asdf](https://github.com/asdf-vm/asdf) |
| `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) |
-| `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`) |
+| `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) |
| `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 |
-| `todo` | [todo](https://github.com/todotxt/todo.txt-cli) items |
-| `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 |
+| `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) |
+| `vpn_ip` | virtual private network indicator |
| `wifi` | WiFi speed |
-| `battery` | internal battery state and charge level (yep, batteries *literally* included) |
+| `xplr` | [xplr](https://github.com/sayanarijit/xplr) shell |
### 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
+
+ 
+
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
@@ -339,16 +404,47 @@ 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
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
-echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>! ~/.zshrc
+echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
+```
+
+Users in 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
+echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
```
This is the simplest kind of installation and it works even if you are using a plugin manager. Just
@@ -357,11 +453,17 @@ make sure to disable the current theme in your plugin manager. See
### Oh My Zsh
-```zsh
-git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k
-```
+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 ไธ็ๅฎๆน้ๅๅ ้ไธ่ฝฝ.
-Set `ZSH_THEME="powerlevel10k/powerlevel10k"` in `~/.zshrc`.
+ ```zsh
+ git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"
+ ```
+2. Open `~/.zshrc`, find the line that sets `ZSH_THEME`, and change its value to `"powerlevel10k/powerlevel10k"`.
### Prezto
@@ -369,12 +471,16 @@ Add `zstyle :prezto:module:prompt theme powerlevel10k` to `~/.zpreztorc`.
### Zim
-Add `zmodule romkatv/powerlevel10k` to `~/.zimrc` and run `zimfw install`.
+Add `zmodule romkatv/powerlevel10k --use degit` 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`
@@ -402,22 +508,52 @@ 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 romkatv/powerlevel10k/powerlevel10k
-echo 'source /usr/local/opt/powerlevel10k/powerlevel10k.zsh-theme' >>! ~/.zshrc
+brew install powerlevel10k
+echo "source $(brew --prefix)/share/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc
```
### Arch Linux
```zsh
-pacman -S --noconfirm zsh-theme-powerlevel10k
-echo 'source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme' >>! ~/.zshrc
+yay -S --noconfirm zsh-theme-powerlevel10k-git
+echo 'source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
```
+[zsh-theme-powerlevel10k-git](https://aur.archlinux.org/packages/zsh-theme-powerlevel10k-git/)
+referenced above is the official Powerlevel10k package.
+
+### 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
@@ -477,7 +613,7 @@ the default system fonts. The full choice of style options is available only whe
๐ **Recommended font**: Meslo Nerd Font patched for Powerlevel10k. ๐
-### Meslo Nerd Font patched for Powerlevel10k
+### Meslo Nerd Font patched for Powerlevel10k
Gorgeous monospace font designed by Jim Lyles for Bitstream, customized by the same for Apple,
further customized by Andrรฉ Berg, and finally patched by yours truly with customized scripts
@@ -496,48 +632,164 @@ If you are using a different terminal, proceed with manual font installation.
#### Manual font installation
-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**: Open *iTerm2 โ Preferences โ Profiles โ Text* and set *Font* to `MesloLGS NF`.
- Alternatively, type `p10k configure` and answer `Yes` when asked whether to install
- *Meslo Nerd Font*.
-- **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`.
-- **Windows Terminal** (the new thing): Open *Settings* (`Ctrl+,`), search for `fontFace` and set
- value to `MesloLGS NF` for every profile.
-- **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`.
-
-**IMPORTANT:** Run `p10k configure` after changing terminal font. The old `~/.p10k.zsh` may work
-incorrectly with the new font.
+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`.
+ - **Warp**: Open Warp and Navigate to *Settings* then *Appearance*. Scroll down to *Text* Section
+ and under *"Terminal Font"*, select the `MesloLGS NF` font.
+ - **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.
+ - **Deepin Terminal**: Create or open `~/.config/deepin/deepin-terminal/config.conf` and add the following section
+ to it:
+ ```ini
+ [basic.interface.font]
+ value = "MesloLGS NF"
+ ```
+ - **Ghostty**: Open *Menu โ Open Configuration* (Linux) or *Ghostty โ Settings...* (Mac) and add
+ the following line:
+ ```text
+ font-family = "MesloLGS NF"
+ ```
+1. Run `p10k configure` to generate a new `~/.p10k.zsh`. The old config 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!_
@@ -545,11 +797,10 @@ 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 image is deleted.
+the theme. Once you exit Zsh, the container is deleted.
```zsh
-docker run -e TERM -e COLORTERM -it --rm alpine sh -uec '
- apk update
+docker run -e TERM -e COLORTERM -e LC_ALL=C.UTF-8 -it --rm alpine sh -uec '
apk add git zsh nano vim
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
echo "source ~/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc
@@ -569,26 +820,144 @@ 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/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` |
+| 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` |
**IMPORTANT**: Restart Zsh after updating Powerlevel10k. [Do not use `source ~/.zshrc`](
#weird-things-happen-after-typing-source-zshrc).
+### How do I uninstall Powerlevel10k?
+
+1. Remove all references to "p10k" from `~/.zshrc`. You might have this snippet at the top:
+ ```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
+ ```
+ And this at the bottom:
+ ```zsh
+ [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
+ ```
+ These are added by the [configuration wizard](#configuration-wizard). Remove them.
+2. Remove all references to "powerlevel10k" from `~/.zshrc`, `~/.zpreztorc` and `~/.zimrc` (some
+ of these files may be missing -- this is normal). These references have been added manually by
+ yourself when installing Powerlevel10k. Refer to the [installation instructions](#installation)
+ if you need a reminder.
+3. Verify that all references to "p10k" and "powerlevel10k" are gone from `~/.zshrc`, `~/.zpreztorc`
+ and `~/.zimrc`.
+ ```zsh
+ grep -E 'p10k|powerlevel10k' ~/.zshrc ~/.zpreztorc ~/.zimrc 2>/dev/null
+ ```
+ If this command produces output, there are still references to "p10k" or "powerlevel10k". You
+ need to remove them.
+4. Delete Powerlevel10k configuration file. This file is created by the
+ [configuration wizard](#configuration-wizard) and may contain manual edits by yourself.
+ ```zsh
+ rm -f ~/.p10k.zsh
+ ```
+5. Delete Powerlevel10k source files. These files have been downloaded when you've 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
+ ```
+
+### How do I install Powerlevel10k on a machine without Internet access?
+
+1. Run this command on the machine without Internet access:
+ ```sh
+ uname -sm | tr '[A-Z]' '[a-z]'
+ ```
+2. Run these commands on a machine connected to the Internet after replacing the value of
+ `target_uname` with the output of the previous command:
+ ```sh
+ target_uname="replace this with the output of the previous command"
+ git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
+ GITSTATUS_CACHE_DIR="$HOME"/powerlevel10k/gitstatus/usrbin ~/powerlevel10k/gitstatus/install -f -s "${target_uname% *}" -m "${target_uname#* }"
+ ```
+3. Copy `~/powerlevel10k` from the machine connected to the Internet to the one without Internet
+ access.
+4. Add `source ~/powerlevel10k/powerlevel10k.zsh-theme` to `~/.zshrc` on the machine without
+ Internet access:
+ ```zsh
+ echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
+ ```
+5. If `~/.zshrc` on the machine without Internet access sets `ZSH_THEME`, remove that line.
+ ```zsh
+ sed -i.bak '/^ZSH_THEME=/d' ~/.zshrc
+ ```
+
+To update, remove `~/powerlevel10k` on both machines and repeat steps 1-3.
+
### Where can I ask for help and report bugs?
The best way to ask for help and to report bugs is to [open an issue](
@@ -612,26 +981,31 @@ Powerlevel10k defines prompt and nothing else. It sets [prompt-related options](
https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/prompt-highlight.png)
Everything within the highlighted areas on the screenshot is produced by Powerlevel10k.
-Powerlevel10k has no control over the terminal content or color outside these areas.
+Powerlevel10k has no control over the terminal content or colors outside these areas.
Powerlevel10k does not affect:
-- Terminal window title.
+- Terminal window/tab title.
- Colors used by `ls`.
-- Content and style of command completions.
+- The behavior of `git` command.
+- The content and style of Tab completions.
- Command line colors (syntax highlighting, autosuggestions, etc.).
+- Key bindings.
+- Aliases.
- 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?
1. Run this command:
```zsh
# Add powerlevel10k to the list of Oh My Zsh themes.
-git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
+git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"
# Replace ZSH_THEME="powerlevel9k/powerlevel9k" with ZSH_THEME="powerlevel10k/powerlevel10k".
-sed 's/powerlevel9k/powerlevel10k/g' -i ~/.zshrc
+sed -i.bak 's/powerlevel9k/powerlevel10k/g' ~/.zshrc
# Restart Zsh.
exec zsh
```
@@ -649,36 +1023,14 @@ exec zsh
### Is it really fast?
-Yes.
+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).
-[](
- 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?
+### How do I configure instant prompt?
See [instant prompt](#instant-prompt) to learn about instant prompt. This section explains how you
-can enable it and lists caveats that you should be aware of.
+can enable and configure 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`:
@@ -744,25 +1096,79 @@ 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 โฃ42โก42 โ 42โข42 *42 merge ~42 +42 !42 ?42
+feature:master wip โฃ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 @{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}` |
+| `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}` |
| `*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` |
@@ -788,7 +1194,7 @@ When using Lean, Classic or Rainbow style, `~/.p10k.zsh` contains the following
```zsh
# Don't show Git status in prompt for repositories whose workdir matches this pattern.
# For example, if set to '~', the Git repository at $HOME/.git will be ignored.
-# Multiple patterns can be combined with '|': '~|~/some/dir'.
+# Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'.
typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~'
```
@@ -803,11 +1209,25 @@ computation completes.
When your current directory is within a Git repository, Powerlevel10k computes up-to-date Git
status after every command. If the repository is large, or the machine is slow, this computation
-can take quite a bit of time. If it takes longer than 20 milliseconds (configurable via
+can take quite a bit of time. If it takes longer than 10 milliseconds (configurable via
`POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS`), Powerlevel10k displays the last known Git status in
grey and continues to compute up-to-date Git status in the background. When the computation
completes, Powerlevel10k refreshes prompt with new information, this time with colored Git status.
+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
+`~/.p10k.zsh`, search for `POWERLEVEL9K_VCS_LOADING_BACKGROUND`, uncomment it if it's commented out,
+and change the value.
+
+```zsh
+typeset -g POWERLEVEL9K_VCS_LOADING_BACKGROUND=244
+```
+
+Type `source ~/.p10k.zsh` to apply your changes to the current Zsh session.
+
+*Related*: [How do I change prompt colors?](#how-do-i-change-prompt-colors)
+
### How do I add username and/or hostname to prompt?
When using Lean, Classic or Rainbow style, prompt shows `username@hostname` when you are logged in
@@ -849,9 +1269,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 kubectl, helm, kubens, kubectx, oc, istioctl or kogito.
-typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito'
+# 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'
```
Configs created by `p10k configure` may contain parameters of this kind. To customize when different
@@ -867,7 +1287,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|kubectx|oc|istioctl|kogito'
+ POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens'
fi
p10k reload
if zle; then
@@ -920,12 +1340,29 @@ 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 colors look in your terminal, run the following command:
+To see how different numbered 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`
@@ -943,26 +1380,13 @@ prompt latency when using Powerlevel10k, please
### Is Powerlevel10k fast to load?
-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.
+Yes. See [zsh-bench](https://github.com/romkatv/zsh-bench).
### 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 large user base and release cycle measured in months. Powerlevel10k
+already a mature project with a large user base and a 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
@@ -1031,7 +1455,7 @@ Similarly, if you enable transient prompt, sparse prompt (with an empty line bef
great choice.
If you are using vi keymap, choose prompt with `prompt_char` in it (shown as green `โฏ` in the
-wizard). This symbol changes depending on vi mode: `โฏ`, `โฎ`, `โ
ค`, `โถ` for insert, command, visual
+wizard). This symbol changes depending on vi mode: `โฏ`, `โฎ`, `V`, `โถ` for insert, command, visual
and replace mode respectively. When a command fails, the symbol turns red. *Lean* style always has
`prompt_char` in it. *Rainbow* and *Classic* styles have it only in the two-line configuration
without left frame.
@@ -1066,17 +1490,9 @@ command is reflected in the *next* prompt.
For details, see [this post on /r/zsh](
https://www.reddit.com/r/zsh/comments/eg49ff/powerlevel10k_prompt_history_exit_code_colors/fc5huku).
-### Is there an AUR package for Powerlevel10k?
-
-There is [zsh-theme-powerlevel10k-git](
- https://aur.archlinux.org/packages/zsh-theme-powerlevel10k-git/). It's owned by an unaffiliated
-volunteer.
-
-There is also an [official Powerlevel10k package](#arch-linux) for Pacman.
-
### What is the minimum supported Zsh version?
-Zsh 5.1 or newer should work. Fast startup requires Zsh >= 5.4.
+Zsh 5.3 or newer should work. Fast startup requires Zsh >= 5.4.
### How were these screenshots and animated gifs created?
@@ -1099,7 +1515,6 @@ from Nerd Fonts. The final font is released under the terms of
[Apache License](
https://raw.githubusercontent.com/romkatv/powerlevel10k-media/master/MesloLGS%20NF%20License.txt).
-
MesloLGS NF font can be recreated with the following command (requires `git` and `docker`):
```zsh
@@ -1112,49 +1527,57 @@ If everything goes well, four `ttf` files will appear in `./out`.
### How to package Powerlevel10k for distribution?
-If you want to package Powerlevel10k, it's best to do it based off releases. In a nutshell, you
-need to download Powerlevel10k tarball, build gitstatusd and compile zsh files.
-
-The following code should work. If it doesn't, please open an issue.
-
-**IMPORTANT:** *Change version to what you want to package. This example doesn't get updated when
-new versions are released.*
-
-```zsh
-curl -fsSLO https://github.com/romkatv/powerlevel10k/archive/v1.0.0.tar.gz
-tar -xzf v1.0.0.tar.gz
-cd powerlevel10k-1.0.0
-(
- cd gitstatus
- . ./build.info
- curl -fsSLo \
- deps/libgit2-"$libgit2_version".tar.gz \
- https://github.com/romkatv/libgit2/archive/"$libgit2_version".tar.gz
- ./build
- rm deps/libgit2-*.tar.gz
-)
-for file in *.zsh-theme internal/*.zsh gitstatus/*.zsh gitstatus/install; do
- zsh -fc "zcompile -R -- $file.zwc $file"
-done
-```
-
-This needs binutils, cmake, gcc, g++, git, GNU make and zsh.
-
-Depending on your workflow, it might be easier to store the URL to the libgit2 tarball in the
-same place where you are going to put the main powerlevel10k tarball URL. You'll need to update both
-URLs at the same time when bumping package version.
-
-Once build completes, *do not delete or move any files*. Package the whole directory as is. Don't
-add it (or any of its subdirectories) to `PATH`.
-
-Note that Powerlevel10k has an embedded version of gitstatus. It must stay that way. The embedded
-gitstatus won't conflict with the standalone version. They can have different versions and can
-coexist within the same Zsh process. Do not attempt to surgically remove gitstatus from
-Powerlevel10k, package the result and then somehow force Powerlevel10k to use a separately packaged
-gitstatus.
+It's currently neither easy nor recommended to package and distribute Powerlevel10k. There are no
+instructions you can follow that would allow you to easily update your package when new versions of
+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
@@ -1338,16 +1761,16 @@ 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`.
-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.
+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]}`.
-The minimum screen size at which configuration wizard can function is 55 columns by 21 lines.
-However, not all prompt styles are offered at such small screen size as there is simply not enough
-space to present them. *Fix*: Resize your terminal to at least 84 columns by 25 lines prior to
-running `p10k configure`. Verify with `print ${COLUMNS}x${LINES}`.
+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
+`p10k configure` and checking that all glyphs render correctly.
### Cannot install the recommended font
@@ -1370,11 +1793,11 @@ From [Zsh documentation](
http://zsh.sourceforge.net/Doc/Release/Parameters.html#index-ZLE_005fRPROMPT_005fINDENT):
> `ZLE_RPROMPT_INDENT `
->
+>
> If set, used to give the indentation between the right hand side of the right prompt in the line
> editor as given by `RPS1` or `RPROMPT` and the right hand side of the screen. If not set, the
> value `1` is used.
->
+>
> Typically this will be used to set the value to `0` so that the prompt appears flush with the
> right hand side of the screen.
@@ -1450,41 +1873,58 @@ theme (so that you end up with no theme) and then installing Powerlevel10k manua
```zsh
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
-echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>! ~/.zshrc
+echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
```
This method of installation won't make anything slower or otherwise sub-par.
### Directory is difficult to see in prompt when using Rainbow style
-In Classic style the current working directory is shown with bright white white text on blue
-background. The white is fixed and always looks the same but the appearance of "blue" is defined
-by your terminal color palette. If it's very light, it's difficult to see white text on it.
+In Rainbow style the current working directory is shown with bright white text on blue background.
+The white is fixed and always looks the same but the appearance of "blue" is defined by your
+terminal color palette. If it's very light, it may be difficult to see white text on it.
There are several ways to fix this.
- Type `p10k configure` and choose a more readable prompt style.
- [Change terminal color palette](#change-the-color-palette-used-by-your-terminal). Try Tango Dark
or Solarized Dark, or change just the "blue" color.
-- [Change directory background color](#set-colors-through-Powerlevel10k-configuration-parameters).
- The parameter you are looking for is called `POWERLEVEL9K_DIR_BACKGROUND`. You can find it in
- in `~/.p10k.zsh`. Uncomment it if it's commented out and try different values.
+- [Change directory background and/or foreground color](#set-colors-through-Powerlevel10k-configuration-parameters).
+ 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.
### Horrific mess when resizing terminal window
-When you resize terminal window horizontally back and forth a few times, you might see this ugly
+When you resize a terminal window horizontally back and forth a few times, you might see this ugly
picture.

-tl;dr: This is a bug in Zsh that isn't specific to Powerlevel10k. See [mitigation](#mitigation).
+tl;dr: This issue arises when a terminal reflows Zsh prompt upon resizing. It isn't specific to
+Powerlevel10k. See [mitigation](#mitigation).
-#### Zsh bug
+*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.*
-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.
+#### 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.
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*.
@@ -1506,9 +1946,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 bug in Zsh.
+strategy never changes the height of terminal content, so it doesn't trigger this issue.
-Let's see how the bug plays out in slow motion. We'll start by launching `zsh -df` and pasting
+Let's see how the issue plays out in slow motion. We'll start by launching `zsh -f` and pasting
the following code:
```zsh
@@ -1524,13 +1964,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:
-
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:
-
At this point the terminal sends `SIGWINCH` to Zsh to notify it about changes in the terminal
@@ -1542,7 +1982,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.
-
In this case we ended up with unwanted junk content because `VD` has *increased*. When you make
@@ -1551,28 +1991,30 @@ 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).
-
-
-
-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.
-
-
+- 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).
+ 
+- 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 patch
-The bug described above has been fixed 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 same position when prompt needs to be refreshed.
+[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.
-*Note*: The patch doesn't work on Alacritty. On the plus side, it doesn't make things worse.
+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
+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 fixing the bug that may seem to work at fight glance but in
+There are two alternative approaches to patching Zsh 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`
@@ -1591,20 +2033,25 @@ 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.
+ 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.
+ 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.
- Avoid long lines between the start of prompt and cursor.
1. Disable ruler with `POWERLEVEL9K_SHOW_RULER=false`.
- 1. Disable prompt connection with `POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' '`.
- 1. Disable right frame with `POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX=` and
- `POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX=` and
- `POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX=`.
- 1. Remove all elements from `POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS`. Right prompt on the last prompt
- line will cause resizing issues only when the cursor is below it. This isn't very common, so
- you might want to keep some elements in `POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS` provided that
- none of them are succeeded by `newline`.
+ 2. Disable prompt connection with `POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' '`.
+ 3. Disable right frame with `POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX=''`,
+ `POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX=''` and
+ `POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX=''`.
+ 4. Set `POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()`. Right prompt on the last prompt line will cause
+ resizing issues only when the cursor is below it. This isn't very common, so you might want to
+ keep some elements in `POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS` provided that none of them are
+ succeeded by `newline`.
### Icons cut off in Konsole
@@ -1654,87 +2101,15 @@ 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
```
-## Table of contents
+### Incorrect git status in prompt
-- [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)
- - [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)
- - [Is there an AUR package for Powerlevel10k?](#is-there-an-aur-package-for-powerlevel10k)
- - [What is the minimum supported Zsh version?](#what-is-the-minimum-supported-zsh-version)
- - [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)
+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`.
diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh
index 5f754231..623b9308 100644
--- a/config/p10k-classic.zsh
+++ b/config/p10k-classic.zsh
@@ -17,10 +17,10 @@
# Unset all configuration options. This allows you to apply configuration changes without
# restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`.
- unset -m 'POWERLEVEL9K_*|DEFAULT_USER'
+ unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR'
# Zsh >= 5.1 is required.
- autoload -Uz is-at-least && is-at-least 5.1 || return
+ [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return
# The list of segments shown on the left. Fill it with the most important segments.
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
@@ -65,22 +65,30 @@
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
@@ -90,6 +98,8 @@
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
@@ -136,7 +146,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 using this option.
+ # for more compact prompt if 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=
@@ -161,6 +171,9 @@
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.
@@ -190,7 +203,7 @@
# Prompt symbol in command vi mode.
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='โฎ'
# Prompt symbol in visual vi mode.
- typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='โ
ค'
+ typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V'
# Prompt symbol in overwrite vi mode.
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='โถ'
typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true
@@ -230,7 +243,8 @@
.java-version
.perl-version
.php-version
- .tool-version
+ .tool-versions
+ .mise.toml
.shorten_folder_marker
.svn
.terraform
@@ -247,6 +261,11 @@
# /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first)
# or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers
# and other directories don't.
+ #
+ # Optionally, "first" and "last" can be followed by ":" where is an integer.
+ # This moves the truncation point to the right (positive offset) or to the left (negative offset)
+ # relative to the marker. Plain "first" and "last" are equivalent to "first:0" and "last:0"
+ # respectively.
typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false
# Don't shorten this many last directory segments. They are anchors.
typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
@@ -268,12 +287,12 @@
# 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
- # The default icon shown next to non-writable directories when POWERLEVEL9K_DIR_SHOW_WRITABLE is
- # set to v2.
+ # The default icon shown next to non-writable and non-existent directories when
+ # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3.
# typeset -g POWERLEVEL9K_LOCK_ICON='โญ'
# POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different
@@ -286,8 +305,8 @@
#
# Triplets are tried in order. The first triplet whose pattern matches $PWD wins.
#
- # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v2 and the current directory is not writable,
- # its class gets suffix _NOT_WRITABLE.
+ # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories
+ # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively.
#
# For example, given these settings:
#
@@ -296,10 +315,11 @@
# '~(|/*)' HOME ''
# '*' DEFAULT '')
#
- # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with class
- # WORK or WORK_NOT_WRITABLE.
+ # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one
+ # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or
+ # WORK_NON_EXISTENT.
#
- # Simply assigning classes to directories don't have any visible effects. It merely gives you an
+ # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an
# option to define custom colors and icons for different directory classes.
#
# # Styling for WORK.
@@ -314,6 +334,12 @@
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=103
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=39
#
+ # # Styling for WORK_NON_EXISTENT.
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=31
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=103
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=39
+ #
# If a styling parameter isn't explicitly defined for some class, it falls back to the classless
# parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls
# back to POWERLEVEL9K_DIR_FOREGROUND.
@@ -324,7 +350,7 @@
# typeset -g POWERLEVEL9K_DIR_PREFIX='%248Fin '
#####################################[ vcs: git status ]######################################
- # Branch icon. Set this parameter to '\uF126 ' for the popular Powerline branch icon.
+ # Branch icon. Set this parameter to '\UE0A0 ' 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.
@@ -333,7 +359,7 @@
# Formatter for Git status.
#
- # Example output: master โฃ42โก42 *42 merge ~42 +42 !42 ?42.
+ # Example output: master wip โฃ42โก42 *42 merge ~42 +42 !42 ?42.
#
# You can edit the function to customize how Git status looks.
#
@@ -366,35 +392,55 @@
fi
local res
- local where # branch or tag
+
if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then
- res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}"
- where=${(V)VCS_STATUS_LOCAL_BRANCH}
- elif [[ -n $VCS_STATUS_TAG ]]; then
- res+="${meta}#"
- where=${(V)VCS_STATUS_TAG}
+ local branch=${(V)VCS_STATUS_LOCAL_BRANCH}
+ # If local branch name is at most 32 characters long, show it in full.
+ # Otherwise show the first 12 โฆ the last 12.
+ # Tip: To always show local branch name in full without truncation, delete the next line.
+ (( $#branch > 32 )) && branch[13,-13]="โฆ" # <-- this line
+ res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}"
fi
- # If local branch name or tag is at most 32 characters long, show it in full.
- # Otherwise show the first 12 โฆ the last 12.
- # Tip: To always show local branch name in full without truncation, delete the next line.
- (( $#where > 32 )) && where[13,-13]="โฆ"
- res+="${clean}${where//\%/%%}" # escape %
+ if [[ -n $VCS_STATUS_TAG
+ # Show tag only if not on a branch.
+ # Tip: To always show tag, delete the next line.
+ && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line
+ ]]; then
+ local tag=${(V)VCS_STATUS_TAG}
+ # If tag name is at most 32 characters long, show it in full.
+ # Otherwise show the first 12 โฆ the last 12.
+ # Tip: To always show tag name in full without truncation, delete the next line.
+ (( $#tag > 32 )) && tag[13,-13]="โฆ" # <-- this line
+ res+="${meta}#${clean}${tag//\%/%%}"
+ fi
- # Display the current Git commit if there is no branch or tag.
- # Tip: To always display the current Git commit, remove `[[ -z $where ]] &&` from the next line.
- [[ -z $where ]] && res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}"
+ # 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
+ res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}"
# Show tracking branch name if it differs from local branch.
if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then
- res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape %
+ 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+=" "
@@ -436,7 +482,7 @@
# Don't show Git status in prompt for repositories whose workdir matches this pattern.
# For example, if set to '~', the Git repository at $HOME/.git will be ignored.
- # Multiple patterns can be combined with '|': '~|~/some/dir'.
+ # Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'.
typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~'
# Disable the default Git status formatting.
@@ -460,7 +506,7 @@
# isn't in an svn or hg reposotiry.
typeset -g POWERLEVEL9K_VCS_BACKENDS=(git)
- # These settings are used for respositories other than Git or when gitstatusd fails and
+ # These settings are used for repositories other than Git or when gitstatusd fails and
# Powerlevel10k has to fall back to using vcs_info.
typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76
typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=76
@@ -503,7 +549,7 @@
typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='โ'
###################[ command_execution_time: duration of the last command ]###################
- # Show duration of the last command if takes longer than this many seconds.
+ # Show duration of the last command if takes at least this many seconds.
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3
# Show this many fractional digits. Zero means round to seconds.
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
@@ -532,6 +578,7 @@
###############[ asdf: asdf version manager (https://github.com/asdf-vm/asdf) ]###############
# Default asdf color. Only used to display tools for which there is no color override (see below).
+ # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_FOREGROUND.
typeset -g POWERLEVEL9K_ASDF_FOREGROUND=66
# There are four parameters that can be used to hide asdf tools. Each parameter describes
@@ -577,7 +624,7 @@
typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true
# If set to non-empty value, hide tools unless there is a file matching the specified file pattern
- # in the current directory, or its parent diretory, or its grandparent directory, and so on.
+ # in the current directory, or its parent directory, or its grandparent directory, and so on.
#
# Note: If this parameter is set to empty value, it won't hide tools.
# Note: SHOW_ON_UPGLOB isn't specific to asdf. It works with all prompt segments.
@@ -664,6 +711,11 @@
# typeset -g POWERLEVEL9K_ASDF_HASKELL_VISUAL_IDENTIFIER_EXPANSION='โญ'
# typeset -g POWERLEVEL9K_ASDF_HASKELL_SHOW_ON_UPGLOB='*.foo|*.bar'
+ # Julia version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_JULIA_FOREGROUND=70
+ # typeset -g POWERLEVEL9K_ASDF_JULIA_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ # typeset -g POWERLEVEL9K_ASDF_JULIA_SHOW_ON_UPGLOB='*.foo|*.bar'
+
##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]###########
# NordVPN connection indicator color.
typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=39
@@ -678,6 +730,12 @@
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.
@@ -685,6 +743,18 @@
# 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
@@ -701,12 +771,21 @@
# 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
@@ -733,9 +812,8 @@
# 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_RANGER_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ # typeset -g POWERLEVEL9K_VI_MODE_VISUAL_IDENTIFIER_EXPANSION='โญ'
######################################[ ram: free RAM ]#######################################
# RAM color.
@@ -800,7 +878,7 @@
##############[ taskwarrior: taskwarrior task count (https://taskwarrior.org/) ]##############
# Taskwarrior color.
typeset -g POWERLEVEL9K_TASKWARRIOR_FOREGROUND=74
-
+
# Taskwarrior segment format. The following parameters are available within the expansion.
#
# - P9K_TASKWARRIOR_PENDING_COUNT The number of pending tasks: `task +PENDING count`.
@@ -817,6 +895,30 @@
# 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
@@ -846,6 +948,9 @@
typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=37
# Don't show Python version next to the virtual environment name.
typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false
+ # If set to "false", won't show virtualenv if pyenv is already shown.
+ # If set to "if-different", won't show virtualenv if it's the same as pyenv.
+ typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false
# Separate environment name from Python version only with a space.
typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER=
# Custom icon.
@@ -854,10 +959,33 @@
#####################[ anaconda: conda environment (https://conda.io/) ]######################
# Anaconda environment color.
typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=37
- # Don't show Python version next to the anaconda environment name.
- typeset -g POWERLEVEL9K_ANACONDA_SHOW_PYTHON_VERSION=false
- # Separate environment name from Python version only with a space.
- typeset -g POWERLEVEL9K_ANACONDA_{LEFT,RIGHT}_DELIMITER=
+
+ # Anaconda segment format. The following parameters are available within the expansion.
+ #
+ # - CONDA_PREFIX Absolute path to the active Anaconda/Miniconda environment.
+ # - CONDA_DEFAULT_ENV Name of the active Anaconda/Miniconda environment.
+ # - CONDA_PROMPT_MODIFIER Configurable prompt modifier (see below).
+ # - P9K_ANACONDA_PYTHON_VERSION Current python version (python --version).
+ #
+ # CONDA_PROMPT_MODIFIER can be configured with the following command:
+ #
+ # conda config --set env_prompt '({default_env}) '
+ #
+ # The last argument is a Python format string that can use the following variables:
+ #
+ # - prefix The same as CONDA_PREFIX.
+ # - default_env The same as CONDA_DEFAULT_ENV.
+ # - name The last segment of CONDA_PREFIX.
+ # - stacked_env Comma-separated list of names in the environment stack. The first element is
+ # always the same as default_env.
+ #
+ # Note: '({default_env}) ' is the default value of env_prompt.
+ #
+ # The default value of POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION expands to $CONDA_PROMPT_MODIFIER
+ # without the surrounding parentheses, or to the last path component of CONDA_PREFIX if the former
+ # is empty.
+ typeset -g POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION='${${${${CONDA_PROMPT_MODIFIER#\(}% }%\)}:-${CONDA_PREFIX:t}}'
+
# Custom icon.
# typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION='โญ'
@@ -871,6 +999,19 @@
typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false
# If set to false, hide python version if it's equal to "system".
typeset -g POWERLEVEL9K_PYENV_SHOW_SYSTEM=true
+
+ # Pyenv segment format. The following parameters are available within the expansion.
+ #
+ # - P9K_CONTENT Current pyenv environment (pyenv version-name).
+ # - P9K_PYENV_PYTHON_VERSION Current python version (python --version).
+ #
+ # 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}'
+
# Custom icon.
# typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='โญ'
@@ -903,6 +1044,11 @@
##############[ 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='โญ'
@@ -1052,6 +1198,16 @@
# 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
@@ -1065,6 +1221,19 @@
# Custom icon.
# typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ #######[ scalaenv: scala version from scalaenv (https://github.com/scalaenv/scalaenv) ]#######
+ # Scala color.
+ typeset -g POWERLEVEL9K_SCALAENV_FOREGROUND=160
+ # Hide scala version if it doesn't come from one of these sources.
+ typeset -g POWERLEVEL9K_SCALAENV_SOURCES=(shell local global)
+ # If set to false, hide scala version if it's the same as global:
+ # $(scalaenv version-name) == $(scalaenv global).
+ typeset -g POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW=false
+ # If set to false, hide scala version if it's equal to "system".
+ typeset -g POWERLEVEL9K_SCALAENV_SHOW_SYSTEM=true
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_SCALAENV_VISUAL_IDENTIFIER_EXPANSION='โญ'
+
##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]###########
# Haskell color.
typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=172
@@ -1080,6 +1249,8 @@
# typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='โญ'
################[ terraform: terraform workspace (https://www.terraform.io) ]#################
+ # Don't show terraform workspace if it's literally "default".
+ typeset -g POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT=false
# POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element
# in each pair defines a pattern against which the current terraform workspace gets matched.
# More specifically, it's P9K_CONTENT prior to the application of context expansion (see below)
@@ -1093,7 +1264,7 @@
# typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=(
# '*prod*' PROD
# '*test*' TEST
- # '*' DEFAULT)
+ # '*' OTHER)
#
# If your current terraform workspace is "project_test", its class is TEST because "project_test"
# doesn't match the pattern '*prod*' but does match '*test*'.
@@ -1106,14 +1277,20 @@
typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=(
# '*prod*' PROD # These values are examples that are unlikely
# '*test*' TEST # to match your needs. Customize them as needed.
- '*' DEFAULT)
- typeset -g POWERLEVEL9K_TERRAFORM_DEFAULT_FOREGROUND=38
- # typeset -g POWERLEVEL9K_TERRAFORM_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ '*' OTHER)
+ 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 the command you are typing invokes one of these tools.
+ # Show kubecontext only when 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'
+ 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'
# Kubernetes context classes for the purpose of using different colors, icons and expansions with
# different contexts.
@@ -1198,9 +1375,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 the command you are typing invokes one of these tools.
+ # Show aws only when 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|terraform|pulumi'
+ typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|cdk|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.
@@ -1232,6 +1409,12 @@
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
@@ -1239,18 +1422,47 @@
# 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 the command you are typing invokes one of these tools.
+ # Show azure only when 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'
+ 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_FOREGROUND=32
+ typeset -g POWERLEVEL9K_AZURE_OTHER_FOREGROUND=32
# Custom icon.
- # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ # typeset -g POWERLEVEL9K_AZURE_OTHER_VISUAL_IDENTIFIER_EXPANSION='โญ'
##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]###########
- # Show gcloud only when the the command you are typing invokes one of these tools.
+ # Show gcloud only when 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'
+ typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil'
# Google cloud color.
typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=32
@@ -1266,7 +1478,7 @@
# P9K_GCLOUD_PROJECT_ID | gcloud config get-value project
# P9K_GCLOUD_PROJECT_NAME | gcloud projects describe $P9K_GCLOUD_PROJECT_ID --format='value(name)'
#
- # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurences of '%' replaced with '%%'.
+ # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced with '%%'.
#
# Obtaining project name requires sending a request to Google servers. This can take a long time
# and even fail. When project name is unknown, P9K_GCLOUD_PROJECT_NAME is not set and gcloud
@@ -1289,9 +1501,9 @@
# 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 the command you are typing invokes one of these tools.
+ # Show google_app_cred only when 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'
+ typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt'
# Google application credentials classes for the purpose of using different colors, icons and
# expansions with different credentials.
@@ -1339,9 +1551,19 @@
# P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id
# P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email
#
- # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurences of '%' replaced by '%%'.
+ # 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
@@ -1356,7 +1578,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='(wg|(.*tun))[0-9]*'
+ typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*|(zt.*)'
# 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.
@@ -1370,17 +1592,19 @@
# 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_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_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)
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.
- typeset -g POWERLEVEL9K_IP_INTERFACE='e.*'
+ typeset -g POWERLEVEL9K_IP_INTERFACE='[ew].*'
# Custom icon.
# typeset -g POWERLEVEL9K_IP_VISUAL_IDENTIFIER_EXPANSION='โญ'
@@ -1423,15 +1647,11 @@
# Parameter | Meaning
# ----------------------+---------------
# P9K_WIFI_SSID | service set identifier, a.k.a. network name
- # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"
+ # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"; empty if unknown
# P9K_WIFI_LAST_TX_RATE | wireless transmit rate in megabits per second
# P9K_WIFI_RSSI | signal strength in dBm, from -120 to 0
# P9K_WIFI_NOISE | noise in dBm, from -120 to 0
# P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE)
- #
- # All parameters except P9K_WIFI_BARS are extracted from the output of the following command:
- #
- # /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I
####################################[ time: current time ]####################################
# Current time color.
@@ -1458,7 +1678,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/blob/master/README.md#instant-prompt.
+ # https://github.com/romkatv/powerlevel10k#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
@@ -1494,7 +1714,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/blob/master/README.md#instant-prompt.
+ # https://github.com/romkatv/powerlevel10k#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 dc1530a0..3f72ff4b 100644
--- a/config/p10k-lean-8colors.zsh
+++ b/config/p10k-lean-8colors.zsh
@@ -17,10 +17,10 @@
# Unset all configuration options. This allows you to apply configuration changes without
# restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`.
- unset -m 'POWERLEVEL9K_*|DEFAULT_USER'
+ unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR'
# Zsh >= 5.1 is required.
- autoload -Uz is-at-least && is-at-least 5.1 || return
+ [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return
# The list of segments shown on the left. Fill it with the most important segments.
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
@@ -65,22 +65,30 @@
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
@@ -89,6 +97,8 @@
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
@@ -186,7 +196,7 @@
# Prompt symbol in command vi mode.
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='โฎ'
# Prompt symbol in visual vi mode.
- typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='โ
ค'
+ typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V'
# Prompt symbol in overwrite vi mode.
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='โถ'
typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true
@@ -224,7 +234,8 @@
.java-version
.perl-version
.php-version
- .tool-version
+ .tool-versions
+ .mise.toml
.shorten_folder_marker
.svn
.terraform
@@ -241,6 +252,11 @@
# /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first)
# or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers
# and other directories don't.
+ #
+ # Optionally, "first" and "last" can be followed by ":" where is an integer.
+ # This moves the truncation point to the right (positive offset) or to the left (negative offset)
+ # relative to the marker. Plain "first" and "last" are equivalent to "first:0" and "last:0"
+ # respectively.
typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false
# Don't shorten this many last directory segments. They are anchors.
typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
@@ -262,12 +278,12 @@
# 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
- # The default icon shown next to non-writable directories when POWERLEVEL9K_DIR_SHOW_WRITABLE is
- # set to v2.
+ # The default icon shown next to non-writable and non-existent directories when
+ # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3.
# typeset -g POWERLEVEL9K_LOCK_ICON='โญ'
# POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different
@@ -280,8 +296,8 @@
#
# Triplets are tried in order. The first triplet whose pattern matches $PWD wins.
#
- # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v2 and the current directory is not writable,
- # its class gets suffix _NOT_WRITABLE.
+ # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories
+ # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively.
#
# For example, given these settings:
#
@@ -290,10 +306,11 @@
# '~(|/*)' HOME ''
# '*' DEFAULT '')
#
- # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with class
- # WORK or WORK_NOT_WRITABLE.
+ # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one
+ # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or
+ # WORK_NON_EXISTENT.
#
- # Simply assigning classes to directories don't have any visible effects. It merely gives you an
+ # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an
# option to define custom colors and icons for different directory classes.
#
# # Styling for WORK.
@@ -306,7 +323,13 @@
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='โญ'
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND=4
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=4
- # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=4
+ # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=4#
+ #
+ # Styling for WORK_NON_EXISTENT.
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=4
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=4
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=4
#
# If a styling parameter isn't explicitly defined for some class, it falls back to the classless
# parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls
@@ -318,7 +341,7 @@
# typeset -g POWERLEVEL9K_DIR_PREFIX='%fin '
#####################################[ vcs: git status ]######################################
- # Branch icon. Set this parameter to '\uF126 ' for the popular Powerline branch icon.
+ # Branch icon. Set this parameter to '\UE0A0 ' 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.
@@ -327,7 +350,7 @@
# Formatter for Git status.
#
- # Example output: master โฃ42โก42 *42 merge ~42 +42 !42 ?42.
+ # Example output: master wip โฃ42โก42 *42 merge ~42 +42 !42 ?42.
#
# You can edit the function to customize how Git status looks.
#
@@ -360,35 +383,55 @@
fi
local res
- local where # branch or tag
+
if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then
- res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}"
- where=${(V)VCS_STATUS_LOCAL_BRANCH}
- elif [[ -n $VCS_STATUS_TAG ]]; then
- res+="${meta}#"
- where=${(V)VCS_STATUS_TAG}
+ local branch=${(V)VCS_STATUS_LOCAL_BRANCH}
+ # If local branch name is at most 32 characters long, show it in full.
+ # Otherwise show the first 12 โฆ the last 12.
+ # Tip: To always show local branch name in full without truncation, delete the next line.
+ (( $#branch > 32 )) && branch[13,-13]="โฆ" # <-- this line
+ res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}"
fi
- # If local branch name or tag is at most 32 characters long, show it in full.
- # Otherwise show the first 12 โฆ the last 12.
- # Tip: To always show local branch name in full without truncation, delete the next line.
- (( $#where > 32 )) && where[13,-13]="โฆ"
- res+="${clean}${where//\%/%%}" # escape %
+ if [[ -n $VCS_STATUS_TAG
+ # Show tag only if not on a branch.
+ # Tip: To always show tag, delete the next line.
+ && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line
+ ]]; then
+ local tag=${(V)VCS_STATUS_TAG}
+ # If tag name is at most 32 characters long, show it in full.
+ # Otherwise show the first 12 โฆ the last 12.
+ # Tip: To always show tag name in full without truncation, delete the next line.
+ (( $#tag > 32 )) && tag[13,-13]="โฆ" # <-- this line
+ res+="${meta}#${clean}${tag//\%/%%}"
+ fi
- # Display the current Git commit if there is no branch or tag.
- # Tip: To always display the current Git commit, remove `[[ -z $where ]] &&` from the next line.
- [[ -z $where ]] && res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}"
+ # 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
+ res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}"
# Show tracking branch name if it differs from local branch.
if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then
- res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape %
+ 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+=" "
@@ -430,7 +473,7 @@
# Don't show Git status in prompt for repositories whose workdir matches this pattern.
# For example, if set to '~', the Git repository at $HOME/.git will be ignored.
- # Multiple patterns can be combined with '|': '~|~/some/dir'.
+ # Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'.
typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~'
# Disable the default Git status formatting.
@@ -451,10 +494,10 @@
# Show status of repositories of these types. You can add svn and/or hg if you are
# using them. If you do, your prompt may become slow even when your current directory
- # isn't in an svn or hg reposotiry.
+ # isn't in an svn or hg repository.
typeset -g POWERLEVEL9K_VCS_BACKENDS=(git)
- # These settings are used for respositories other than Git or when gitstatusd fails and
+ # These settings are used for repositories other than Git or when gitstatusd fails and
# Powerlevel10k has to fall back to using vcs_info.
typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=2
typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=2
@@ -497,7 +540,7 @@
typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='โ'
###################[ command_execution_time: duration of the last command ]###################
- # Show duration of the last command if takes longer than this many seconds.
+ # Show duration of the last command if takes at least this many seconds.
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3
# Show this many fractional digits. Zero means round to seconds.
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
@@ -526,6 +569,7 @@
###############[ asdf: asdf version manager (https://github.com/asdf-vm/asdf) ]###############
# Default asdf color. Only used to display tools for which there is no color override (see below).
+ # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_FOREGROUND.
typeset -g POWERLEVEL9K_ASDF_FOREGROUND=6
# There are four parameters that can be used to hide asdf tools. Each parameter describes
@@ -571,7 +615,7 @@
typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true
# If set to non-empty value, hide tools unless there is a file matching the specified file pattern
- # in the current directory, or its parent diretory, or its grandparent directory, and so on.
+ # in the current directory, or its parent directory, or its grandparent directory, and so on.
#
# Note: If this parameter is set to empty value, it won't hide tools.
# Note: SHOW_ON_UPGLOB isn't specific to asdf. It works with all prompt segments.
@@ -658,6 +702,11 @@
# typeset -g POWERLEVEL9K_ASDF_HASKELL_VISUAL_IDENTIFIER_EXPANSION='โญ'
# typeset -g POWERLEVEL9K_ASDF_HASKELL_SHOW_ON_UPGLOB='*.foo|*.bar'
+ # Julia version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_JULIA_FOREGROUND=2
+ # typeset -g POWERLEVEL9K_ASDF_JULIA_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ # typeset -g POWERLEVEL9K_ASDF_JULIA_SHOW_ON_UPGLOB='*.foo|*.bar'
+
##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]###########
# NordVPN connection indicator color.
typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=6
@@ -672,6 +721,12 @@
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.
@@ -679,6 +734,18 @@
# 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
@@ -695,12 +762,21 @@
# 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
@@ -777,7 +853,7 @@
##############[ taskwarrior: taskwarrior task count (https://taskwarrior.org/) ]##############
# Taskwarrior color.
typeset -g POWERLEVEL9K_TASKWARRIOR_FOREGROUND=6
-
+
# Taskwarrior segment format. The following parameters are available within the expansion.
#
# - P9K_TASKWARRIOR_PENDING_COUNT The number of pending tasks: `task +PENDING count`.
@@ -794,6 +870,30 @@
# 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
@@ -823,6 +923,9 @@
typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=6
# Don't show Python version next to the virtual environment name.
typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false
+ # If set to "false", won't show virtualenv if pyenv is already shown.
+ # If set to "if-different", won't show virtualenv if it's the same as pyenv.
+ typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false
# Separate environment name from Python version only with a space.
typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER=
# Custom icon.
@@ -831,10 +934,33 @@
#####################[ anaconda: conda environment (https://conda.io/) ]######################
# Anaconda environment color.
typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=6
- # Don't show Python version next to the anaconda environment name.
- typeset -g POWERLEVEL9K_ANACONDA_SHOW_PYTHON_VERSION=false
- # Separate environment name from Python version only with a space.
- typeset -g POWERLEVEL9K_ANACONDA_{LEFT,RIGHT}_DELIMITER=
+
+ # Anaconda segment format. The following parameters are available within the expansion.
+ #
+ # - CONDA_PREFIX Absolute path to the active Anaconda/Miniconda environment.
+ # - CONDA_DEFAULT_ENV Name of the active Anaconda/Miniconda environment.
+ # - CONDA_PROMPT_MODIFIER Configurable prompt modifier (see below).
+ # - P9K_ANACONDA_PYTHON_VERSION Current python version (python --version).
+ #
+ # CONDA_PROMPT_MODIFIER can be configured with the following command:
+ #
+ # conda config --set env_prompt '({default_env}) '
+ #
+ # The last argument is a Python format string that can use the following variables:
+ #
+ # - prefix The same as CONDA_PREFIX.
+ # - default_env The same as CONDA_DEFAULT_ENV.
+ # - name The last segment of CONDA_PREFIX.
+ # - stacked_env Comma-separated list of names in the environment stack. The first element is
+ # always the same as default_env.
+ #
+ # Note: '({default_env}) ' is the default value of env_prompt.
+ #
+ # The default value of POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION expands to $CONDA_PROMPT_MODIFIER
+ # without the surrounding parentheses, or to the last path component of CONDA_PREFIX if the former
+ # is empty.
+ typeset -g POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION='${${${${CONDA_PROMPT_MODIFIER#\(}% }%\)}:-${CONDA_PREFIX:t}}'
+
# Custom icon.
# typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION='โญ'
@@ -848,6 +974,19 @@
typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false
# If set to false, hide python version if it's equal to "system".
typeset -g POWERLEVEL9K_PYENV_SHOW_SYSTEM=true
+
+ # Pyenv segment format. The following parameters are available within the expansion.
+ #
+ # - P9K_CONTENT Current pyenv environment (pyenv version-name).
+ # - P9K_PYENV_PYTHON_VERSION Current python version (python --version).
+ #
+ # 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}'
+
# Custom icon.
# typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='โญ'
@@ -880,6 +1019,11 @@
##############[ 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='โญ'
@@ -1029,6 +1173,16 @@
# 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
@@ -1042,6 +1196,19 @@
# Custom icon.
# typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ #######[ scalaenv: scala version from scalaenv (https://github.com/scalaenv/scalaenv) ]#######
+ # Scala color.
+ typeset -g POWERLEVEL9K_SCALAENV_FOREGROUND=1
+ # Hide scala version if it doesn't come from one of these sources.
+ typeset -g POWERLEVEL9K_SCALAENV_SOURCES=(shell local global)
+ # If set to false, hide scala version if it's the same as global:
+ # $(scalaenv version-name) == $(scalaenv global).
+ typeset -g POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW=false
+ # If set to false, hide scala version if it's equal to "system".
+ typeset -g POWERLEVEL9K_SCALAENV_SHOW_SYSTEM=true
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_SCALAENV_VISUAL_IDENTIFIER_EXPANSION='โญ'
+
##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]###########
# Haskell color.
typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=3
@@ -1057,9 +1224,9 @@
# typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='โญ'
#############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]#############
- # Show kubecontext only when the the command you are typing invokes one of these tools.
+ # Show kubecontext only when 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'
+ 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'
# Kubernetes context classes for the purpose of using different colors, icons and expansions with
# different contexts.
@@ -1144,6 +1311,8 @@
# typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%fat '
################[ terraform: terraform workspace (https://www.terraform.io) ]#################
+ # Don't show terraform workspace if it's literally "default".
+ typeset -g POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT=false
# POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element
# in each pair defines a pattern against which the current terraform workspace gets matched.
# More specifically, it's P9K_CONTENT prior to the application of context expansion (see below)
@@ -1157,7 +1326,7 @@
# typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=(
# '*prod*' PROD
# '*test*' TEST
- # '*' DEFAULT)
+ # '*' OTHER)
#
# If your current terraform workspace is "project_test", its class is TEST because "project_test"
# doesn't match the pattern '*prod*' but does match '*test*'.
@@ -1170,14 +1339,20 @@
typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=(
# '*prod*' PROD # These values are examples that are unlikely
# '*test*' TEST # to match your needs. Customize them as needed.
- '*' DEFAULT)
- typeset -g POWERLEVEL9K_TERRAFORM_DEFAULT_FOREGROUND=4
- # typeset -g POWERLEVEL9K_TERRAFORM_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ '*' OTHER)
+ 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 the command you are typing invokes one of these tools.
+ # Show aws only when 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|terraform|pulumi'
+ typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|cdk|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.
@@ -1209,6 +1384,12 @@
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
@@ -1216,18 +1397,47 @@
# 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 the command you are typing invokes one of these tools.
+ # Show azure only when 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'
+ 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_FOREGROUND=4
+ typeset -g POWERLEVEL9K_AZURE_OTHER_FOREGROUND=4
# Custom icon.
- # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ # typeset -g POWERLEVEL9K_AZURE_OTHER_VISUAL_IDENTIFIER_EXPANSION='โญ'
##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]###########
- # Show gcloud only when the the command you are typing invokes one of these tools.
+ # Show gcloud only when 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'
+ typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil'
# Google cloud color.
typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=4
@@ -1243,7 +1453,7 @@
# P9K_GCLOUD_PROJECT_ID | gcloud config get-value project
# P9K_GCLOUD_PROJECT_NAME | gcloud projects describe $P9K_GCLOUD_PROJECT_ID --format='value(name)'
#
- # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurences of '%' replaced with '%%'.
+ # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced with '%%'.
#
# Obtaining project name requires sending a request to Google servers. This can take a long time
# and even fail. When project name is unknown, P9K_GCLOUD_PROJECT_NAME is not set and gcloud
@@ -1266,9 +1476,9 @@
# 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 the command you are typing invokes one of these tools.
+ # Show google_app_cred only when 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'
+ typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt'
# Google application credentials classes for the purpose of using different colors, icons and
# expansions with different credentials.
@@ -1316,9 +1526,19 @@
# P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id
# P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email
#
- # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurences of '%' replaced by '%%'.
+ # 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
@@ -1333,7 +1553,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='(wg|(.*tun))[0-9]*'
+ typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*|(zt.*)'
# 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.
@@ -1347,17 +1567,19 @@
# 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_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_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)
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.
- typeset -g POWERLEVEL9K_IP_INTERFACE='e.*'
+ typeset -g POWERLEVEL9K_IP_INTERFACE='[ew].*'
# Custom icon.
# typeset -g POWERLEVEL9K_IP_VISUAL_IDENTIFIER_EXPANSION='โญ'
@@ -1400,15 +1622,11 @@
# Parameter | Meaning
# ----------------------+---------------
# P9K_WIFI_SSID | service set identifier, a.k.a. network name
- # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"
+ # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"; empty if unknown
# P9K_WIFI_LAST_TX_RATE | wireless transmit rate in megabits per second
# P9K_WIFI_RSSI | signal strength in dBm, from -120 to 0
# P9K_WIFI_NOISE | noise in dBm, from -120 to 0
# P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE)
- #
- # All parameters except P9K_WIFI_BARS are extracted from the output of the following command:
- #
- # /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I
####################################[ time: current time ]####################################
# Current time color.
@@ -1435,7 +1653,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/blob/master/README.md#instant-prompt.
+ # https://github.com/romkatv/powerlevel10k#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
@@ -1471,7 +1689,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/blob/master/README.md#instant-prompt.
+ # https://github.com/romkatv/powerlevel10k#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 6dcf87c9..cef70fd8 100644
--- a/config/p10k-lean.zsh
+++ b/config/p10k-lean.zsh
@@ -17,10 +17,10 @@
# Unset all configuration options. This allows you to apply configuration changes without
# restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`.
- unset -m 'POWERLEVEL9K_*|DEFAULT_USER'
+ unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR'
# Zsh >= 5.1 is required.
- autoload -Uz is-at-least && is-at-least 5.1 || return
+ [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return
# The list of segments shown on the left. Fill it with the most important segments.
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
@@ -65,22 +65,30 @@
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
@@ -89,6 +97,8 @@
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
@@ -173,8 +183,8 @@
#################################[ os_icon: os identifier ]##################################
# OS identifier color.
typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND=
- # Make the icon bold.
- typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='${P9K_CONTENT}'
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='โญ'
################################[ prompt_char: prompt symbol ]################################
# Green prompt symbol if the last command succeeded.
@@ -186,7 +196,7 @@
# Prompt symbol in command vi mode.
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='โฎ'
# Prompt symbol in visual vi mode.
- typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='โ
ค'
+ typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V'
# Prompt symbol in overwrite vi mode.
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='โถ'
typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true
@@ -224,7 +234,8 @@
.java-version
.perl-version
.php-version
- .tool-version
+ .tool-versions
+ .mise.toml
.shorten_folder_marker
.svn
.terraform
@@ -241,6 +252,11 @@
# /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first)
# or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers
# and other directories don't.
+ #
+ # Optionally, "first" and "last" can be followed by ":" where is an integer.
+ # This moves the truncation point to the right (positive offset) or to the left (negative offset)
+ # relative to the marker. Plain "first" and "last" are equivalent to "first:0" and "last:0"
+ # respectively.
typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false
# Don't shorten this many last directory segments. They are anchors.
typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
@@ -262,12 +278,12 @@
# 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
- # The default icon shown next to non-writable directories when POWERLEVEL9K_DIR_SHOW_WRITABLE is
- # set to v2.
+ # The default icon shown next to non-writable and non-existent directories when
+ # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3.
# typeset -g POWERLEVEL9K_LOCK_ICON='โญ'
# POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different
@@ -280,8 +296,8 @@
#
# Triplets are tried in order. The first triplet whose pattern matches $PWD wins.
#
- # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v2 and the current directory is not writable,
- # its class gets suffix _NOT_WRITABLE.
+ # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories
+ # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively.
#
# For example, given these settings:
#
@@ -290,10 +306,11 @@
# '~(|/*)' HOME ''
# '*' DEFAULT '')
#
- # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with class
- # WORK or WORK_NOT_WRITABLE.
+ # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one
+ # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or
+ # WORK_NON_EXISTENT.
#
- # Simply assigning classes to directories don't have any visible effects. It merely gives you an
+ # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an
# option to define custom colors and icons for different directory classes.
#
# # Styling for WORK.
@@ -308,6 +325,12 @@
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=103
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=39
#
+ # # Styling for WORK_NON_EXISTENT.
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=31
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=103
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=39
+ #
# If a styling parameter isn't explicitly defined for some class, it falls back to the classless
# parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls
# back to POWERLEVEL9K_DIR_FOREGROUND.
@@ -318,7 +341,7 @@
# typeset -g POWERLEVEL9K_DIR_PREFIX='%fin '
#####################################[ vcs: git status ]######################################
- # Branch icon. Set this parameter to '\uF126 ' for the popular Powerline branch icon.
+ # Branch icon. Set this parameter to '\UE0A0 ' 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.
@@ -327,7 +350,7 @@
# Formatter for Git status.
#
- # Example output: master โฃ42โก42 *42 merge ~42 +42 !42 ?42.
+ # Example output: master wip โฃ42โก42 *42 merge ~42 +42 !42 ?42.
#
# You can edit the function to customize how Git status looks.
#
@@ -360,35 +383,55 @@
fi
local res
- local where # branch or tag
+
if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then
- res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}"
- where=${(V)VCS_STATUS_LOCAL_BRANCH}
- elif [[ -n $VCS_STATUS_TAG ]]; then
- res+="${meta}#"
- where=${(V)VCS_STATUS_TAG}
+ local branch=${(V)VCS_STATUS_LOCAL_BRANCH}
+ # If local branch name is at most 32 characters long, show it in full.
+ # Otherwise show the first 12 โฆ the last 12.
+ # Tip: To always show local branch name in full without truncation, delete the next line.
+ (( $#branch > 32 )) && branch[13,-13]="โฆ" # <-- this line
+ res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}"
fi
- # If local branch name or tag is at most 32 characters long, show it in full.
- # Otherwise show the first 12 โฆ the last 12.
- # Tip: To always show local branch name in full without truncation, delete the next line.
- (( $#where > 32 )) && where[13,-13]="โฆ"
- res+="${clean}${where//\%/%%}" # escape %
+ if [[ -n $VCS_STATUS_TAG
+ # Show tag only if not on a branch.
+ # Tip: To always show tag, delete the next line.
+ && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line
+ ]]; then
+ local tag=${(V)VCS_STATUS_TAG}
+ # If tag name is at most 32 characters long, show it in full.
+ # Otherwise show the first 12 โฆ the last 12.
+ # Tip: To always show tag name in full without truncation, delete the next line.
+ (( $#tag > 32 )) && tag[13,-13]="โฆ" # <-- this line
+ res+="${meta}#${clean}${tag//\%/%%}"
+ fi
- # Display the current Git commit if there is no branch or tag.
- # Tip: To always display the current Git commit, remove `[[ -z $where ]] &&` from the next line.
- [[ -z $where ]] && res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}"
+ # 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
+ res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}"
# Show tracking branch name if it differs from local branch.
if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then
- res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape %
+ 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+=" "
@@ -430,7 +473,7 @@
# Don't show Git status in prompt for repositories whose workdir matches this pattern.
# For example, if set to '~', the Git repository at $HOME/.git will be ignored.
- # Multiple patterns can be combined with '|': '~|~/some/dir'.
+ # Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'.
typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~'
# Disable the default Git status formatting.
@@ -451,10 +494,10 @@
# Show status of repositories of these types. You can add svn and/or hg if you are
# using them. If you do, your prompt may become slow even when your current directory
- # isn't in an svn or hg reposotiry.
+ # isn't in an svn or hg repository.
typeset -g POWERLEVEL9K_VCS_BACKENDS=(git)
- # These settings are used for respositories other than Git or when gitstatusd fails and
+ # These settings are used for repositories other than Git or when gitstatusd fails and
# Powerlevel10k has to fall back to using vcs_info.
typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76
typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=76
@@ -497,7 +540,7 @@
typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='โ'
###################[ command_execution_time: duration of the last command ]###################
- # Show duration of the last command if takes longer than this many seconds.
+ # Show duration of the last command if takes at least this many seconds.
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3
# Show this many fractional digits. Zero means round to seconds.
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
@@ -526,6 +569,7 @@
###############[ asdf: asdf version manager (https://github.com/asdf-vm/asdf) ]###############
# Default asdf color. Only used to display tools for which there is no color override (see below).
+ # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_FOREGROUND.
typeset -g POWERLEVEL9K_ASDF_FOREGROUND=66
# There are four parameters that can be used to hide asdf tools. Each parameter describes
@@ -571,7 +615,7 @@
typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true
# If set to non-empty value, hide tools unless there is a file matching the specified file pattern
- # in the current directory, or its parent diretory, or its grandparent directory, and so on.
+ # in the current directory, or its parent directory, or its grandparent directory, and so on.
#
# Note: If this parameter is set to empty value, it won't hide tools.
# Note: SHOW_ON_UPGLOB isn't specific to asdf. It works with all prompt segments.
@@ -658,6 +702,11 @@
# typeset -g POWERLEVEL9K_ASDF_HASKELL_VISUAL_IDENTIFIER_EXPANSION='โญ'
# typeset -g POWERLEVEL9K_ASDF_HASKELL_SHOW_ON_UPGLOB='*.foo|*.bar'
+ # Julia version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_JULIA_FOREGROUND=70
+ # typeset -g POWERLEVEL9K_ASDF_JULIA_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ # typeset -g POWERLEVEL9K_ASDF_JULIA_SHOW_ON_UPGLOB='*.foo|*.bar'
+
##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]###########
# NordVPN connection indicator color.
typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=39
@@ -672,6 +721,12 @@
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.
@@ -679,6 +734,18 @@
# 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
@@ -695,12 +762,21 @@
# 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
@@ -777,7 +853,7 @@
##############[ taskwarrior: taskwarrior task count (https://taskwarrior.org/) ]##############
# Taskwarrior color.
typeset -g POWERLEVEL9K_TASKWARRIOR_FOREGROUND=74
-
+
# Taskwarrior segment format. The following parameters are available within the expansion.
#
# - P9K_TASKWARRIOR_PENDING_COUNT The number of pending tasks: `task +PENDING count`.
@@ -794,6 +870,30 @@
# 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
@@ -823,6 +923,9 @@
typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=37
# Don't show Python version next to the virtual environment name.
typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false
+ # If set to "false", won't show virtualenv if pyenv is already shown.
+ # If set to "if-different", won't show virtualenv if it's the same as pyenv.
+ typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false
# Separate environment name from Python version only with a space.
typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER=
# Custom icon.
@@ -831,10 +934,33 @@
#####################[ anaconda: conda environment (https://conda.io/) ]######################
# Anaconda environment color.
typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=37
- # Don't show Python version next to the anaconda environment name.
- typeset -g POWERLEVEL9K_ANACONDA_SHOW_PYTHON_VERSION=false
- # Separate environment name from Python version only with a space.
- typeset -g POWERLEVEL9K_ANACONDA_{LEFT,RIGHT}_DELIMITER=
+
+ # Anaconda segment format. The following parameters are available within the expansion.
+ #
+ # - CONDA_PREFIX Absolute path to the active Anaconda/Miniconda environment.
+ # - CONDA_DEFAULT_ENV Name of the active Anaconda/Miniconda environment.
+ # - CONDA_PROMPT_MODIFIER Configurable prompt modifier (see below).
+ # - P9K_ANACONDA_PYTHON_VERSION Current python version (python --version).
+ #
+ # CONDA_PROMPT_MODIFIER can be configured with the following command:
+ #
+ # conda config --set env_prompt '({default_env}) '
+ #
+ # The last argument is a Python format string that can use the following variables:
+ #
+ # - prefix The same as CONDA_PREFIX.
+ # - default_env The same as CONDA_DEFAULT_ENV.
+ # - name The last segment of CONDA_PREFIX.
+ # - stacked_env Comma-separated list of names in the environment stack. The first element is
+ # always the same as default_env.
+ #
+ # Note: '({default_env}) ' is the default value of env_prompt.
+ #
+ # The default value of POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION expands to $CONDA_PROMPT_MODIFIER
+ # without the surrounding parentheses, or to the last path component of CONDA_PREFIX if the former
+ # is empty.
+ typeset -g POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION='${${${${CONDA_PROMPT_MODIFIER#\(}% }%\)}:-${CONDA_PREFIX:t}}'
+
# Custom icon.
# typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION='โญ'
@@ -848,6 +974,19 @@
typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false
# If set to false, hide python version if it's equal to "system".
typeset -g POWERLEVEL9K_PYENV_SHOW_SYSTEM=true
+
+ # Pyenv segment format. The following parameters are available within the expansion.
+ #
+ # - P9K_CONTENT Current pyenv environment (pyenv version-name).
+ # - P9K_PYENV_PYTHON_VERSION Current python version (python --version).
+ #
+ # 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}'
+
# Custom icon.
# typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='โญ'
@@ -880,6 +1019,11 @@
##############[ 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='โญ'
@@ -1029,6 +1173,16 @@
# 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
@@ -1042,6 +1196,19 @@
# Custom icon.
# typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ #######[ scalaenv: scala version from scalaenv (https://github.com/scalaenv/scalaenv) ]#######
+ # Scala color.
+ typeset -g POWERLEVEL9K_SCALAENV_FOREGROUND=160
+ # Hide scala version if it doesn't come from one of these sources.
+ typeset -g POWERLEVEL9K_SCALAENV_SOURCES=(shell local global)
+ # If set to false, hide scala version if it's the same as global:
+ # $(scalaenv version-name) == $(scalaenv global).
+ typeset -g POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW=false
+ # If set to false, hide scala version if it's equal to "system".
+ typeset -g POWERLEVEL9K_SCALAENV_SHOW_SYSTEM=true
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_SCALAENV_VISUAL_IDENTIFIER_EXPANSION='โญ'
+
##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]###########
# Haskell color.
typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=172
@@ -1057,9 +1224,9 @@
# typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='โญ'
#############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]#############
- # Show kubecontext only when the the command you are typing invokes one of these tools.
+ # Show kubecontext only when 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'
+ 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'
# Kubernetes context classes for the purpose of using different colors, icons and expansions with
# different contexts.
@@ -1144,6 +1311,8 @@
# typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%fat '
################[ terraform: terraform workspace (https://www.terraform.io) ]#################
+ # Don't show terraform workspace if it's literally "default".
+ typeset -g POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT=false
# POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element
# in each pair defines a pattern against which the current terraform workspace gets matched.
# More specifically, it's P9K_CONTENT prior to the application of context expansion (see below)
@@ -1157,7 +1326,7 @@
# typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=(
# '*prod*' PROD
# '*test*' TEST
- # '*' DEFAULT)
+ # '*' OTHER)
#
# If your current terraform workspace is "project_test", its class is TEST because "project_test"
# doesn't match the pattern '*prod*' but does match '*test*'.
@@ -1170,14 +1339,20 @@
typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=(
# '*prod*' PROD # These values are examples that are unlikely
# '*test*' TEST # to match your needs. Customize them as needed.
- '*' DEFAULT)
- typeset -g POWERLEVEL9K_TERRAFORM_DEFAULT_FOREGROUND=38
- # typeset -g POWERLEVEL9K_TERRAFORM_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ '*' OTHER)
+ 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 the command you are typing invokes one of these tools.
+ # Show aws only when 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|terraform|pulumi'
+ typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|cdk|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.
@@ -1209,6 +1384,12 @@
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
@@ -1216,18 +1397,47 @@
# 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 the command you are typing invokes one of these tools.
+ # Show azure only when 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'
+ 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_FOREGROUND=32
+ typeset -g POWERLEVEL9K_AZURE_OTHER_FOREGROUND=32
# Custom icon.
- # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ # typeset -g POWERLEVEL9K_AZURE_OTHER_VISUAL_IDENTIFIER_EXPANSION='โญ'
##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]###########
- # Show gcloud only when the the command you are typing invokes one of these tools.
+ # Show gcloud only when 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'
+ typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil'
# Google cloud color.
typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=32
@@ -1243,7 +1453,7 @@
# P9K_GCLOUD_PROJECT_ID | gcloud config get-value project
# P9K_GCLOUD_PROJECT_NAME | gcloud projects describe $P9K_GCLOUD_PROJECT_ID --format='value(name)'
#
- # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurences of '%' replaced with '%%'.
+ # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced with '%%'.
#
# Obtaining project name requires sending a request to Google servers. This can take a long time
# and even fail. When project name is unknown, P9K_GCLOUD_PROJECT_NAME is not set and gcloud
@@ -1266,9 +1476,9 @@
# 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 the command you are typing invokes one of these tools.
+ # Show google_app_cred only when 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'
+ typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt'
# Google application credentials classes for the purpose of using different colors, icons and
# expansions with different credentials.
@@ -1316,9 +1526,19 @@
# P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id
# P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email
#
- # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurences of '%' replaced by '%%'.
+ # 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
@@ -1333,7 +1553,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='(wg|(.*tun))[0-9]*'
+ typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*|(zt.*)'
# 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.
@@ -1347,17 +1567,19 @@
# 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_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_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)
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.
- typeset -g POWERLEVEL9K_IP_INTERFACE='e.*'
+ typeset -g POWERLEVEL9K_IP_INTERFACE='[ew].*'
# Custom icon.
# typeset -g POWERLEVEL9K_IP_VISUAL_IDENTIFIER_EXPANSION='โญ'
@@ -1400,15 +1622,11 @@
# Parameter | Meaning
# ----------------------+---------------
# P9K_WIFI_SSID | service set identifier, a.k.a. network name
- # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"
+ # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"; empty if unknown
# P9K_WIFI_LAST_TX_RATE | wireless transmit rate in megabits per second
# P9K_WIFI_RSSI | signal strength in dBm, from -120 to 0
# P9K_WIFI_NOISE | noise in dBm, from -120 to 0
# P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE)
- #
- # All parameters except P9K_WIFI_BARS are extracted from the output of the following command:
- #
- # /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I
####################################[ time: current time ]####################################
# Current time color.
@@ -1435,7 +1653,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/blob/master/README.md#instant-prompt.
+ # https://github.com/romkatv/powerlevel10k#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
@@ -1471,7 +1689,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/blob/master/README.md#instant-prompt.
+ # https://github.com/romkatv/powerlevel10k#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 2ab4369f..7a4d2441 100644
--- a/config/p10k-pure.zsh
+++ b/config/p10k-pure.zsh
@@ -23,13 +23,13 @@
'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand'
() {
- emulate -L zsh
+ emulate -L zsh -o extended_glob
# Unset all configuration options.
- unset -m 'POWERLEVEL9K_*|DEFAULT_USER'
+ unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR'
# Zsh >= 5.1 is required.
- autoload -Uz is-at-least && is-at-least 5.1 || return
+ [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || 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/blob/master/README.md#instant-prompt.
+ # https://github.com/romkatv/powerlevel10k#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 2162e2ca..ed74b7fa 100644
--- a/config/p10k-rainbow.zsh
+++ b/config/p10k-rainbow.zsh
@@ -17,10 +17,10 @@
# Unset all configuration options. This allows you to apply configuration changes without
# restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`.
- unset -m 'POWERLEVEL9K_*|DEFAULT_USER'
+ unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR'
# Zsh >= 5.1 is required.
- autoload -Uz is-at-least && is-at-least 5.1 || return
+ [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return
# The list of segments shown on the left. Fill it with the most important segments.
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
@@ -65,22 +65,30 @@
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
@@ -90,6 +98,8 @@
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
@@ -136,7 +146,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 using this option.
+ # for more compact prompt if 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=
@@ -158,6 +168,9 @@
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.
@@ -188,7 +201,7 @@
# Prompt symbol in command vi mode.
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='โฎ'
# Prompt symbol in visual vi mode.
- typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='โ
ค'
+ typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V'
# Prompt symbol in overwrite vi mode.
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='โถ'
typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true
@@ -201,7 +214,7 @@
##################################[ dir: current directory ]##################################
# Current directory background color.
- # typeset -g POWERLEVEL9K_DIR_BACKGROUND=4
+ typeset -g POWERLEVEL9K_DIR_BACKGROUND=4
# Default current directory foreground color.
typeset -g POWERLEVEL9K_DIR_FOREGROUND=254
# If directory is too long, shorten some of its segments to the shortest possible unique
@@ -230,7 +243,8 @@
.java-version
.perl-version
.php-version
- .tool-version
+ .tool-versions
+ .mise.toml
.shorten_folder_marker
.svn
.terraform
@@ -247,6 +261,11 @@
# /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first)
# or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers
# and other directories don't.
+ #
+ # Optionally, "first" and "last" can be followed by ":" where is an integer.
+ # This moves the truncation point to the right (positive offset) or to the left (negative offset)
+ # relative to the marker. Plain "first" and "last" are equivalent to "first:0" and "last:0"
+ # respectively.
typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false
# Don't shorten this many last directory segments. They are anchors.
typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
@@ -268,12 +287,12 @@
# 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
- # The default icon shown next to non-writable directories when POWERLEVEL9K_DIR_SHOW_WRITABLE is
- # set to v2.
+ # The default icon shown next to non-writable and non-existent directories when
+ # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3.
# typeset -g POWERLEVEL9K_LOCK_ICON='โญ'
# POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different
@@ -286,8 +305,8 @@
#
# Triplets are tried in order. The first triplet whose pattern matches $PWD wins.
#
- # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v2 and the current directory is not writable,
- # its class gets suffix _NOT_WRITABLE.
+ # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories
+ # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively.
#
# For example, given these settings:
#
@@ -296,10 +315,11 @@
# '~(|/*)' HOME ''
# '*' DEFAULT '')
#
- # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with class
- # WORK or WORK_NOT_WRITABLE.
+ # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one
+ # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or
+ # WORK_NON_EXISTENT.
#
- # Simply assigning classes to directories don't have any visible effects. It merely gives you an
+ # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an
# option to define custom colors and icons for different directory classes.
#
# # Styling for WORK.
@@ -316,6 +336,13 @@
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=250
# typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=255
#
+ # # Styling for WORK_NON_EXISTENT.
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_BACKGROUND=4
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=254
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=250
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=255
+ #
# If a styling parameter isn't explicitly defined for some class, it falls back to the classless
# parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls
# back to POWERLEVEL9K_DIR_FOREGROUND.
@@ -326,14 +353,14 @@
# typeset -g POWERLEVEL9K_DIR_PREFIX='in '
#####################################[ vcs: git status ]######################################
- # 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
+ # Version control background colors.
+ typeset -g POWERLEVEL9K_VCS_CLEAN_BACKGROUND=2
+ typeset -g POWERLEVEL9K_VCS_MODIFIED_BACKGROUND=3
+ typeset -g POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND=2
+ typeset -g POWERLEVEL9K_VCS_CONFLICTED_BACKGROUND=3
+ typeset -g POWERLEVEL9K_VCS_LOADING_BACKGROUND=8
- # Branch icon. Set this parameter to '\uF126 ' for the popular Powerline branch icon.
+ # Branch icon. Set this parameter to '\UE0A0 ' 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.
@@ -342,7 +369,7 @@
# Formatter for Git status.
#
- # Example output: master โฃ42โก42 *42 merge ~42 +42 !42 ?42.
+ # Example output: master wip โฃ42โก42 *42 merge ~42 +42 !42 ?42.
#
# You can edit the function to customize how Git status looks.
#
@@ -366,35 +393,55 @@
local conflicted='%1F' # red foreground
local res
- local where # branch or tag
+
if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then
- res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}"
- where=${(V)VCS_STATUS_LOCAL_BRANCH}
- elif [[ -n $VCS_STATUS_TAG ]]; then
- res+="${meta}#"
- where=${(V)VCS_STATUS_TAG}
+ local branch=${(V)VCS_STATUS_LOCAL_BRANCH}
+ # If local branch name is at most 32 characters long, show it in full.
+ # Otherwise show the first 12 โฆ the last 12.
+ # Tip: To always show local branch name in full without truncation, delete the next line.
+ (( $#branch > 32 )) && branch[13,-13]="โฆ" # <-- this line
+ res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}"
fi
- # If local branch name or tag is at most 32 characters long, show it in full.
- # Otherwise show the first 12 โฆ the last 12.
- # Tip: To always show local branch name in full without truncation, delete the next line.
- (( $#where > 32 )) && where[13,-13]="โฆ"
- res+="${clean}${where//\%/%%}" # escape %
+ if [[ -n $VCS_STATUS_TAG
+ # Show tag only if not on a branch.
+ # Tip: To always show tag, delete the next line.
+ && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line
+ ]]; then
+ local tag=${(V)VCS_STATUS_TAG}
+ # If tag name is at most 32 characters long, show it in full.
+ # Otherwise show the first 12 โฆ the last 12.
+ # Tip: To always show tag name in full without truncation, delete the next line.
+ (( $#tag > 32 )) && tag[13,-13]="โฆ" # <-- this line
+ res+="${meta}#${clean}${tag//\%/%%}"
+ fi
- # Display the current Git commit if there is no branch or tag.
- # Tip: To always display the current Git commit, remove `[[ -z $where ]] &&` from the next line.
- [[ -z $where ]] && res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}"
+ # 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
+ res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}"
# Show tracking branch name if it differs from local branch.
if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then
- res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape %
+ 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+=" "
@@ -436,7 +483,7 @@
# Don't show Git status in prompt for repositories whose workdir matches this pattern.
# For example, if set to '~', the Git repository at $HOME/.git will be ignored.
- # Multiple patterns can be combined with '|': '~|~/some/dir'.
+ # Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'.
typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~'
# Disable the default Git status formatting.
@@ -453,7 +500,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 reposotiry.
+ # isn't in an svn or hg repository.
typeset -g POWERLEVEL9K_VCS_BACKENDS=(git)
##########################[ status: exit code of the last command ]###########################
@@ -465,43 +512,43 @@
# it will signify success by turning green.
typeset -g POWERLEVEL9K_STATUS_OK=true
typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION='โ'
- # typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=2
- # typeset -g POWERLEVEL9K_STATUS_OK_BACKGROUND=0
+ typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=2
+ typeset -g POWERLEVEL9K_STATUS_OK_BACKGROUND=0
# Status when some part of a pipe command fails but the overall exit status is zero. It may look
# like this: 1|0.
typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true
typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION='โ'
- # typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=2
- # typeset -g POWERLEVEL9K_STATUS_OK_PIPE_BACKGROUND=0
+ typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=2
+ typeset -g POWERLEVEL9K_STATUS_OK_PIPE_BACKGROUND=0
# Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as
# it will signify error by turning red.
typeset -g POWERLEVEL9K_STATUS_ERROR=true
typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='โ'
- # typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=3
- # typeset -g POWERLEVEL9K_STATUS_ERROR_BACKGROUND=1
+ typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=3
+ typeset -g POWERLEVEL9K_STATUS_ERROR_BACKGROUND=1
# Status when the last command was terminated by a signal.
typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true
# Use terse signal names: "INT" instead of "SIGINT(2)".
typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=false
typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION='โ'
- # typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=3
- # typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_BACKGROUND=1
+ typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=3
+ typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_BACKGROUND=1
# Status when some part of a pipe command fails and the overall exit status is also non-zero.
# It may look like this: 1|0.
typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true
typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='โ'
- # typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=3
- # typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_BACKGROUND=1
+ typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=3
+ typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_BACKGROUND=1
###################[ command_execution_time: duration of the last command ]###################
# Execution time color.
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=0
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND=3
- # Show duration of the last command if takes longer than this many seconds.
+ # Show duration of the last command if takes at least this many seconds.
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3
# Show this many fractional digits. Zero means round to seconds.
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
@@ -514,8 +561,8 @@
#######################[ background_jobs: presence of background jobs ]#######################
# Background jobs color.
- # typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=6
- # typeset -g POWERLEVEL9K_BACKGROUND_JOBS_BACKGROUND=0
+ typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=6
+ typeset -g POWERLEVEL9K_BACKGROUND_JOBS_BACKGROUND=0
# Don't show the number of background jobs.
typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false
# Custom icon.
@@ -523,13 +570,15 @@
#######################[ direnv: direnv status (https://direnv.net/) ]########################
# Direnv color.
- # typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=3
- # typeset -g POWERLEVEL9K_DIRENV_BACKGROUND=0
+ typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=3
+ typeset -g POWERLEVEL9K_DIRENV_BACKGROUND=0
# Custom icon.
# typeset -g POWERLEVEL9K_DIRENV_VISUAL_IDENTIFIER_EXPANSION='โญ'
###############[ asdf: asdf version manager (https://github.com/asdf-vm/asdf) ]###############
# Default asdf color. Only used to display tools for which there is no color override (see below).
+ # Tip: Override these parameters for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_FOREGROUND and
+ # POWERLEVEL9K_ASDF_${TOOL}_BACKGROUND.
typeset -g POWERLEVEL9K_ASDF_FOREGROUND=0
typeset -g POWERLEVEL9K_ASDF_BACKGROUND=7
@@ -576,7 +625,7 @@
typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true
# If set to non-empty value, hide tools unless there is a file matching the specified file pattern
- # in the current directory, or its parent diretory, or its grandparent directory, and so on.
+ # in the current directory, or its parent directory, or its grandparent directory, and so on.
#
# Note: If this parameter is set to empty value, it won't hide tools.
# Note: SHOW_ON_UPGLOB isn't specific to asdf. It works with all prompt segments.
@@ -678,10 +727,16 @@
# typeset -g POWERLEVEL9K_ASDF_HASKELL_VISUAL_IDENTIFIER_EXPANSION='โญ'
# typeset -g POWERLEVEL9K_ASDF_HASKELL_SHOW_ON_UPGLOB='*.foo|*.bar'
+ # Julia version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_JULIA_FOREGROUND=0
+ typeset -g POWERLEVEL9K_ASDF_JULIA_BACKGROUND=2
+ # typeset -g POWERLEVEL9K_ASDF_JULIA_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ # typeset -g POWERLEVEL9K_ASDF_JULIA_SHOW_ON_UPGLOB='*.foo|*.bar'
+
##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]###########
# NordVPN connection indicator color.
- # typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=7
- # typeset -g POWERLEVEL9K_NORDVPN_BACKGROUND=4
+ typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=7
+ typeset -g POWERLEVEL9K_NORDVPN_BACKGROUND=4
# Hide NordVPN connection indicator when not connected.
typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_CONTENT_EXPANSION=
typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_VISUAL_IDENTIFIER_EXPANSION=
@@ -690,36 +745,60 @@
#################[ ranger: ranger shell (https://github.com/ranger/ranger) ]##################
# Ranger shell color.
- # typeset -g POWERLEVEL9K_RANGER_FOREGROUND=3
- # typeset -g POWERLEVEL9K_RANGER_BACKGROUND=0
+ typeset -g POWERLEVEL9K_RANGER_FOREGROUND=3
+ 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
- # typeset -g POWERLEVEL9K_NNN_BACKGROUND=6
+ typeset -g POWERLEVEL9K_NNN_FOREGROUND=0
+ typeset -g POWERLEVEL9K_NNN_BACKGROUND=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
- # typeset -g POWERLEVEL9K_VIM_SHELL_BACKGROUND=2
+ typeset -g POWERLEVEL9K_VIM_SHELL_FOREGROUND=0
+ typeset -g POWERLEVEL9K_VIM_SHELL_BACKGROUND=2
# Custom icon.
# typeset -g POWERLEVEL9K_VIM_SHELL_VISUAL_IDENTIFIER_EXPANSION='โญ'
######[ midnight_commander: midnight commander shell (https://midnight-commander.org/) ]######
# Midnight Commander shell color.
- # typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_FOREGROUND=3
- # typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_BACKGROUND=0
+ typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_FOREGROUND=3
+ typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_BACKGROUND=0
# Custom icon.
# typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_VISUAL_IDENTIFIER_EXPANSION='โญ'
#[ nix_shell: nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) ]##
# Nix shell color.
- # typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=0
- # typeset -g POWERLEVEL9K_NIX_SHELL_BACKGROUND=4
+ 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=
@@ -727,14 +806,21 @@
# 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
- # typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_BACKGROUND=0
- # typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_FOREGROUND=0
- # typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_BACKGROUND=3
- # typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_FOREGROUND=7
- # typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_BACKGROUND=1
+ typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_FOREGROUND=3
+ typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_BACKGROUND=0
+ typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_FOREGROUND=0
+ typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_BACKGROUND=3
+ typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_FOREGROUND=7
+ typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_BACKGROUND=1
# Thresholds for different levels of disk usage (percentage points).
typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=90
typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=95
@@ -758,18 +844,20 @@
# 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.
- # typeset -g POWERLEVEL9K_RAM_FOREGROUND=0
- # typeset -g POWERLEVEL9K_RAM_BACKGROUND=3
+ typeset -g POWERLEVEL9K_RAM_FOREGROUND=0
+ typeset -g POWERLEVEL9K_RAM_BACKGROUND=3
# Custom icon.
# typeset -g POWERLEVEL9K_RAM_VISUAL_IDENTIFIER_EXPANSION='โญ'
#####################################[ swap: used swap ]######################################
# Swap color.
- # typeset -g POWERLEVEL9K_SWAP_FOREGROUND=0
- # typeset -g POWERLEVEL9K_SWAP_BACKGROUND=3
+ typeset -g POWERLEVEL9K_SWAP_FOREGROUND=0
+ typeset -g POWERLEVEL9K_SWAP_BACKGROUND=3
# Custom icon.
# typeset -g POWERLEVEL9K_SWAP_VISUAL_IDENTIFIER_EXPANSION='โญ'
@@ -777,21 +865,21 @@
# Show average CPU load over this many last minutes. Valid values are 1, 5 and 15.
typeset -g POWERLEVEL9K_LOAD_WHICH=5
# Load color when load is under 50%.
- # typeset -g POWERLEVEL9K_LOAD_NORMAL_FOREGROUND=0
- # typeset -g POWERLEVEL9K_LOAD_NORMAL_BACKGROUND=2
+ typeset -g POWERLEVEL9K_LOAD_NORMAL_FOREGROUND=0
+ typeset -g POWERLEVEL9K_LOAD_NORMAL_BACKGROUND=2
# Load color when load is between 50% and 70%.
- # typeset -g POWERLEVEL9K_LOAD_WARNING_FOREGROUND=0
- # typeset -g POWERLEVEL9K_LOAD_WARNING_BACKGROUND=3
+ typeset -g POWERLEVEL9K_LOAD_WARNING_FOREGROUND=0
+ typeset -g POWERLEVEL9K_LOAD_WARNING_BACKGROUND=3
# Load color when load is over 70%.
- # typeset -g POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND=0
- # typeset -g POWERLEVEL9K_LOAD_CRITICAL_BACKGROUND=1
+ typeset -g POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND=0
+ typeset -g POWERLEVEL9K_LOAD_CRITICAL_BACKGROUND=1
# Custom icon.
# typeset -g POWERLEVEL9K_LOAD_VISUAL_IDENTIFIER_EXPANSION='โญ'
################[ todo: todo items (https://github.com/todotxt/todo.txt-cli) ]################
# Todo color.
- # typeset -g POWERLEVEL9K_TODO_FOREGROUND=0
- # typeset -g POWERLEVEL9K_TODO_BACKGROUND=8
+ typeset -g POWERLEVEL9K_TODO_FOREGROUND=0
+ typeset -g POWERLEVEL9K_TODO_BACKGROUND=8
# Hide todo when the total number of tasks is zero.
typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_TOTAL=true
# Hide todo when the number of tasks after filtering is zero.
@@ -815,8 +903,8 @@
###########[ timewarrior: timewarrior tracking status (https://timewarrior.net/) ]############
# Timewarrior color.
- # typeset -g POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=255
- # typeset -g POWERLEVEL9K_TIMEWARRIOR_BACKGROUND=8
+ typeset -g POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=255
+ typeset -g POWERLEVEL9K_TIMEWARRIOR_BACKGROUND=8
# If the tracked task is longer than 24 characters, truncate and append "โฆ".
# Tip: To always display tasks without truncation, delete the following parameter.
@@ -829,8 +917,8 @@
##############[ taskwarrior: taskwarrior task count (https://taskwarrior.org/) ]##############
# Taskwarrior color.
- # typeset -g POWERLEVEL9K_TASKWARRIOR_FOREGROUND=0
- # typeset -g POWERLEVEL9K_TASKWARRIOR_BACKGROUND=6
+ typeset -g POWERLEVEL9K_TASKWARRIOR_FOREGROUND=0
+ typeset -g POWERLEVEL9K_TASKWARRIOR_BACKGROUND=6
# Taskwarrior segment format. The following parameters are available within the expansion.
#
@@ -848,6 +936,33 @@
# 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
@@ -877,10 +992,13 @@
###[ virtualenv: python virtual environment (https://docs.python.org/3/library/venv.html) ]###
# Python virtual environment color.
- # typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=0
- # typeset -g POWERLEVEL9K_VIRTUALENV_BACKGROUND=4
+ typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=0
+ typeset -g POWERLEVEL9K_VIRTUALENV_BACKGROUND=4
# Don't show Python version next to the virtual environment name.
typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false
+ # If set to "false", won't show virtualenv if pyenv is already shown.
+ # If set to "if-different", won't show virtualenv if it's the same as pyenv.
+ typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false
# Separate environment name from Python version only with a space.
typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER=
# Custom icon.
@@ -888,19 +1006,42 @@
#####################[ anaconda: conda environment (https://conda.io/) ]######################
# Anaconda environment color.
- # typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=0
- # typeset -g POWERLEVEL9K_ANACONDA_BACKGROUND=4
- # Don't show Python version next to the anaconda environment name.
- typeset -g POWERLEVEL9K_ANACONDA_SHOW_PYTHON_VERSION=false
- # Separate environment name from Python version only with a space.
- typeset -g POWERLEVEL9K_ANACONDA_{LEFT,RIGHT}_DELIMITER=
+ typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=0
+ typeset -g POWERLEVEL9K_ANACONDA_BACKGROUND=4
+
+ # Anaconda segment format. The following parameters are available within the expansion.
+ #
+ # - CONDA_PREFIX Absolute path to the active Anaconda/Miniconda environment.
+ # - CONDA_DEFAULT_ENV Name of the active Anaconda/Miniconda environment.
+ # - CONDA_PROMPT_MODIFIER Configurable prompt modifier (see below).
+ # - P9K_ANACONDA_PYTHON_VERSION Current python version (python --version).
+ #
+ # CONDA_PROMPT_MODIFIER can be configured with the following command:
+ #
+ # conda config --set env_prompt '({default_env}) '
+ #
+ # The last argument is a Python format string that can use the following variables:
+ #
+ # - prefix The same as CONDA_PREFIX.
+ # - default_env The same as CONDA_DEFAULT_ENV.
+ # - name The last segment of CONDA_PREFIX.
+ # - stacked_env Comma-separated list of names in the environment stack. The first element is
+ # always the same as default_env.
+ #
+ # Note: '({default_env}) ' is the default value of env_prompt.
+ #
+ # The default value of POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION expands to $CONDA_PROMPT_MODIFIER
+ # without the surrounding parentheses, or to the last path component of CONDA_PREFIX if the former
+ # is empty.
+ typeset -g POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION='${${${${CONDA_PROMPT_MODIFIER#\(}% }%\)}:-${CONDA_PREFIX:t}}'
+
# Custom icon.
# typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION='โญ'
################[ pyenv: python environment (https://github.com/pyenv/pyenv) ]################
# Pyenv color.
- # typeset -g POWERLEVEL9K_PYENV_FOREGROUND=0
- # typeset -g POWERLEVEL9K_PYENV_BACKGROUND=4
+ typeset -g POWERLEVEL9K_PYENV_FOREGROUND=0
+ typeset -g POWERLEVEL9K_PYENV_BACKGROUND=4
# Hide python version if it doesn't come from one of these sources.
typeset -g POWERLEVEL9K_PYENV_SOURCES=(shell local global)
# If set to false, hide python version if it's the same as global:
@@ -908,13 +1049,26 @@
typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false
# If set to false, hide python version if it's equal to "system".
typeset -g POWERLEVEL9K_PYENV_SHOW_SYSTEM=true
+
+ # Pyenv segment format. The following parameters are available within the expansion.
+ #
+ # - P9K_CONTENT Current pyenv environment (pyenv version-name).
+ # - P9K_PYENV_PYTHON_VERSION Current python version (python --version).
+ #
+ # 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}'
+
# Custom icon.
# typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='โญ'
################[ goenv: go environment (https://github.com/syndbg/goenv) ]################
# Goenv color.
- # typeset -g POWERLEVEL9K_GOENV_FOREGROUND=0
- # typeset -g POWERLEVEL9K_GOENV_BACKGROUND=4
+ typeset -g POWERLEVEL9K_GOENV_FOREGROUND=0
+ typeset -g POWERLEVEL9K_GOENV_BACKGROUND=4
# Hide go version if it doesn't come from one of these sources.
typeset -g POWERLEVEL9K_GOENV_SOURCES=(shell local global)
# If set to false, hide go version if it's the same as global:
@@ -927,8 +1081,8 @@
##########[ nodenv: node.js version from nodenv (https://github.com/nodenv/nodenv) ]##########
# Nodenv color.
- # typeset -g POWERLEVEL9K_NODENV_FOREGROUND=2
- # typeset -g POWERLEVEL9K_NODENV_BACKGROUND=0
+ typeset -g POWERLEVEL9K_NODENV_FOREGROUND=2
+ typeset -g POWERLEVEL9K_NODENV_BACKGROUND=0
# Hide node version if it doesn't come from one of these sources.
typeset -g POWERLEVEL9K_NODENV_SOURCES=(shell local global)
# If set to false, hide node version if it's the same as global:
@@ -941,15 +1095,20 @@
##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]###############
# Nvm color.
- # typeset -g POWERLEVEL9K_NVM_FOREGROUND=0
- # typeset -g POWERLEVEL9K_NVM_BACKGROUND=5
+ 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='โญ'
############[ nodeenv: node.js environment (https://github.com/ekalinin/nodeenv) ]############
# Nodeenv color.
- # typeset -g POWERLEVEL9K_NODEENV_FOREGROUND=2
- # typeset -g POWERLEVEL9K_NODEENV_BACKGROUND=0
+ typeset -g POWERLEVEL9K_NODEENV_FOREGROUND=2
+ typeset -g POWERLEVEL9K_NODEENV_BACKGROUND=0
# Don't show Node version next to the environment name.
typeset -g POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION=false
# Separate environment name from Node version only with a space.
@@ -959,8 +1118,8 @@
##############################[ node_version: node.js version ]###############################
# Node version color.
- # typeset -g POWERLEVEL9K_NODE_VERSION_FOREGROUND=7
- # typeset -g POWERLEVEL9K_NODE_VERSION_BACKGROUND=2
+ typeset -g POWERLEVEL9K_NODE_VERSION_FOREGROUND=7
+ typeset -g POWERLEVEL9K_NODE_VERSION_BACKGROUND=2
# Show node version only when in a directory tree containing package.json.
typeset -g POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=true
# Custom icon.
@@ -968,8 +1127,8 @@
#######################[ go_version: go version (https://golang.org) ]########################
# Go version color.
- # typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=255
- # typeset -g POWERLEVEL9K_GO_VERSION_BACKGROUND=2
+ typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=255
+ typeset -g POWERLEVEL9K_GO_VERSION_BACKGROUND=2
# Show go version only when in a go project subdirectory.
typeset -g POWERLEVEL9K_GO_VERSION_PROJECT_ONLY=true
# Custom icon.
@@ -977,8 +1136,8 @@
#################[ rust_version: rustc version (https://www.rust-lang.org) ]##################
# Rust version color.
- # typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=0
- # typeset -g POWERLEVEL9K_RUST_VERSION_BACKGROUND=208
+ typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=0
+ typeset -g POWERLEVEL9K_RUST_VERSION_BACKGROUND=208
# Show rust version only when in a rust project subdirectory.
typeset -g POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY=true
# Custom icon.
@@ -986,8 +1145,8 @@
###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################
# .NET version color.
- # typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=7
- # typeset -g POWERLEVEL9K_DOTNET_VERSION_BACKGROUND=5
+ typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=7
+ typeset -g POWERLEVEL9K_DOTNET_VERSION_BACKGROUND=5
# Show .NET version only when in a .NET project subdirectory.
typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true
# Custom icon.
@@ -1011,8 +1170,8 @@
#############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]##############
# Rbenv color.
- # typeset -g POWERLEVEL9K_RBENV_FOREGROUND=0
- # typeset -g POWERLEVEL9K_RBENV_BACKGROUND=1
+ typeset -g POWERLEVEL9K_RBENV_FOREGROUND=0
+ typeset -g POWERLEVEL9K_RBENV_BACKGROUND=1
# Hide ruby version if it doesn't come from one of these sources.
typeset -g POWERLEVEL9K_RBENV_SOURCES=(shell local global)
# If set to false, hide ruby version if it's the same as global:
@@ -1036,8 +1195,8 @@
###[ package: name@version from package.json (https://docs.npmjs.com/files/package.json) ]####
# Package color.
- # typeset -g POWERLEVEL9K_PACKAGE_FOREGROUND=0
- # typeset -g POWERLEVEL9K_PACKAGE_BACKGROUND=6
+ typeset -g POWERLEVEL9K_PACKAGE_FOREGROUND=0
+ typeset -g POWERLEVEL9K_PACKAGE_BACKGROUND=6
# Package format. The following parameters are available within the expansion.
#
@@ -1051,8 +1210,8 @@
#######################[ rvm: ruby version from rvm (https://rvm.io) ]########################
# Rvm color.
- # typeset -g POWERLEVEL9K_RVM_FOREGROUND=0
- # typeset -g POWERLEVEL9K_RVM_BACKGROUND=240
+ typeset -g POWERLEVEL9K_RVM_FOREGROUND=0
+ typeset -g POWERLEVEL9K_RVM_BACKGROUND=240
# Don't show @gemset at the end.
typeset -g POWERLEVEL9K_RVM_SHOW_GEMSET=false
# Don't show ruby- at the front.
@@ -1062,15 +1221,15 @@
###########[ fvm: flutter version management (https://github.com/leoafarias/fvm) ]############
# Fvm color.
- # typeset -g POWERLEVEL9K_FVM_FOREGROUND=0
- # typeset -g POWERLEVEL9K_FVM_BACKGROUND=4
+ typeset -g POWERLEVEL9K_FVM_FOREGROUND=0
+ typeset -g POWERLEVEL9K_FVM_BACKGROUND=4
# Custom icon.
# typeset -g POWERLEVEL9K_FVM_VISUAL_IDENTIFIER_EXPANSION='โญ'
##########[ luaenv: lua version from luaenv (https://github.com/cehoffman/luaenv) ]###########
# Lua color.
- # typeset -g POWERLEVEL9K_LUAENV_FOREGROUND=0
- # typeset -g POWERLEVEL9K_LUAENV_BACKGROUND=4
+ typeset -g POWERLEVEL9K_LUAENV_FOREGROUND=0
+ typeset -g POWERLEVEL9K_LUAENV_BACKGROUND=4
# Hide lua version if it doesn't come from one of these sources.
typeset -g POWERLEVEL9K_LUAENV_SOURCES=(shell local global)
# If set to false, hide lua version if it's the same as global:
@@ -1083,8 +1242,8 @@
###############[ jenv: java version from jenv (https://github.com/jenv/jenv) ]################
# Java color.
- # typeset -g POWERLEVEL9K_JENV_FOREGROUND=1
- # typeset -g POWERLEVEL9K_JENV_BACKGROUND=7
+ typeset -g POWERLEVEL9K_JENV_FOREGROUND=1
+ typeset -g POWERLEVEL9K_JENV_BACKGROUND=7
# Hide java version if it doesn't come from one of these sources.
typeset -g POWERLEVEL9K_JENV_SOURCES=(shell local global)
# If set to false, hide java version if it's the same as global:
@@ -1097,8 +1256,8 @@
###########[ plenv: perl version from plenv (https://github.com/tokuhirom/plenv) ]############
# Perl color.
- # typeset -g POWERLEVEL9K_PLENV_FOREGROUND=0
- # typeset -g POWERLEVEL9K_PLENV_BACKGROUND=4
+ typeset -g POWERLEVEL9K_PLENV_FOREGROUND=0
+ typeset -g POWERLEVEL9K_PLENV_BACKGROUND=4
# Hide perl version if it doesn't come from one of these sources.
typeset -g POWERLEVEL9K_PLENV_SOURCES=(shell local global)
# If set to false, hide perl version if it's the same as global:
@@ -1109,10 +1268,20 @@
# 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
- # typeset -g POWERLEVEL9K_PHPENV_BACKGROUND=5
+ typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=0
+ typeset -g POWERLEVEL9K_PHPENV_BACKGROUND=5
# Hide php version if it doesn't come from one of these sources.
typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global)
# If set to false, hide php version if it's the same as global:
@@ -1123,10 +1292,24 @@
# Custom icon.
# typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ #######[ scalaenv: scala version from scalaenv (https://github.com/scalaenv/scalaenv) ]#######
+ # Scala color.
+ typeset -g POWERLEVEL9K_SCALAENV_FOREGROUND=0
+ typeset -g POWERLEVEL9K_SCALAENV_BACKGROUND=1
+ # Hide scala version if it doesn't come from one of these sources.
+ typeset -g POWERLEVEL9K_SCALAENV_SOURCES=(shell local global)
+ # If set to false, hide scala version if it's the same as global:
+ # $(scalaenv version-name) == $(scalaenv global).
+ typeset -g POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW=false
+ # If set to false, hide scala version if it's equal to "system".
+ typeset -g POWERLEVEL9K_SCALAENV_SHOW_SYSTEM=true
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_SCALAENV_VISUAL_IDENTIFIER_EXPANSION='โญ'
+
##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]###########
# Haskell color.
- # typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=0
- # typeset -g POWERLEVEL9K_HASKELL_STACK_BACKGROUND=3
+ typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=0
+ typeset -g POWERLEVEL9K_HASKELL_STACK_BACKGROUND=3
# Hide haskell version if it doesn't come from one of these sources.
#
@@ -1140,6 +1323,8 @@
# typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='โญ'
################[ terraform: terraform workspace (https://www.terraform.io) ]#################
+ # Don't show terraform workspace if it's literally "default".
+ typeset -g POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT=false
# POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element
# in each pair defines a pattern against which the current terraform workspace gets matched.
# More specifically, it's P9K_CONTENT prior to the application of context expansion (see below)
@@ -1153,7 +1338,7 @@
# typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=(
# '*prod*' PROD
# '*test*' TEST
- # '*' DEFAULT)
+ # '*' OTHER)
#
# If your current terraform workspace is "project_test", its class is TEST because "project_test"
# doesn't match the pattern '*prod*' but does match '*test*'.
@@ -1161,20 +1346,31 @@
# You can define different colors, icons and content expansions for different classes:
#
# typeset -g POWERLEVEL9K_TERRAFORM_TEST_FOREGROUND=2
+ # typeset -g POWERLEVEL9K_TERRAFORM_TEST_BACKGROUND=0
# typeset -g POWERLEVEL9K_TERRAFORM_TEST_VISUAL_IDENTIFIER_EXPANSION='โญ'
# typeset -g POWERLEVEL9K_TERRAFORM_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <'
typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=(
# '*prod*' PROD # These values are examples that are unlikely
# '*test*' TEST # to match your needs. Customize them as needed.
- '*' DEFAULT)
- typeset -g POWERLEVEL9K_TERRAFORM_DEFAULT_FOREGROUND=4
- typeset -g POWERLEVEL9K_TERRAFORM_DEFAULT_BACKGROUND=0
- # typeset -g POWERLEVEL9K_TERRAFORM_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ '*' OTHER)
+ typeset -g POWERLEVEL9K_TERRAFORM_OTHER_FOREGROUND=4
+ 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 the command you are typing invokes one of these tools.
+ # Show kubecontext only when 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'
+ 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'
# Kubernetes context classes for the purpose of using different colors, icons and expansions with
# different contexts.
@@ -1261,9 +1457,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 the command you are typing invokes one of these tools.
+ # Show aws only when 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|terraform|pulumi'
+ typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|cdk|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.
@@ -1292,34 +1488,70 @@
# '*prod*' PROD # These values are examples that are unlikely
# '*test*' TEST # to match your needs. Customize them as needed.
'*' DEFAULT)
- # typeset -g POWERLEVEL9K_AWS_DEFAULT_FOREGROUND=7
- # typeset -g POWERLEVEL9K_AWS_DEFAULT_BACKGROUND=1
+ typeset -g POWERLEVEL9K_AWS_DEFAULT_FOREGROUND=7
+ 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
- # typeset -g POWERLEVEL9K_AWS_EB_ENV_BACKGROUND=0
+ typeset -g POWERLEVEL9K_AWS_EB_ENV_FOREGROUND=2
+ typeset -g POWERLEVEL9K_AWS_EB_ENV_BACKGROUND=0
# Custom icon.
# typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='โญ'
##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]##########
- # Show azure only when the the command you are typing invokes one of these tools.
+ # Show azure only when 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'
+ 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_FOREGROUND=7
- # typeset -g POWERLEVEL9K_AZURE_BACKGROUND=4
+ typeset -g POWERLEVEL9K_AZURE_OTHER_FOREGROUND=7
+ typeset -g POWERLEVEL9K_AZURE_OTHER_BACKGROUND=4
# Custom icon.
- # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='โญ'
+ # typeset -g POWERLEVEL9K_AZURE_OTHER_VISUAL_IDENTIFIER_EXPANSION='โญ'
##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]###########
- # Show gcloud only when the the command you are typing invokes one of these tools.
+ # Show gcloud only when 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'
+ typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil'
# Google cloud color.
- # typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=7
- # typeset -g POWERLEVEL9K_GCLOUD_BACKGROUND=4
+ typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=7
+ typeset -g POWERLEVEL9K_GCLOUD_BACKGROUND=4
# Google cloud format. Change the value of POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION and/or
# POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION if the default is too verbose or not informative
@@ -1333,7 +1565,7 @@
# P9K_GCLOUD_PROJECT_ID | gcloud config get-value project
# P9K_GCLOUD_PROJECT_NAME | gcloud projects describe $P9K_GCLOUD_PROJECT_ID --format='value(name)'
#
- # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurences of '%' replaced with '%%'.
+ # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced with '%%'.
#
# Obtaining project name requires sending a request to Google servers. This can take a long time
# and even fail. When project name is unknown, P9K_GCLOUD_PROJECT_NAME is not set and gcloud
@@ -1356,9 +1588,9 @@
# 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 the command you are typing invokes one of these tools.
+ # Show google_app_cred only when 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'
+ typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt'
# Google application credentials classes for the purpose of using different colors, icons and
# expansions with different credentials.
@@ -1390,8 +1622,8 @@
# '*:*prod*:*' PROD # These values are examples that are unlikely
# '*:*test*:*' TEST # to match your needs. Customize them as needed.
'*' DEFAULT)
- # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_FOREGROUND=7
- # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_BACKGROUND=4
+ typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_FOREGROUND=7
+ typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_BACKGROUND=4
# typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='โญ'
# Use POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION to specify the content displayed by
@@ -1407,26 +1639,37 @@
# P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id
# P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email
#
- # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurences of '%' replaced by '%%'.
+ # 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
- # typeset -g POWERLEVEL9K_PUBLIC_IP_BACKGROUND=0
+ typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=7
+ typeset -g POWERLEVEL9K_PUBLIC_IP_BACKGROUND=0
# Custom icon.
# typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='โญ'
########################[ vpn_ip: virtual private network indicator ]#########################
# VPN IP color.
- # typeset -g POWERLEVEL9K_VPN_IP_FOREGROUND=0
- # typeset -g POWERLEVEL9K_VPN_IP_BACKGROUND=6
+ typeset -g POWERLEVEL9K_VPN_IP_FOREGROUND=0
+ typeset -g POWERLEVEL9K_VPN_IP_BACKGROUND=6
# When on VPN, show just an icon without the IP address.
# Tip: To display the private IP address when on VPN, remove the next line.
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='(wg|(.*tun))[0-9]*'
+ typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*|(zt.*)'
# 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.
@@ -1441,24 +1684,26 @@
# 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_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_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)
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.
- typeset -g POWERLEVEL9K_IP_INTERFACE='e.*'
+ typeset -g POWERLEVEL9K_IP_INTERFACE='[ew].*'
# Custom icon.
# typeset -g POWERLEVEL9K_IP_VISUAL_IDENTIFIER_EXPANSION='โญ'
#########################[ proxy: system-wide http/https/ftp proxy ]##########################
# Proxy color.
- # typeset -g POWERLEVEL9K_PROXY_FOREGROUND=4
- # typeset -g POWERLEVEL9K_PROXY_BACKGROUND=0
+ typeset -g POWERLEVEL9K_PROXY_FOREGROUND=4
+ typeset -g POWERLEVEL9K_PROXY_BACKGROUND=0
# Custom icon.
# typeset -g POWERLEVEL9K_PROXY_VISUAL_IDENTIFIER_EXPANSION='โญ'
@@ -1474,12 +1719,12 @@
typeset -g POWERLEVEL9K_BATTERY_STAGES=('%K{232}โ' '%K{232}โ' '%K{232}โ' '%K{232}โ' '%K{232}โ
' '%K{232}โ' '%K{232}โ' '%K{232}โ')
# Don't show the remaining time to charge/discharge.
typeset -g POWERLEVEL9K_BATTERY_VERBOSE=false
- # typeset -g POWERLEVEL9K_BATTERY_BACKGROUND=0
+ typeset -g POWERLEVEL9K_BATTERY_BACKGROUND=0
#####################################[ wifi: wifi speed ]#####################################
# WiFi color.
- # typeset -g POWERLEVEL9K_WIFI_FOREGROUND=0
- # typeset -g POWERLEVEL9K_WIFI_BACKGROUND=4
+ typeset -g POWERLEVEL9K_WIFI_FOREGROUND=0
+ typeset -g POWERLEVEL9K_WIFI_BACKGROUND=4
# Custom icon.
# typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='โญ'
@@ -1497,20 +1742,16 @@
# Parameter | Meaning
# ----------------------+---------------
# P9K_WIFI_SSID | service set identifier, a.k.a. network name
- # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"
+ # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"; empty if unknown
# P9K_WIFI_LAST_TX_RATE | wireless transmit rate in megabits per second
# P9K_WIFI_RSSI | signal strength in dBm, from -120 to 0
# P9K_WIFI_NOISE | noise in dBm, from -120 to 0
# P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE)
- #
- # All parameters except P9K_WIFI_BARS are extracted from the output of the following command:
- #
- # /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I
####################################[ time: current time ]####################################
# Current time color.
- # typeset -g POWERLEVEL9K_TIME_FOREGROUND=0
- # typeset -g POWERLEVEL9K_TIME_BACKGROUND=7
+ typeset -g POWERLEVEL9K_TIME_FOREGROUND=0
+ typeset -g POWERLEVEL9K_TIME_BACKGROUND=7
# Format for the current time: 09:51:02. See `man 3 strftime`.
typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}'
# If set to true, time will update when you hit enter. This way prompts for the past
@@ -1534,7 +1775,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/blob/master/README.md#instant-prompt.
+ # https://github.com/romkatv/powerlevel10k#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
@@ -1552,7 +1793,8 @@
}
# User-defined prompt segments can be customized the same way as built-in segments.
- # typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=3
+ typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=3
+ typeset -g POWERLEVEL9K_EXAMPLE_BACKGROUND=1
# typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='โญ'
# Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt
@@ -1570,7 +1812,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/blob/master/README.md#instant-prompt.
+ # https://github.com/romkatv/powerlevel10k#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 7703350e..6a204d29 100644
--- a/config/p10k-robbyrussell.zsh
+++ b/config/p10k-robbyrussell.zsh
@@ -18,13 +18,13 @@
'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand'
() {
- emulate -L zsh
+ emulate -L zsh -o extended_glob
# Unset all configuration options.
- unset -m 'POWERLEVEL9K_*|DEFAULT_USER'
+ unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR'
# Zsh >= 5.1 is required.
- autoload -Uz is-at-least && is-at-least 5.1 || return
+ [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || 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/blob/master/README.md#instant-prompt.
+ # https://github.com/romkatv/powerlevel10k#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
new file mode 100644
index 00000000..cb49af46
--- /dev/null
+++ b/font.md
@@ -0,0 +1,180 @@
+# Recommended font: Meslo Nerd Font patched for Powerlevel10k
+
+Gorgeous monospace font designed by Jim Lyles for Bitstream, customized by the same for Apple,
+further customized by Andrรฉ Berg, and finally patched by yours truly with customized scripts
+originally developed by Ryan L McIntyre of Nerd Fonts. Contains all glyphs and symbols that
+Powerlevel10k may need. Battle-tested in dozens of different terminals on all major operating
+systems.
+
+*FAQ*: [How was the recommended font created?](README.md#how-was-the-recommended-font-created)
+
+## 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
+
+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`.
+ - **Warp**: Open Warp and Navigate to *Settings* then *Appearance*. Scroll down to *Text* Section
+ and under *"Terminal Font"*, select the `MesloLGS NF` font.
+ - **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.
+ - **Deepin Terminal**: Create or open `~/.config/deepin/deepin-terminal/config.conf` and add the following section
+ to it:
+ ```ini
+ [basic.interface.font]
+ value = "MesloLGS NF"
+ ```
+ - **Ghostty**: Open *Menu โ Open Configuration* (Linux) or *Ghostty โ Settings...* (Mac) and add
+ the following line:
+ ```text
+ font-family = "MesloLGS NF"
+ ```
+1. Run `p10k configure` to generate a new `~/.p10k.zsh`. The old config 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 d665af1f..4a695acb 100644
--- a/gitstatus/Makefile
+++ b/gitstatus/Makefile
@@ -2,6 +2,7 @@ APPNAME ?= gitstatusd
OBJDIR ?= obj
CXX ?= g++
+ZSH := $(shell command -v zsh 2> /dev/null)
VERSION ?= $(shell . ./build.info && printf "%s" "$$gitstatus_version")
@@ -9,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 -Werror # -g -fsanitize=thread
+CXXFLAGS += -std=c++14 -funsigned-char -O3 -DNDEBUG -DGITSTATUS_VERSION=$(VERSION) # -Wall -g -fsanitize=thread
LDFLAGS += -pthread # -fsanitize=thread
LDLIBS += -lgit2 # -lprofiler -lunwind
@@ -33,4 +34,24 @@ $(OBJDIR)/%.o: src/%.cc Makefile build.info | $(OBJDIR)
clean:
rm -rf -- $(OBJDIR)
+zwc:
+ $(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 4acd2869..609d5f82 100644
--- a/gitstatus/README.md
+++ b/gitstatus/README.md
@@ -1,5 +1,9 @@
# gitstatus
+- **THE PROJECT HAS VERY LIMITED SUPPORT**
+- **NO NEW FEATURES ARE IN THE WORKS**
+- **MOST BUGS WILL GO UNFIXED**
+
**gitstatus** is a 10x faster alternative to `git status` and `git describe`. Its primary use
case is to enable fast git prompt in interactive shells.
@@ -22,7 +26,8 @@ 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.
+fast theme with first-class gitstatus integration. If you install Powerlevel10k, you don't need to
+install gitstatus.

@@ -35,6 +40,24 @@ 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.
+ไธญๅฝๅคง้็จๆทๅฏไปฅไฝฟ็จ gitee.com ไธ็ๅฎๆน้ๅๅ ้ไธ่ฝฝ.
+
+```zsh
+git clone --depth=1 https://gitee.com/romkatv/gitstatus.git ~/gitstatus
+echo 'source ~/gitstatus/gitstatus.prompt.zsh' >>! ~/.zshrc
+```
+
+Alternatively, if you have Homebrew installed:
+
+```zsh
+brew install romkatv/gitstatus/gitstatus
+echo "source $(brew --prefix)/opt/gitstatus/gitstatus.prompt.zsh" >>! ~/.zshrc
+```
+
+(If you choose this option, replace `~/gitstatus` with `$(brew --prefix)/opt/gitstatus/gitstatus`
+in all code snippets below.)
+
_Make sure to disable your current theme if you have one._
This will give you a basic yet functional prompt with git status in it. It's
@@ -85,9 +108,9 @@ function my_set_prompt() {
if gitstatus_query MY && [[ $VCS_STATUS_RESULT == ok-sync ]]; then
RPROMPT=${${VCS_STATUS_LOCAL_BRANCH:-@${VCS_STATUS_COMMIT}}//\%/%%} # escape %
- (( $VCS_STATUS_NUM_STAGED )) && RPROMPT+='+'
- (( $VCS_STATUS_NUM_UNSTAGED )) && RPROMPT+='!'
- (( $VCS_STATUS_NUM_UNTRACKED )) && RPROMPT+='?'
+ (( VCS_STATUS_NUM_STAGED )) && RPROMPT+='+'
+ (( VCS_STATUS_NUM_UNSTAGED )) && RPROMPT+='!'
+ (( VCS_STATUS_NUM_UNTRACKED )) && RPROMPT+='?'
fi
setopt no_prompt_{bang,subst} prompt_percent # enable/disable correct prompt expansions
@@ -118,6 +141,24 @@ 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.
+ไธญๅฝๅคง้็จๆทๅฏไปฅไฝฟ็จ gitee.com ไธ็ๅฎๆน้ๅๅ ้ไธ่ฝฝ.
+
+```bash
+git clone --depth=1 https://gitee.com/romkatv/gitstatus.git ~/gitstatus
+echo 'source ~/gitstatus/gitstatus.prompt.sh' >> ~/.bashrc
+```
+
+Alternatively, if you have Homebrew installed:
+
+```zsh
+brew install romkatv/gitstatus/gitstatus
+echo "source $(brew --prefix)/opt/gitstatus/gitstatus.prompt.sh" >> ~/.bashrc
+```
+
+(If you choose this option, replace `~/gitstatus` with `$(brew --prefix)/opt/gitstatus/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.
@@ -168,9 +209,9 @@ function my_set_prompt() {
else
PS1+=" @${VCS_STATUS_COMMIT//\\/\\\\}" # escape backslash
fi
- [[ "$VCS_STATUS_HAS_STAGED" == 1 ]] && PS1+='+'
- [[ "$VCS_STATUS_HAS_UNSTAGED" == 1 ]] && PS1+='!'
- [[ "$VCS_STATUS_HAS_UNTRACKED" == 1 ]] && PS1+='?'
+ (( VCS_STATUS_HAS_STAGED" )) && PS1+='+'
+ (( VCS_STATUS_HAS_UNSTAGED" )) && PS1+='!'
+ (( VCS_STATUS_HAS_UNTRACKED" )) && PS1+='?'
fi
PS1+='\n\$ '
@@ -218,7 +259,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 untracked cache enabled
+* `git` with `core.untrackedcache` enabled and `core.fsmonitor` disabled
* `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
@@ -344,7 +385,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 cleary visible. `__GI___fxstatat` is a flavor of `stat()`, and the other
+core of the algorithm are clearly 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
@@ -455,6 +496,15 @@ cd gitstatus
./build -w -s -d docker
```
+Users in China can use the official mirror on gitee.com for faster download.
+ไธญๅฝๅคง้็จๆทๅฏไปฅไฝฟ็จ gitee.com ไธ็ๅฎๆน้ๅๅ ้ไธ่ฝฝ.
+
+```zsh
+git clone --depth=1 https://gitee.com/romkatv/gitstatus.git
+cd gitstatus
+./build -w -s -d docker
+```
+
- If it says that `-d docker` is not supported on your OS, remove this flag.
- If it says that `-s` is not supported on your OS, remove this flag.
- If it tell you to install docker but you cannot or don't want to, remove `-d docker`.
@@ -466,44 +516,17 @@ by shell bindings automatically.
When you update shell bindings, they may refuse to work with the binary you've built earlier. In
this case you'll need to rebuild.
+If you are using gitstatus through [Powerlevel10k](https://github.com/romkatv/powerlevel10k), the
+instructions are the same except that you don't need to clone gitstatus. Instead, change your
+current directory to `/path/to/powerlevel10k/gitstatus` (`/path/to/powerlevel10k` is the directory
+where you've installed Powerlevel10k) and run `./build -w -s -d docker` from there as described
+above.
+
### Compiling for distribution
-If you want to package gitstatus, it's best to do it based off releases. You also probably don't
-want to build in docker (`-d docker`) or to allow automatic downloading of libgit2 tarballs (`-w`).
-
-The following code should work. If it doesn't, please open an issue.
-
-```zsh
-curl -fsSLO https://github.com/romkatv/gitstatus/archive/v1.0.0.tar.gz
-tar -xzf v1.0.0.tar.gz
-cd gitstatus-1.0.0
-(
- . ./build.info
- curl -fsSLo \
- deps/libgit2-"$libgit2_version".tar.gz \
- https://github.com/romkatv/libgit2/archive/"$libgit2_version".tar.gz
-)
-./build
-rm deps/libgit2-*.tar.gz
-for file in gitstatus.plugin.zsh gitstatus.prompt.zsh install; do
- zsh -fc "zcompile -R -- $file.zwc $file"
-done
-```
-
-This needs binutils, cmake, gcc, g++, git, GNU make and zsh.
-
-Depending on your workflow, it might be easier to store the URL to the libgit2 tarball in the
-same place where you are going to put the main gitstatus tarball URL. You'll need to update both
-URLs at the same time when bumping package version.
-
-Once build completes, *do not delete or move any files*. Package the whole directory as is. Don't
-add it (or any of its subdirectories) to `PATH`.
-
-Note that Powerlevel10k has an embedded version of gitstatus. It must stay that way. The embedded
-gitstatus won't conflict with the standalone version. They can have different versions and can
-coexist within the same Zsh process. Do not attempt to surgically remove gitstatus from
-Powerlevel10k, package the result and then somehow force Powerlevel10k to use a separately packaged
-gitstatus.
+It's currently neither easy nor recommended to package and distribute gitstatus. There are no
+instructions you can follow that would allow you to easily update your package when new versions of
+gitstatus are released. This may change in the future but not soon.
## License
diff --git a/gitstatus/build b/gitstatus/build
index 1a591a8c..ea96a25a 100755
--- a/gitstatus/build
+++ b/gitstatus/build
@@ -9,7 +9,28 @@ if [ -n "${ZSH_VERSION:-}" ]; then
emulate sh -o err_exit -o no_unset
fi
-usage="$(cat <<\END
+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]
Options:
@@ -17,8 +38,8 @@ Options:
-m ARCH `uname -m` from the target machine; defaults to `uname -m`
from the local machine
-c CPU generate machine instructions for CPU of this type; this
- value gets passed as `-march` to gcc; inferred from ARCH
- if not set explicitly
+ value gets passed as `-march` (or `-mcpu` for ppc64le) to gcc;
+ inferred from ARCH if not set explicitly
-d CMD build in a Docker container and use CMD as the `docker`
command; e.g., `-d docker` or `-d podman`
-i IMAGE build in this Docker image; inferred from ARCH if not set
@@ -27,73 +48,90 @@ Options:
succeed; on some operating systems this option is not
supported; on others it can have partial effect
-w automatically download tarballs for dependencies if they
- don't already exist in ./deps; dependencies are described
+ do not already exist in ./deps; dependencies are described
in ./build.info
END
)"
-build="$(cat <<\END
-outdir="$(pwd)"
+build="$(command cat <<\END
+outdir="$(command pwd)"
if command -v mktemp >/dev/null 2>&1; then
- workdir="$(mktemp -d "${TMPDIR:-/tmp}"/gitstatus-build.XXXXXXXXXX)"
+ workdir="$(command mktemp -d "${TMPDIR:-/tmp}"/gitstatus-build.XXXXXXXXXX)"
else
workdir="${TMPDIR:-/tmp}/gitstatus-build.tmp.$$"
- mkdir -- "$workdir"
+ command mkdir -- "$workdir"
fi
cd -- "$workdir"
-workdir="$(pwd)"
+workdir="$(command pwd)"
narg() { echo $#; }
-if [ "$(narg $workdir)" != 1 -o -z "${workdir##*:*}" ]; then
+if [ "$(narg $workdir)" != 1 -o -z "${workdir##*:*}" -o -z "${workdir##*=*}" ]; then
>&2 echo "[error] cannot build in this directory: $workdir"
exit 1
fi
-appname=gitstatusd-"$gitstatus_kernel"-"$gitstatus_arch"
+appname=gitstatusd
libgit2_tmp="$outdir"/deps/"$appname".libgit2.tmp
cleanup() {
+ trap - INT QUIT TERM ILL PIPE
cd /
- rm -rf -- "$workdir" "$outdir"/usrbin/"$appname".tmp "$libgit2_tmp"
- trap - INT QUIT TERM EXIT ILL PIPE
+ if ! command rm -rf -- "$workdir" "$outdir"/usrbin/"$appname".tmp "$libgit2_tmp"; then
+ command sleep 5
+ command rm -rf -- "$workdir" "$outdir"/usrbin/"$appname".tmp "$libgit2_tmp"
+ fi
}
-trap cleanup INT QUIT TERM EXIT ILL PIPE
+trap cleanup INT QUIT TERM ILL PIPE
if [ -n "$gitstatus_install_tools" ]; then
case "$gitstatus_kernel" in
linux)
- apk update
- apk add binutils cmake gcc g++ git make musl-dev
+ if command -v apk >/dev/null 2>&1; then
+ command apk update
+ command apk add binutils cmake gcc g++ git make musl-dev perl-utils
+ elif command -v apt-get >/dev/null 2>&1; then
+ apt-get update
+ apt-get install -y binutils cmake gcc g++ make wget
+ else
+ >&2 echo "[error] -s is not supported on this system"
+ exit 1
+ fi
;;
- freebsd)
- pkg install -y cmake gmake binutils gcc git
+ freebsd|dragonfly)
+ command pkg install -y cmake gmake binutils git perl5 wget
+ ;;
+ openbsd)
+ command pkg_add cmake gmake gcc g++ git wget
;;
netbsd)
- pkgin -y install cmake gmake binutils git
+ command pkgin -y install cmake gmake binutils git
;;
darwin)
if ! command -v make >/dev/null 2>&1 || ! command -v gcc >/dev/null 2>&1; then
>&2 echo "[error] please run 'xcode-select --install' and retry"
exit 1
fi
- if ! command -v brew >/dev/null 2>&1; then
- >&2 echo "[error] please install homebrew from https://brew.sh/ and retry"
+ if command -v port >/dev/null 2>&1; 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
+ command brew upgrade "$formula"
+ else
+ command brew install "$formula"
+ fi
+ done
+ else
+ >&2 echo "[error] please install MacPorts or Homebrew and retry"
exit 1
fi
- for formula in libiconv cmake git wget; do
- if brew list "$formula" &>/dev/null; then
- brew upgrade "$formula"
- else
- brew install "$formula"
- fi
- done
;;
msys*|mingw*)
- pacman -Syu --noconfirm
- pacman -S --needed --noconfirm binutils cmake gcc git make
+ command pacman -Syu --noconfirm
+ command pacman -S --needed --noconfirm binutils cmake gcc git make perl
;;
*)
>&2 echo "[internal error] unhandled kernel: $gitstatus_kernel"
@@ -102,43 +140,149 @@ if [ -n "$gitstatus_install_tools" ]; then
esac
fi
-cpus="$(getconf _NPROCESSORS_ONLN)" || cpus="$(sysctl -n hw.ncpu)" || cpus=8
+cpus="$(command getconf _NPROCESSORS_ONLN 2>/dev/null)" ||
+ cpus="$(command sysctl -n hw.ncpu 2>/dev/null)" ||
+ cpus=8
+
+case "$gitstatus_cpu" in
+ powerpc64|powerpc64le)
+ archflag="-mcpu"
+ ;;
+ *)
+ archflag="-march"
+ ;;
+esac
+
+case "$gitstatus_arch" in
+ e2k)
+ nopltflag=""
+ ;;
+ *)
+ nopltflag="-fno-plt"
+ ;;
+esac
+
+cflags="$archflag=$gitstatus_cpu $nopltflag -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
+
+if [ "$gitstatus_cpu" = x86-64 ]; then
+ cflags="$cflags -mtune=generic"
+fi
libgit2_cmake_flags=
-libgit2_cflags="-march=$gitstatus_cpu"
+libgit2_cflags="${CFLAGS-} $cflags -O3 -DNDEBUG"
gitstatus_cxx=g++
-gitstatus_cxxflags="-I${workdir}/libgit2/include -DGITSTATUS_ZERO_NSEC -D_GNU_SOURCE -march=$gitstatus_cpu"
-gitstatus_ldflags="-L${workdir}/libgit2/build"
+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_ldlibs=
gitstatus_make=make
case "$gitstatus_kernel" in
linux)
- gitstatus_ldflags="$gitstatus_ldflags -static"
+ gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}"
+ libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
;;
freebsd)
+ gitstatus_cxx=clang++
gitstatus_make=gmake
- gitstatus_ldflags="$gitstatus_ldflags -static"
+ 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}"
+ libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
;;
netbsd)
gitstatus_make=gmake
- gitstatus_ldflags="$gitstatus_ldflags -static"
+ gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}"
+ libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
;;
darwin)
- mkdir -- "$workdir"/lib
- ln -s -- /usr/local/opt/libiconv/lib/libiconv.a "$workdir"/lib
+ command mkdir -- "$workdir"/lib
+ if [ -e /opt/local/lib/libiconv.a ]; then
+ command ln -s -- /opt/local/lib/libiconv.a "$workdir"/lib
+ libgit2_cflags="$libgit2_cflags -I/opt/local/include"
+ gitstatus_cxxflags="$gitstatus_cxxflags -I/opt/local/include"
+ else
+ brew_prefix="$(command brew --prefix)"
+ command ln -s -- "$brew_prefix"/opt/libiconv/lib/libiconv.a "$workdir"/lib
+ libgit2_cflags="$libgit2_cflags -I"$brew_prefix"/opt/libiconv/include"
+ gitstatus_cxxflags="$gitstatus_cxxflags -I"$brew_prefix"/opt/libiconv/include"
+ fi
libgit2_cmake_flags="$libgit2_cmake_flags -DUSE_ICONV=ON"
- libgit2_cflags="$libgit2_cflags -I/usr/local/opt/libiconv/include"
- gitstatus_cxxflags="$gitstatus_cxxflags -I/usr/local/opt/libiconv/include"
gitstatus_ldlibs="$gitstatus_ldlibs -liconv"
gitstatus_ldflags="$gitstatus_ldflags -L${workdir}/lib"
+ libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=OFF"
;;
msys*|mingw*)
- gitstatus_ldflags="$gitstatus_ldflags -static"
+ gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}"
+ libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
;;
cygwin*)
- gitstatus_ldflags="$gitstatus_ldflags -static"
+ gitstatus_ldflags="$gitstatus_ldflags ${static_pie:--static}"
+ libgit2_cmake_flags="$libgit2_cmake_flags -DENABLE_REPRODUCIBLE_BUILDS=ON"
;;
*)
>&2 echo "[internal error] unhandled kernel: $gitstatus_kernel"
@@ -146,7 +290,7 @@ case "$gitstatus_kernel" in
;;
esac
-for cmd in cmake gcc g++ git ld "$gitstatus_make" wget; do
+for cmd in cat cmake 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"
@@ -159,74 +303,147 @@ for cmd in cmake gcc g++ git ld "$gitstatus_make" wget; do
done
. "$outdir"/build.info
-if [ -z "$libgit2_version" ]; then
+if [ -z "${libgit2_version:-}" ]; then
>&2 echo "[internal error] libgit2_version not set"
exit 1
fi
+if [ -z "${libgit2_sha256:-}" ]; then
+ >&2 echo "[internal error] libgit2_sha256 not set"
+ exit 1
+fi
libgit2_tarball="$outdir"/deps/libgit2-"$libgit2_version".tar.gz
if [ ! -e "$libgit2_tarball" ]; then
if [ -n "$gitstatus_download_deps" ]; then
+ if ! command -v wget >/dev/null 2>&1; then
+ if [ -n "$gitstatus_install_tools" ]; then
+ >&2 echo "[internal error] wget not found"
+ exit 1
+ else
+ >&2 echo "[error] command not found: wget"
+ exit 1
+ fi
+ fi
libgit2_url=https://github.com/romkatv/libgit2/archive/"$libgit2_version".tar.gz
- wget -O "$libgit2_tmp" -- "$libgit2_url"
- mv -f -- "$libgit2_tmp" "$libgit2_tarball"
+ 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 mv -f -- "$libgit2_tmp" "$libgit2_tarball"
else
>&2 echo "[error] file not found: deps/libgit2-"$libgit2_version".tar.gz"
exit 1
fi
fi
+libgit2_actual_sha256=
+if command -v shasum >/dev/null 2>/dev/null; then
+ libgit2_actual_sha256="$(command shasum -b -a 256 -- "$libgit2_tarball")"
+ libgit2_actual_sha256="${libgit2_actual_sha256%% *}"
+elif command -v sha256sum >/dev/null 2>/dev/null; then
+ libgit2_actual_sha256="$(command sha256sum -b -- "$libgit2_tarball")"
+ libgit2_actual_sha256="${libgit2_actual_sha256%% *}"
+elif command -v sha256 >/dev/null 2>/dev/null; then
+ libgit2_actual_sha256="$(command sha256 -- "$libgit2_tarball" &2 echo "[error] command not found: shasum or sha256sum"
+ exit 1
+fi
+
+if [ "$libgit2_actual_sha256" != "$libgit2_sha256" ]; then
+ >&2 echo "[error] sha256 mismatch"
+ >&2 echo ""
+ >&2 echo " file : deps/libgit2-$libgit2_version.tar.gz"
+ >&2 echo " expected: $libgit2_sha256"
+ >&2 echo " actual : $libgit2_actual_sha256"
+ exit 1
+fi
+
cd -- "$workdir"
-tar -xzf "$libgit2_tarball"
-mv -- libgit2-"$libgit2_version" libgit2
-mkdir libgit2/build
+command tar -xzf "$libgit2_tarball"
+command mv -- libgit2-"$libgit2_version" libgit2
+command mkdir libgit2/build
cd libgit2/build
-CFLAGS="$libgit2_cflags" cmake \
- -DCMAKE_BUILD_TYPE=Release \
- -DZERO_NSEC=ON \
- -DTHREADSAFE=ON \
- -DUSE_BUNDLED_ZLIB=ON \
- -DREGEX_BACKEND=builtin \
- -DUSE_HTTP_PARSER=builtin \
- -DUSE_SSH=OFF \
- -DUSE_HTTPS=OFF \
- -DBUILD_CLAR=OFF \
- -DUSE_GSSAPI=OFF \
- -DUSE_NTLMCLIENT=OFF \
- -DBUILD_SHARED_LIBS=OFF \
- -DENABLE_REPRODUCIBLE_BUILDS=OFF \
- $libgit2_cmake_flags \
+CFLAGS="$libgit2_cflags" command cmake \
+ -DCMAKE_BUILD_TYPE=None \
+ -DZERO_NSEC=ON \
+ -DTHREADSAFE=ON \
+ -DUSE_BUNDLED_ZLIB=ON \
+ -DREGEX_BACKEND=builtin \
+ -DUSE_HTTP_PARSER=builtin \
+ -DUSE_SSH=OFF \
+ -DUSE_HTTPS=OFF \
+ -DBUILD_CLAR=OFF \
+ -DUSE_GSSAPI=OFF \
+ -DUSE_NTLMCLIENT=OFF \
+ -DBUILD_SHARED_LIBS=OFF \
+ -G "Unix Makefiles" \
+ $libgit2_cmake_flags \
..
-make -j "$cpus" VERBOSE=1
+command make -j "$cpus" VERBOSE=1
APPNAME="$appname".tmp \
OBJDIR="$workdir"/gitstatus \
- CXX="$gitstatus_cxx" \
+ CXX="${CXX:-$gitstatus_cxx}" \
CXXFLAGS="$gitstatus_cxxflags" \
LDFLAGS="$gitstatus_ldflags" \
LDLIBS="$gitstatus_ldlibs" \
- "$gitstatus_make" -C "$outdir" -j "$cpus"
+ command "$gitstatus_make" -C "$outdir" -j "$cpus"
app="$outdir"/usrbin/"$appname"
-strip "$app".tmp
+command strip "$app".tmp
-mkdir -- "$workdir"/repo
-git -C "$workdir"/repo init --
-git -C "$workdir"/repo config user.email "you@example.com"
-git -C "$workdir"/repo commit --allow-empty --allow-empty-message -m ''
+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 ''
+)
resp="$(printf "hello\037$workdir/repo\036" | "$app".tmp)"
-[ -n "$resp" -a -z "${resp##hello*1*$workdir/repo*master*}" ]
+case "$resp" in
+ hello*1*/repo*master*);;
+ *)
+ >&2 echo 'error: invalid gitstatusd response for a git repo'
+ exit 1
+ ;;
+esac
resp="$(printf 'hello\037\036' | "$app".tmp)"
-[ -n "$resp" -a -z "${resp##hello*0*}" ]
+case "$resp" in
+ hello*0*);;
+ *)
+ >&2 echo 'error: invalid gitstatusd response for a non-repo'
+ exit 1
+ ;;
+esac
-mv -f -- "$app".tmp "$app"
+command mv -f -- "$app".tmp "$app"
cleanup
-cat >&2 <<-END
+command cat >&2 <<-END
-------------------------------------------------
SUCCESS: created usrbin/$appname
END
@@ -328,10 +545,17 @@ fi
if [ -z "$gitstatus_cpu" ]; then
case "$gitstatus_arch" in
- armv6l) gitstatus_cpu=armv6;;
+ armel) gitstatus_cpu=armv5;;
+ armv6l|armhf) gitstatus_cpu=armv6;;
armv7l) gitstatus_cpu=armv7;;
- aarch64) gitstatus_cpu=armv8-a;;
+ arm64|aarch64) gitstatus_cpu=armv8-a;;
+ ppc64|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;;
+ e2k) gitstatus_cpu=native;;
i386|i586|i686) gitstatus_cpu="$gitstatus_arch";;
*)
>&2 echo '[error] unable to infer target CPU architecture'
@@ -360,11 +584,13 @@ case "$gitstatus_kernel" in
fi
if [ -z "$docker_image" ]; then
case "$gitstatus_arch" in
- 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;;
+ 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;;
*)
>&2 echo '[error] unable to infer docker image'
>&2 echo 'Please specify explicitly with `-i IMAGE`.'
@@ -372,12 +598,9 @@ case "$gitstatus_kernel" in
;;
esac
fi
- elif [ -n "$gitstatus_install_tools" ]; then
- >&2 echo '[error] -s without -d is not supported on linux'
- exit 1
fi
;;
- freebsd|netbsd|darwin)
+ freebsd|openbsd|netbsd|darwin|dragonfly)
if [ -n "$docker_cmd" ]; then
>&2 echo "[error] docker (-d) is not supported on $gitstatus_kernel"
exit 1
@@ -428,6 +651,8 @@ fi
if [ -n "$docker_cmd" ]; then
"$docker_cmd" run \
+ -e docker_cmd="$docker_cmd" \
+ -e docker_image="$docker_image" \
-e gitstatus_kernel="$gitstatus_kernel" \
-e gitstatus_arch="$gitstatus_arch" \
-e gitstatus_cpu="$gitstatus_cpu" \
diff --git a/gitstatus/build.info b/gitstatus/build.info
index b38192c5..9bc9411d 100644
--- a/gitstatus/build.info
+++ b/gitstatus/build.info
@@ -2,11 +2,11 @@
# read by ./Makefile. `gitstatusd --version` reports it back.
#
# This value is also read by shell bindings (indirectly, through
-# ./install) when gitstatusd is from ./usrbin.
-gitstatus_version="v1.0.0"
+# ./install) when using GITSTATUS_DAEMON or usrbin/gitstatusd.
+gitstatus_version="v1.5.5"
-# libgit2 is a build time dependency of gitstatusd. The value of
-# libgit2_version is read by ./build.
+# libgit2 is a build time dependency of gitstatusd. The values of
+# libgit2_version and libgit2_sha256 are read by ./build.
#
# If ./deps/libgit2-${libgit2_version}.tar.gz doesn't exist, build
# downloads it from the following location:
@@ -15,4 +15,8 @@ gitstatus_version="v1.0.0"
#
# Once downloaded, the tarball is stored at the path indicated
# above so that repeated builds don't consume network bandwidth.
-libgit2_version="tag-005f77dca6dbe8788e55139fa1199fc94cc04f9a"
+#
+# If sha256 of ./deps/libgit2-${libgit2_version}.tar.gz doesn't match,
+# build gets aborted.
+libgit2_version="tag-2ecf33948a4df9ef45a66c68b8ef24a5e60eaac6"
+libgit2_sha256="4ce11d71ee576dbbc410b9fa33a9642809cc1fa687b315f7c23eeb825b251e93"
diff --git a/gitstatus/gitstatus.plugin.sh b/gitstatus/gitstatus.plugin.sh
index 7385defa..bfe16dc2 100644
--- a/gitstatus/gitstatus.plugin.sh
+++ b/gitstatus/gitstatus.plugin.sh
@@ -35,12 +35,27 @@
#
# -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"
+ >&2 printf '\n'
+ >&2 printf 'To see the version of the current shell, type:\n'
+ >&2 printf '\n'
+ >&2 printf ' \033[32mecho\033[0m \033[33m"$BASH_VERSION"\033[0m\n'
+ >&2 printf '\n'
+ >&2 printf 'The output of `\033[32mbash\033[0m --version` may be different and is not relevant.\n'
+ return 1
+ fi
+
unset OPTIND
- local opt timeout=5 max_dirty=-1 extra_flags
+ local opt timeout=5 max_dirty=-1 ttl=3600 extra_flags=
local max_num_staged=1 max_num_unstaged=1 max_num_conflicted=1 max_num_untracked=1
- local ignore_status_show_untracked_files
- while getopts "t:s:u:c:d:m:eUWD" opt; do
+ while getopts "t:s:u:c:d:m:r:eUWD" opt; do
case "$opt" in
t) timeout=$OPTARG;;
s) max_num_staged=$OPTARG;;
@@ -48,6 +63,7 @@ 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 ';;
@@ -69,14 +85,14 @@ function gitstatus_start() {
local gitstatus_plugin_dir="$PWD"
fi
- local req_fifo resp_fifo
+ local tmpdir req_fifo resp_fifo culprit
function gitstatus_start_impl() {
local log_level="${GITSTATUS_LOG_LEVEL:-}"
[[ -n "$log_level" || "${GITSTATUS_ENABLE_LOGGING:-0}" != 1 ]] || log_level=INFO
local uname_sm
- uname_sm="$(uname -sm)" || return
+ uname_sm="$(command uname -sm)" || return
uname_sm="${uname_sm,,}"
local uname_s="${uname_sm% *}"
local uname_m="${uname_sm#* }"
@@ -86,8 +102,8 @@ function gitstatus_start() {
else
local cpus
if ! command -v sysctl &>/dev/null || [[ "$uname_s" == linux ]] ||
- ! cpus="$(sysctl -n hw.ncpu)"; then
- if ! command -v getconf &>/dev/null || ! cpus="$(getconf _NPROCESSORS_ONLN)"; then
+ ! cpus="$(command sysctl -n hw.ncpu)"; then
+ if ! command -v getconf &>/dev/null || ! cpus="$(command getconf _NPROCESSORS_ONLN)"; then
cpus=8
fi
fi
@@ -102,25 +118,36 @@ 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
+
if [[ -n "$log_level" ]]; then
- GITSTATUS_DAEMON_LOG=$(mktemp "${TMPDIR:-/tmp}"/gitstatus.$$.log.XXXXXXXXXX) || return
+ GITSTATUS_DAEMON_LOG="$tmpdir"/daemon.log
[[ "$log_level" == INFO ]] || daemon_args+=(--log-level="$log_level")
else
GITSTATUS_DAEMON_LOG=/dev/null
fi
- req_fifo=$(mktemp -u "${TMPDIR:-/tmp}"/gitstatus.$$.pipe.req.XXXXXXXXXX) || return
- resp_fifo=$(mktemp -u "${TMPDIR:-/tmp}"/gitstatus.$$.pipe.resp.XXXXXXXXXX) || return
- mkfifo "$req_fifo" "$resp_fifo" || return
+ req_fifo="$tmpdir"/req.fifo
+ resp_fifo="$tmpdir"/resp.fifo
+ command mkfifo -- "$req_fifo" "$resp_fifo" || return
{
(
+ trap '' INT QUIT TSTP
+ [[ "$GITSTATUS_DAEMON_LOG" == /dev/null ]] || set -x
builtin cd /
+
(
local fd_in fd_out
- exec {fd_in}<"$req_fifo" {fd_out}>"$resp_fifo" || exit
+ exec {fd_in}<"$req_fifo" {fd_out}>>"$resp_fifo" || exit
echo "$BASHPID" >&"$fd_out"
local _gitstatus_bash_daemon _gitstatus_bash_version _gitstatus_bash_downloaded
@@ -131,17 +158,28 @@ function gitstatus_start() {
_gitstatus_bash_downloaded="$3"
}
- set -- -d "$gitstatus_plugin_dir" -s "$uname_s" -m "$uname_m" -- _gitstatus_set_daemon
+ set -- -d "$gitstatus_plugin_dir" -s "$uname_s" -m "$uname_m" \
+ -p "printf '.\036' >&$fd_out" -e "$fd_out" -- _gitstatus_set_daemon
[[ "${GITSTATUS_AUTO_INSTALL:-1}" -ne 0 ]] || set -- -n "$@"
source "$gitstatus_plugin_dir"/install || return
[[ -n "$_gitstatus_bash_daemon" ]] || return
[[ -n "$_gitstatus_bash_version" ]] || return
[[ "$_gitstatus_bash_downloaded" == [01] ]] || return
- local sig=(INT QUIT TERM EXIT ILL PIPE)
+ local sig=(TERM ILL PIPE)
+
+ if (( UID == EUID )); then
+ local home=~
+ else
+ local user
+ user="$(command id -un)" || return
+ [[ "$user" =~ ^[a-zA-Z0-9_,.-]+$ ]] || return
+ eval "local home=~$user"
+ [[ -n "$home" ]] || return
+ fi
if [[ -x "$_gitstatus_bash_daemon" ]]; then
- "$_gitstatus_bash_daemon" \
+ HOME="$home" "$_gitstatus_bash_daemon" \
-G "$_gitstatus_bash_version" "${daemon_args[@]}" <&"$fd_in" >&"$fd_out" &
local pid=$!
trap "trap - ${sig[*]}; kill $pid &>/dev/null" ${sig[@]}
@@ -149,8 +187,8 @@ function gitstatus_start() {
local ret=$?
trap - ${sig[@]}
case "$ret" in
- 0|129|130|131|137|141|143)
- echo -nE $'bye\x1f0\x1e' >&"$fd_out"
+ 0|129|130|131|137|141|143|159)
+ echo -nE $'}bye\x1f0\x1e' >&"$fd_out"
exit "$ret"
;;
esac
@@ -158,43 +196,78 @@ function gitstatus_start() {
(( ! _gitstatus_bash_downloaded )) || return
[[ "${GITSTATUS_AUTO_INSTALL:-1}" -ne 0 ]] || return
+ [[ "$_gitstatus_bash_daemon" == \
+ "${GITSTATUS_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/gitstatus}"/* ]] || return
+
set -- -f "$@"
_gitstatus_bash_daemon=
_gitstatus_bash_version=
_gitstatus_bash_downloaded=
- source "$gitstatus_plugin_dir"/install || return
+ source "$gitstatus_plugin_dir"/install || return
[[ -n "$_gitstatus_bash_daemon" ]] || return
[[ -n "$_gitstatus_bash_version" ]] || return
[[ "$_gitstatus_bash_downloaded" == 1 ]] || return
- "$_gitstatus_bash_daemon" \
+ HOME="$home" "$_gitstatus_bash_daemon" \
-G "$_gitstatus_bash_version" "${daemon_args[@]}" <&"$fd_in" >&"$fd_out" &
local pid=$!
trap "trap - ${sig[*]}; kill $pid &>/dev/null" ${sig[@]}
wait "$pid"
trap - ${sig[@]}
- echo -nE $'bye\x1f0\x1e' >&"$fd_out"
- ) &
- ) & disown
- } 0/dev/null
+ echo -nE $'}bye\x1f0\x1e' >&"$fd_out"
+ ) & disown
+ ) & disown
+ } 0"$GITSTATUS_DAEMON_LOG"
- exec {_GITSTATUS_REQ_FD}>"$req_fifo" {_GITSTATUS_RESP_FD}<"$resp_fifo" || return
- command rm "$req_fifo" "$resp_fifo" || return
+ exec {_GITSTATUS_REQ_FD}>>"$req_fifo" {_GITSTATUS_RESP_FD}<"$resp_fifo" || return
+ command rm -f -- "$req_fifo" "$resp_fifo" || return
+ [[ "$GITSTATUS_DAEMON_LOG" != /dev/null ]] || command rmdir -- "$tmpdir" 2>/dev/null
IFS='' read -r -u $_GITSTATUS_RESP_FD GITSTATUS_DAEMON_PID || return
- [[ $GITSTATUS_DAEMON_PID == [1-9]* ]] || return
+ [[ "$GITSTATUS_DAEMON_PID" == [1-9]* ]] || return
local reply
- echo -nE $'hello\x1f\x1e' >&$_GITSTATUS_REQ_FD || return
- IFS='' read -rd $'\x1e' -u $_GITSTATUS_RESP_FD -t "$timeout" reply || return
- [[ "$reply" == $'hello\x1f0' ]] || return
+ echo -nE $'}hello\x1f\x1e' >&$_GITSTATUS_REQ_FD || return
+ local dl=
+ while true; do
+ reply=
+ if ! IFS='' read -rd $'\x1e' -u $_GITSTATUS_RESP_FD -t "$timeout" reply; then
+ culprit="$reply"
+ return 1
+ fi
+ [[ "$reply" == $'}hello\x1f0' ]] && break
+ if [[ -z "$dl" ]]; then
+ dl=1
+ if [[ -t 2 ]]; then
+ local spinner=('\b\033[33m-\033[0m' '\b\033[33m\\\033[0m' '\b\033[33m|\033[0m' '\b\033[33m/\033[0m')
+ >&2 printf '[\033[33mgitstatus\033[0m] fetching \033[32mgitstatusd\033[0m .. '
+ else
+ local spinner=('.')
+ >&2 printf '[gitstatus] fetching gitstatusd ..'
+ fi
+ fi
+ >&2 printf "${spinner[0]}"
+ spinner=("${spinner[@]:1}" "${spinner[0]}")
+ done
+
+ if [[ -n "$dl" ]]; then
+ if [[ -t 2 ]]; then
+ >&2 printf '\b[\033[32mok\033[0m]\n'
+ else
+ >&2 echo ' [ok]'
+ fi
+ fi
_GITSTATUS_DIRTY_MAX_INDEX_SIZE=$max_dirty
_GITSTATUS_CLIENT_PID="$BASHPID"
}
if ! gitstatus_start_impl; then
- echo "gitstatus_start: failed to start gitstatusd" >&2
+ >&2 printf '\n'
+ >&2 printf '[\033[31mERROR\033[0m]: gitstatus failed to initialize.\n'
+ if [[ -n "${culprit-}" ]]; then
+ >&2 printf '\n%s\n' "$culprit"
+ fi
[[ -z "${req_fifo:-}" ]] || command rm -f "$req_fifo"
[[ -z "${resp_fifo:-}" ]] || command rm -f "$resp_fifo"
unset -f gitstatus_start_impl
@@ -202,54 +275,22 @@ 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() {
- [[ "${_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 "$@"; }
+ 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
fi
- unset _GITSTATUS_REQ_FD _GITSTATUS_RESP_FD GITSTATUS_DAEMON_PID _GITSTATUS_EXEC_HOOK
+ unset _GITSTATUS_REQ_FD _GITSTATUS_RESP_FD GITSTATUS_DAEMON_PID
unset _GITSTATUS_DIRTY_MAX_INDEX_SIZE _GITSTATUS_CLIENT_PID
}
-# Retrives status of a git repository from a directory under its working tree.
+# Retrieves status of a git repository from a directory under its working tree.
#
# Usage: gitstatus_query [OPTION]...
#
@@ -270,6 +311,8 @@ 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.
@@ -317,7 +360,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;;
@@ -328,7 +371,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
@@ -373,6 +416,8 @@ 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
@@ -415,6 +460,8 @@ 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 5dc8d737..b74396d3 100644
--- a/gitstatus/gitstatus.plugin.zsh
+++ b/gitstatus/gitstatus.plugin.zsh
@@ -15,6 +15,8 @@
# 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
@@ -57,7 +59,7 @@ zmodload -F zsh/files b:zf_rm || return
typeset -g _gitstatus_plugin_dir"${1:-}"="${${(%):-%x}:A:h}"
-# Retrives status of a git repo from a directory under its working tree.
+# Retrieves status of a git repo from a directory under its working tree.
#
## Usage: gitstatus_query [OPTION]... NAME
#
@@ -88,6 +90,8 @@ 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.
@@ -168,22 +172,40 @@ function gitstatus_query"${1:-}"() {
done
if (( OPTIND != ARGC )); then
- print -ru2 -- "gitstatus_start: exactly one positional argument is required"
+ print -ru2 -- "gitstatus_query: exactly one positional argument is required"
return 1
fi
local name=$*[OPTIND]
if [[ $name != [[:IDENT:]]## ]]; then
- print -ru2 -- "gitstatus_start: invalid positional argument: $name"
+ print -ru2 -- "gitstatus_query: invalid positional argument: $name"
return 1
fi
(( _GITSTATUS_STATE_$name == 2 )) || return
if [[ -z $GIT_DIR ]]; then
- [[ $dir == /* ]] || dir=${(%):-%/}/$dir
+ if [[ $dir != /* ]]; then
+ if [[ $PWD == /* && $PWD -ef . ]]; then
+ dir=$PWD/$dir
+ else
+ dir=${dir:a}
+ fi
+ fi
else
- [[ $GIT_DIR == /* ]] && dir=:$GIT_DIR || dir=:${(%):-%/}/$GIT_DIR
+ if [[ $GIT_DIR == /* ]]; then
+ dir=:$GIT_DIR
+ elif [[ $PWD == /* && $PWD -ef . ]]; then
+ dir=:$PWD/$GIT_DIR
+ else
+ dir=:${GIT_DIR:a}
+ fi
+ fi
+
+ if [[ $dir != (|:)/* ]]; then
+ typeset -g VCS_STATUS_RESULT=norepo-sync
+ _gitstatus_clear$fsuf
+ return 0
fi
local -i req_fd=${(P)${:-_GITSTATUS_REQ_FD_$name}}
@@ -323,7 +345,9 @@ 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 in "${(@)resp[3,27]}"; do
+ VCS_STATUS_NUM_ASSUME_UNCHANGED \
+ VCS_STATUS_COMMIT_ENCODING \
+ VCS_STATUS_COMMIT_SUMMARY in "${(@)resp[3,29]}"; 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))
@@ -365,8 +389,8 @@ function _gitstatus_daemon"${1:-}"() {
trap '' PIPE
local uname_sm
- uname_sm="${(L)$(uname -sm)}" || return
- [[ $uname_sm == [^' ']##' '[^' ']## ]] || return
+ uname_sm="${${(L)$(command uname -sm)}//ฤฑ/i}" || return
+ [[ $uname_sm == [^' ']##' '[^' ']## ]] || return
local uname_s=${uname_sm% *}
local uname_m=${uname_sm#* }
@@ -375,14 +399,19 @@ function _gitstatus_daemon"${1:-}"() {
else
local cpus
if (( ! $+commands[sysctl] )) || [[ $uname_s == linux ]] ||
- ! cpus="$(sysctl -n hw.ncpu)"; then
- if (( ! $+commands[getconf] )) || ! cpus="$(getconf _NPROCESSORS_ONLN)"; then
+ ! cpus="$(command sysctl -n hw.ncpu)"; then
+ if (( ! $+commands[getconf] )) || ! cpus="$(command getconf _NPROCESSORS_ONLN)"; then
cpus=8
fi
fi
args+=(-t $((cpus > 16 ? 32 : cpus > 0 ? 2 * cpus : 16)))
fi
+ command mkfifo -- $file_prefix.fifo || return
+ print -rnu $pipe_fd -- ${(l:20:)pgid} || return
+ exec <$file_prefix.fifo || return
+ zf_rm -- $file_prefix.fifo || return
+
local _gitstatus_zsh_daemon _gitstatus_zsh_version _gitstatus_zsh_downloaded
function _gitstatus_set_daemon$fsuf() {
@@ -393,36 +422,44 @@ function _gitstatus_daemon"${1:-}"() {
local gitstatus_plugin_dir_var=_gitstatus_plugin_dir$fsuf
local gitstatus_plugin_dir=${(P)gitstatus_plugin_dir_var}
- set -- -d $gitstatus_plugin_dir -s $uname_s -m $uname_m -- _gitstatus_set_daemon$fsuf
- [[ ${GITSTATUS_AUTO_INSTALL:-1} == (|-|+)<1-> ]] || set -- -n "$@"
- source $gitstatus_plugin_dir/install || return
- [[ -n $_gitstatus_zsh_daemon ]] || return
- [[ -n $_gitstatus_zsh_version ]] || return
- [[ $_gitstatus_zsh_downloaded == [01] ]] || return
+ builtin set -- -d $gitstatus_plugin_dir -s $uname_s -m $uname_m \
+ -p "printf '\\001' >&$pipe_fd" -e $pipe_fd -- _gitstatus_set_daemon$fsuf
+ [[ ${GITSTATUS_AUTO_INSTALL:-1} == (|-|+)<1-> ]] || builtin set -- -n "$@"
+ builtin source $gitstatus_plugin_dir/install || return
+ [[ -n $_gitstatus_zsh_daemon ]] || return
+ [[ -n $_gitstatus_zsh_version ]] || return
+ [[ $_gitstatus_zsh_downloaded == [01] ]] || return
- mkfifo -- $file_prefix.fifo || return
- print -rnu $pipe_fd -- ${(l:20:)pgid} || return
- exec <$file_prefix.fifo || return
- zf_rm -- $file_prefix.fifo || return
+ if (( UID == EUID )); then
+ local home=~
+ else
+ local user
+ user="$(command id -un)" || return
+ local home=${userdirs[$user]}
+ [[ -n $home ]] || return
+ fi
if [[ -x $_gitstatus_zsh_daemon ]]; then
- $_gitstatus_zsh_daemon -G $_gitstatus_zsh_version "${(@)args}" >&$pipe_fd
+ HOME=$home $_gitstatus_zsh_daemon -G $_gitstatus_zsh_version "${(@)args}" >&$pipe_fd
local -i ret=$?
- [[ $ret == (0|129|130|131|137|141|143) ]] && return ret
+ [[ $ret == (0|129|130|131|137|141|143|159) ]] && return ret
fi
(( ! _gitstatus_zsh_downloaded )) || return
[[ ${GITSTATUS_AUTO_INSTALL:-1} == (|-|+)<1-> ]] || return
- set -- -f "$@"
+ [[ $_gitstatus_zsh_daemon == \
+ ${GITSTATUS_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/gitstatus}/* ]] || return
+
+ builtin set -- -f "$@"
_gitstatus_zsh_daemon=
_gitstatus_zsh_version=
_gitstatus_zsh_downloaded=
- source $gitstatus_plugin_dir/install || return
- [[ -n $_gitstatus_zsh_daemon ]] || return
- [[ -n $_gitstatus_zsh_version ]] || return
- [[ $_gitstatus_zsh_downloaded == 1 ]] || return
+ builtin source $gitstatus_plugin_dir/install || return
+ [[ -n $_gitstatus_zsh_daemon ]] || return
+ [[ -n $_gitstatus_zsh_version ]] || return
+ [[ $_gitstatus_zsh_downloaded == 1 ]] || return
- $_gitstatus_zsh_daemon -G $_gitstatus_zsh_version "${(@)args}" >&$pipe_fd
+ HOME=$home $_gitstatus_zsh_daemon -G $_gitstatus_zsh_version "${(@)args}" >&$pipe_fd
} always {
local -i ret=$?
zf_rm -f -- $file_prefix.lock $file_prefix.fifo
@@ -433,7 +470,7 @@ function _gitstatus_daemon"${1:-}"() {
(( lock_fd == -1 )) && return
{
- if zsystem flock -- $file_prefix.lock && [[ -e $file_prefix.lock ]]; then
+ if zsystem flock -- $file_prefix.lock && command sleep 5 && [[ -e $file_prefix.lock ]]; then
zf_rm -f -- $file_prefix.lock $file_prefix.fifo
kill -- -$pgid
fi
@@ -503,7 +540,7 @@ function gitstatus_start"${1:-}"() {
args+=(-$opt $OPTARG)
[[ $opt == m ]] && dirty_max_index_size=OPTARG
;;
- e|U|W|D) args+=$opt;;
+ e|U|W|D) args+=-$opt;;
+(e|U|W|D)) args=(${(@)args:#-$opt});;
\?) print -ru2 -- "gitstatus_start: invalid option: $OPTARG" ; return 1;;
:) print -ru2 -- "gitstatus_start: missing required argument: $OPTARG"; return 1;;
@@ -523,209 +560,264 @@ function gitstatus_start"${1:-}"() {
fi
local -i lock_fd resp_fd stderr_fd
- local file_prefix xtrace=/dev/null daemon_log=/dev/null
- if (( _GITSTATUS_STATE_$name )); then
- (( async )) && return
- (( _GITSTATUS_STATE_$name == 2 )) && return
- lock_fd=_GITSTATUS_LOCK_FD_$name
- resp_fd=_GITSTATUS_RESP_FD_$name
- xtrace=${(P)${:-GITSTATUS_XTRACE_$name}}
- daemon_log=${(P)${:-GITSTATUS_DAEMON_LOG_$name}}
- file_prefix=${(P)${:-_GITSTATUS_FILE_PREFIX_$name}}
- else
- typeset -gi _GITSTATUS_START_COUNTER
- local log_level=$GITSTATUS_LOG_LEVEL
- 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
- xtrace=$file_prefix.xtrace.log
- daemon_log=$file_prefix.daemon.log
- fi
- args+=(-v ${log_level:-FATAL})
- typeset -g GITSTATUS_XTRACE_$name=$xtrace
- typeset -g GITSTATUS_DAEMON_LOG_$name=$daemon_log
- typeset -g _GITSTATUS_FILE_PREFIX_$name=$file_prefix
- typeset -gi _GITSTATUS_CLIENT_PID_$name="sysparams[pid]"
- typeset -gi _GITSTATUS_DIRTY_MAX_INDEX_SIZE_$name=dirty_max_index_size
- fi
+ local file_prefix xtrace=/dev/null daemon_log=/dev/null culprit
- () {
- if [[ $xtrace != /dev/null && -o no_xtrace ]]; then
- exec {stderr_fd}>&2 || return
- exec 2>>$xtrace || return
- setopt xtrace
- fi
-
- setopt monitor || return
-
- if (( ! _GITSTATUS_STATE_$name )); then
- if [[ -r /proc/version && "$($file_prefix.lock || return
- zsystem flock -f lock_fd $file_prefix.lock || return
- [[ $lock_fd == <1-> ]] || return
+ local tmpdir=/tmp
+ fi
+ local file_prefix=${tmpdir:A}/gitstatus.$name.$EUID
+ file_prefix+=.$sysparams[pid].$EPOCHSECONDS.$((++_GITSTATUS_START_COUNTER))
+ (( GITSTATUS_ENABLE_LOGGING )) && : ${log_level:=INFO}
+ if [[ -n $log_level ]]; then
+ xtrace=$file_prefix.xtrace.log
+ daemon_log=$file_prefix.daemon.log
+ fi
+ args+=(-v ${log_level:-FATAL})
+ typeset -g GITSTATUS_XTRACE_$name=$xtrace
+ typeset -g GITSTATUS_DAEMON_LOG_$name=$daemon_log
+ typeset -g _GITSTATUS_FILE_PREFIX_$name=$file_prefix
+ typeset -gi _GITSTATUS_CLIENT_PID_$name="sysparams[pid]"
+ typeset -gi _GITSTATUS_DIRTY_MAX_INDEX_SIZE_$name=dirty_max_index_size
+ fi
+
+ () {
+ if [[ $xtrace != /dev/null && -o no_xtrace ]]; then
+ exec {stderr_fd}>&2 || return
+ exec 2>>$xtrace || return
+ setopt xtrace
fi
- typeset -gi _GITSTATUS_LOCK_FD_$name=lock_fd
+ setopt monitor || return
- if [[ -n $USERPROFILE && -d /cygdrive && -d /proc/self/fd ]]; then
- # Work around bugs in Cygwin 32-bit.
- #
- # This hangs:
- #
- # emulate -L zsh
- # () { exec {fd}< $1 } <(:)
- # =true # hangs here
- #
- # This hangs:
- #
- # sysopen -r -u fd <(:)
- local -i fd
- exec {fd}< <(_gitstatus_daemon$fsuf) || return
- {
- [[ -r /proc/self/fd/$fd ]] || return
- sysopen -r -o cloexec -u resp_fd /proc/self/fd/$fd || return
- } always {
- exec {fd} >&- || return
- }
- else
- sysopen -r -o cloexec -u resp_fd <(_gitstatus_daemon$fsuf) || return
- fi
-
- typeset -gi GITSTATUS_DAEMON_PID_$name="${sysparams[procsubstpid]:--1}"
-
- [[ $resp_fd == <1-> ]] || return
- typeset -gi _GITSTATUS_RESP_FD_$name=resp_fd
- typeset -gi _GITSTATUS_STATE_$name=1
- fi
-
- if (( ! async )); then
- (( _GITSTATUS_CLIENT_PID_$name == sysparams[pid] )) || return
-
- local pgid
- while (( $#pgid < 20 )); do
- [[ -t $resp_fd ]]
- sysread -s $((20 - $#pgid)) -t $timeout -i $resp_fd 'pgid[$#pgid+1]' || return
- done
- [[ $pgid == ' '#<1-> ]] || return
- typeset -gi GITSTATUS_DAEMON_PID_$name=pgid
-
- sysopen -w -o cloexec -u req_fd -- $file_prefix.fifo || return
- [[ $req_fd == <1-> ]] || return
- typeset -gi _GITSTATUS_REQ_FD_$name=req_fd
-
- function _gitstatus_process_response_$name-$fsuf() {
- emulate -L zsh -o no_aliases -o extended_glob -o typeset_silent
- local pair=${${(%):-%N}#_gitstatus_process_response_}
- local name=${pair%%-*}
- local fsuf=${pair#*-}
- if (( ARGC == 1 )); then
- _gitstatus_process_response$fsuf $name 0 ''
+ if (( ! _GITSTATUS_STATE_$name )); then
+ if [[ -r /proc/version && "$($file_prefix.lock || return
+ zsystem flock -f lock_fd $file_prefix.lock || return
+ [[ $lock_fd == <1-> ]] || return
fi
- }
- if ! zle -F $resp_fd _gitstatus_process_response_$name-$fsuf; then
- unfunction _gitstatus_process_response_$name-$fsuf
- return 1
+
+ typeset -gi _GITSTATUS_LOCK_FD_$name=lock_fd
+
+ if [[ $OSTYPE == cygwin* && -d /proc/self/fd ]]; then
+ # Work around bugs in Cygwin 32-bit.
+ #
+ # This hangs:
+ #
+ # emulate -L zsh
+ # () { exec {fd}< $1 } <(:)
+ # =true # hangs here
+ #
+ # This hangs:
+ #
+ # sysopen -r -u fd <(:)
+ local -i fd
+ exec {fd}< <(_gitstatus_daemon$fsuf) || return
+ {
+ [[ -r /proc/self/fd/$fd ]] || return
+ sysopen -r -o cloexec -u resp_fd /proc/self/fd/$fd || return
+ } always {
+ exec {fd} >&- || return
+ }
+ else
+ sysopen -r -o cloexec -u resp_fd <(_gitstatus_daemon$fsuf) || return
+ fi
+
+ typeset -gi GITSTATUS_DAEMON_PID_$name="${sysparams[procsubstpid]:--1}"
+
+ [[ $resp_fd == <1-> ]] || return
+ typeset -gi _GITSTATUS_RESP_FD_$name=resp_fd
+ typeset -gi _GITSTATUS_STATE_$name=1
fi
- function _gitstatus_cleanup_$name-$fsuf() {
- emulate -L zsh -o no_aliases -o extended_glob -o typeset_silent
- local pair=${${(%):-%N}#_gitstatus_cleanup_}
- local name=${pair%%-*}
- local fsuf=${pair#*-}
+ if (( ! async )); then
(( _GITSTATUS_CLIENT_PID_$name == sysparams[pid] )) || return
- gitstatus_stop$fsuf $name
- }
- if ! add-zsh-hook zshexit _gitstatus_cleanup_$name-$fsuf; then
- unfunction _gitstatus_cleanup_$name-$fsuf
- return 1
+
+ local pgid
+ while (( $#pgid < 20 )); do
+ [[ -t $resp_fd ]]
+ sysread -s $((20 - $#pgid)) -t $timeout -i $resp_fd 'pgid[$#pgid+1]' || return
+ done
+ [[ $pgid == ' '#<1-> ]] || return
+ typeset -gi GITSTATUS_DAEMON_PID_$name=pgid
+
+ sysopen -w -o cloexec -u req_fd -- $file_prefix.fifo || return
+ [[ $req_fd == <1-> ]] || return
+ typeset -gi _GITSTATUS_REQ_FD_$name=req_fd
+
+ print -nru $req_fd -- $'}hello\x1f\x1e' || return
+ local expected=$'}hello\x1f0\x1e' actual
+ if (( $+functions[p10k] )) && [[ ! -t 1 && ! -t 0 ]]; then
+ local -F deadline='EPOCHREALTIME + 4'
+ else
+ local -F deadline='1'
+ fi
+ while true; do
+ [[ -t $resp_fd ]]
+ sysread -s 1 -t $timeout -i $resp_fd actual || return
+ [[ $expected == $actual* ]] && break
+ if [[ $actual != $'\1' ]]; then
+ [[ -t $resp_fd ]]
+ while sysread -t $timeout -i $resp_fd 'actual[$#actual+1]'; do
+ [[ -t $resp_fd ]]
+ done
+ culprit=$actual
+ return 1
+ fi
+ (( EPOCHREALTIME < deadline )) && continue
+ if (( deadline > 0 )); then
+ deadline=0
+ if (( stderr_fd )); then
+ unsetopt xtrace
+ exec 2>&$stderr_fd {stderr_fd}>&-
+ stderr_fd=0
+ fi
+ if (( $+functions[p10k] )); then
+ p10k clear-instant-prompt || return
+ fi
+ if [[ $name == POWERLEVEL9K ]]; then
+ local label=powerlevel10k
+ else
+ local label=gitstatus
+ fi
+ if [[ -t 2 ]]; then
+ local spinner=($'\b%3F-%f' $'\b%3F\\%f' $'\b%3F|%f' $'\b%3F/%f')
+ print -Prnu2 -- "[%3F$label%f] fetching %2Fgitstatusd%f .. "
+ else
+ local spinner=('.')
+ print -rnu2 -- "[$label] fetching gitstatusd .."
+ fi
+ fi
+ print -Prnu2 -- $spinner[1]
+ spinner=($spinner[2,-1] $spinner[1])
+ done
+
+ if (( deadline == 0 )); then
+ if [[ -t 2 ]]; then
+ print -Pru2 -- $'\b[%2Fok%f]'
+ else
+ print -ru2 -- ' [ok]'
+ fi
+ if [[ $xtrace != /dev/null && -o no_xtrace ]]; then
+ exec {stderr_fd}>&2 || return
+ exec 2>>$xtrace || return
+ setopt xtrace
+ fi
+ fi
+
+ while (( $#actual < $#expected )); do
+ [[ -t $resp_fd ]]
+ sysread -s $(($#expected - $#actual)) -t $timeout -i $resp_fd 'actual[$#actual+1]' || return
+ done
+ [[ $actual == $expected ]] || return
+
+ function _gitstatus_process_response_$name-$fsuf() {
+ emulate -L zsh -o no_aliases -o extended_glob -o typeset_silent
+ local pair=${${(%):-%N}#_gitstatus_process_response_}
+ local name=${pair%%-*}
+ local fsuf=${pair#*-}
+ [[ $name == POWERLEVEL9K && $fsuf == _p9k_ ]] && eval $__p9k_intro_base
+ if (( ARGC == 1 )); then
+ _gitstatus_process_response$fsuf $name 0 ''
+ else
+ gitstatus_stop$fsuf $name
+ fi
+ }
+ if ! zle -F $resp_fd _gitstatus_process_response_$name-$fsuf; then
+ unfunction _gitstatus_process_response_$name-$fsuf
+ return 1
+ fi
+
+ function _gitstatus_cleanup_$name-$fsuf() {
+ emulate -L zsh -o no_aliases -o extended_glob -o typeset_silent
+ local pair=${${(%):-%N}#_gitstatus_cleanup_}
+ local name=${pair%%-*}
+ local fsuf=${pair#*-}
+ (( _GITSTATUS_CLIENT_PID_$name == sysparams[pid] )) || return
+ gitstatus_stop$fsuf $name
+ }
+ if ! add-zsh-hook zshexit _gitstatus_cleanup_$name-$fsuf; then
+ unfunction _gitstatus_cleanup_$name-$fsuf
+ return 1
+ fi
+
+ if (( lock_fd != -1 )); then
+ zf_rm -- $file_prefix.lock || return
+ zsystem flock -u $lock_fd || return
+ fi
+ unset _GITSTATUS_LOCK_FD_$name
+
+ typeset -gi _GITSTATUS_STATE_$name=2
fi
+ }
+ } always {
+ local -i err=$?
+ (( stderr_fd )) && exec 2>&$stderr_fd {stderr_fd}>&-
+ (( err == 0 )) && return
- print -nru $req_fd -- $'hello\x1f\x1e' || return
- local expected=$'hello\x1f0\x1e' actual
- while (( $#actual < $#expected )); do
- [[ -t $resp_fd ]]
- sysread -s $(($#expected - $#actual)) -t $timeout -i $resp_fd 'actual[$#actual+1]' || return
- done
- [[ $actual == $expected ]] || return
+ gitstatus_stop$fsuf $name
- if (( lock_fd != -1 )); then
- zf_rm -- $file_prefix.lock || return
- zsystem flock -u $lock_fd || return
- fi
- unset _GITSTATUS_LOCK_FD_$name
-
- typeset -gi _GITSTATUS_STATE_$name=2
+ setopt prompt_percent no_prompt_subst no_prompt_bang
+ (( $+functions[p10k] )) && p10k clear-instant-prompt
+ print -ru2 -- ''
+ print -Pru2 -- '[%F{red}ERROR%f]: gitstatus failed to initialize.'
+ print -ru2 -- ''
+ if [[ -n $culprit ]]; then
+ print -ru2 -- $culprit
+ return err
+ fi
+ if [[ -s $xtrace ]]; then
+ print -ru2 -- ''
+ print -Pru2 -- " Zsh log (%U${xtrace//\%/%%}%u):"
+ print -Pru2 -- '%F{yellow}'
+ print -lru2 -- "${(@)${(@f)$(<$xtrace)}/#/ }"
+ print -Pnru2 -- '%f'
+ fi
+ if [[ -s $daemon_log ]]; then
+ print -ru2 -- ''
+ print -Pru2 -- " Daemon log (%U${daemon_log//\%/%%}%u):"
+ print -Pru2 -- '%F{yellow}'
+ print -lru2 -- "${(@)${(@f)$(<$daemon_log)}/#/ }"
+ print -Pnru2 -- '%f'
+ fi
+ if [[ $GITSTATUS_LOG_LEVEL == DEBUG ]]; then
+ print -ru2 -- ''
+ print -ru2 -- ' System information:'
+ print -Pru2 -- '%F{yellow}'
+ print -ru2 -- " zsh: $ZSH_VERSION"
+ print -ru2 -- " uname -a: $(command uname -a)"
+ print -Pru2 -- '%f'
+ print -ru2 -- ' If you need help, open an issue and attach this whole error message to it:'
+ print -ru2 -- ''
+ print -Pru2 -- ' %Uhttps://github.com/romkatv/gitstatus/issues/new%u'
+ else
+ print -ru2 -- ''
+ local home=~
+ local zshrc=${${${(q)${ZDOTDIR:-~}}/#${(q)home}/'~'}//\%/%%}/.zshrc
+ print -Pru2 -- " Add the following parameter to %U$zshrc%u for extra diagnostics on error:"
+ print -ru2 -- ''
+ print -Pru2 -- ' %BGITSTATUS_LOG_LEVEL=DEBUG%b'
+ print -ru2 -- ''
+ print -ru2 -- ' Restart Zsh to retry gitstatus initialization:'
+ print -ru2 -- ''
+ print -Pru2 -- ' %F{green}%Uexec%u zsh%f'
fi
}
-
- local -i err=$?
- (( stderr_fd )) && exec 2>&$stderr_fd {stderr_fd}>&-
- (( err == 0 )) && return
-
- gitstatus_stop$fsuf $name
-
- setopt prompt_percent no_prompt_subst no_prompt_bang
- print -Pru2 -- '[%F{red}ERROR%f]: gitstatus failed to initialize.'
- print -ru2 -- ''
- print -ru2 -- ' Your Git prompt may disappear or become slow.'
- if [[ -s $xtrace ]]; then
- print -ru2 -- ''
- print -ru2 -- " The content of ${(q-)xtrace} (gitstatus_start xtrace):"
- print -Pru2 -- '%F{yellow}'
- >&2 awk '{print " " $0}' <$xtrace
- print -Pru2 -- "%F{red} ^ this command failed ($err)%f"
- fi
- if [[ -s $daemon_log ]]; then
- print -ru2 -- ''
- print -ru2 -- " The content of ${(q-)daemon_log} (gitstatus daemon log):"
- print -Pru2 -- '%F{yellow}'
- >&2 awk '{print " " $0}' <$daemon_log
- print -Pnru2 -- '%f'
- fi
- if [[ $GITSTATUS_LOG_LEVEL == DEBUG ]]; then
- print -ru2 -- ''
- print -ru2 -- ' Your system information:'
- print -Pru2 -- '%F{yellow}'
- print -ru2 -- " zsh: $ZSH_VERSION"
- print -ru2 -- " uname -a: $(uname -a)"
- print -Pru2 -- '%f'
- print -ru2 -- ' If you need help, open an issue and attach this whole error message to it:'
- print -ru2 -- ''
- print -Pru2 -- ' %F{green}https://github.com/romkatv/gitstatus/issues/new%f'
- else
- print -ru2 -- ''
- print -ru2 -- ' Run the following command to retry with extra diagnostics:'
- print -Pru2 -- '%F{green}'
- local env="GITSTATUS_LOG_LEVEL=DEBUG"
- if [[ -n $GITSTATUS_NUM_THREADS ]]; then
- env+=" GITSTATUS_NUM_THREADS=${(q)GITSTATUS_NUM_THREADS}"
- fi
- if [[ -n $GITSTATUS_DAEMON ]]; then
- env+=" GITSTATUS_DAEMON=${(q)GITSTATUS_DAEMON}"
- fi
- if [[ -n $GITSTATUS_AUTO_INSTALL ]]; then
- env+=" GITSTATUS_AUTO_INSTALL=${(q)GITSTATUS_AUTO_INSTALL}"
- fi
- if [[ -n $GITSTATUS_CACHE_DIR ]]; then
- env+=" GITSTATUS_CACHE_DIR=${(q)GITSTATUS_CACHE_DIR}"
- fi
- print -nru2 -- " ${env} gitstatus_start ${(@q-)*}"
- print -Pru2 -- '%f'
- print -ru2 -- ''
- local zshrc=${(D)ZDOTDIR:-~}/.zshrc
- print -ru2 -- " If this command produces no output, add the following parameter to $zshrc:"
- print -ru2 -- ''
- print -Pru2 -- '%F{green} GITSTATUS_LOG_LEVEL=DEBUG%f'
- print -ru2 -- ''
- print -ru2 -- ' With this parameter gitstatus will print additional information on error.'
- fi
-
- return err
}
# Stops gitstatusd if it's running.
diff --git a/gitstatus/gitstatus.prompt.sh b/gitstatus/gitstatus.prompt.sh
index b2c67c8d..f54c11ac 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=$'\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 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 p
@@ -85,7 +85,15 @@ 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.
-PROMPT_COMMAND=gitstatus_prompt_update
+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
# Enable promptvars so that ${GITSTATUS_PROMPT} in PS1 is expanded.
shopt -s promptvars
@@ -94,7 +102,7 @@ shopt -s promptvars
#
# Example:
#
-# user@host ~/projects/skynet master+!
+# user@host ~/projects/skynet master โก42
# $ โ
PS1='\[\033[01;32m\]\u@\h\[\033[00m\] ' # green user@host
PS1+='\[\033[01;34m\]\w\[\033[00m\]' # blue current working directory
diff --git a/gitstatus/install b/gitstatus/install
index 464ab821..76f339e0 100755
--- a/gitstatus/install
+++ b/gitstatus/install
@@ -2,6 +2,12 @@
#
# This script does not have a stable API.
+_gitstatus_install_daemon_found() {
+ local installed="$1"
+ shift
+ [ $# = 0 ] || "$@" "$daemon" "$version" "$installed"
+}
+
_gitstatus_install_main() {
if [ -n "${ZSH_VERSION:-}" ]; then
emulate -L sh -o no_unset
@@ -9,17 +15,17 @@ _gitstatus_install_main() {
set -u
fi
- local argv1=$1
+ local argv1="$1"
shift
- local no_check= no_install= uname_s= uname_m= gitstatus_dir=
+ local no_check= no_install= uname_s= uname_m= gitstatus_dir= dl_status= e=
local opt= OPTARG= OPTIND=1
- while getopts ':s:m:d:fnh' opt "$@"; do
+ while getopts ':s:m:d:p:e:fnh' opt "$@"; do
case "$opt" in
h)
command cat <<\END
-Usage: install [-s KERNEL] [-m ARCH] [-d DIR] [-f|-n] [-- CMD [ARG]...]
+Usage: install [-s KERNEL] [-m ARCH] [-d DIR] [-p CMD] [-e ERRFD] [-f|-n] [-- CMD [ARG]...]
If positional arguments are specified, call this on success:
@@ -35,6 +41,8 @@ Options:
-s KERNEL use this instead of lowercase `uname -s`
-m ARCH use this instead of lowercase `uname -m`
-d DIR use this instead of `dirname "$0"`
+ -p CMD eval this every second while downloading gitstatusd
+ -e ERRFD write error messages to this file descriptor
-f download gitstatusd even if there is one locally
-n do not download gitstatusd (fail instead)
END
@@ -65,6 +73,28 @@ END
fi
gitstatus_dir="$OPTARG"
;;
+ p)
+ if [ -n "$dl_status" ]; then
+ >&2 echo "[gitstatus] error: duplicate option: -$opt"
+ return 1
+ fi
+ if [ -z "$OPTARG" ]; then
+ >&2 echo "[error] incorrect value of -$opt: $OPTARG"
+ return 1
+ fi
+ dl_status="$OPTARG"
+ ;;
+ e)
+ if [ -n "$e" ]; then
+ >&2 echo "[gitstatus] error: duplicate option: -$opt"
+ return 1
+ fi
+ if [ -z "$OPTARG" ]; then
+ >&2 echo "[error] incorrect value of -$opt: $OPTARG"
+ return 1
+ fi
+ e="$OPTARG"
+ ;;
m)
if [ -n "$uname_m" ]; then
>&2 echo "[gitstatus] error: duplicate option: -$opt"
@@ -95,6 +125,7 @@ END
shift "$((OPTIND - 1))"
+ : "${e:=2}"
: "${gitstatus_dir:=$argv1}"
if [ -n "$no_check" -a -n "$no_install" ]; then
@@ -119,14 +150,8 @@ END
>&2 echo "[gitstatus] error: GITSTATUS_DAEMON is not absolute path: $daemon"
return 1
fi
- if [ -z "$daemon" ]; then
+ if [ -z "$daemon" -a -e "$gitstatus_dir"/usrbin/gitstatusd ]; then
daemon="$gitstatus_dir"/usrbin/gitstatusd
- if [ ! -e "$daemon" ]; then
- daemon="$daemon"-"$uname_s"-"$uname_m"
- if [ ! -e "$daemon" ]; then
- daemon=
- fi
- fi
fi
if [ -n "$daemon" ]; then
local gitstatus_version= libgit2_version=
@@ -138,7 +163,8 @@ END
>&2 echo "[gitstatus] internal error: empty gitstatus_version in build.info"
return 1
fi
- [ $# = 0 ] || "$@" "$daemon" "$gitstatus_version" 0
+ local version="$gitstatus_version"
+ _gitstatus_install_daemon_found 0 "$@"
return
fi
fi
@@ -147,10 +173,14 @@ END
line="${line###*}"
[ -n "$line" ] || continue
- local uname_s_glob= uname_m_glob= file= version=
+ local uname_s_glob= uname_m_glob= file= version= sha256=
eval "$line" || return
- if [ -z "$uname_s_glob" -o -z "$uname_m_glob" -o -z "$file" -o -z "$version" ]; then
+ if [ -z "$uname_s_glob" -o \
+ -z "$uname_m_glob" -o \
+ -z "$file" -o \
+ -z "$version" -o \
+ -z "$sha256" ]; then
>&2 echo "[gitstatus] internal error: invalid install.info line: $line"
return 1
fi
@@ -168,23 +198,13 @@ END
if [ -z "$no_check" ]; then
# Check if a suitable gitstatusd already exists.
- local daemon="$cache_dir"/"$file"
- if [ -e "$daemon" ]; then
- [ $# = 0 ] || "$@" "$daemon" "$version" 0
- return
+ local daemon="$gitstatus_dir"/usrbin/"$file"
+ if [ ! -e "$daemon" ]; then
+ daemon="$cache_dir"/"$file"
+ [ -e "$daemon" ] || daemon=
fi
- daemon="$daemon"-"$uname_s"-"$uname_m"
- if [ -e "$daemon" ]; then
- local gitstatus_version= libgit2_version=
- if ! . "$gitstatus_dir"/build.info; then
- >&2 echo "[gitstatus] internal error: failed to source build.info"
- return 1
- fi
- if [ -z "$gitstatus_version" ]; then
- >&2 echo "[gitstatus] internal error: empty gitstatus_version in build.info"
- return 1
- fi
- [ $# = 0 ] || "$@" "$daemon" "$gitstatus_version" 0
+ if [ -n "$daemon" ]; then
+ _gitstatus_install_daemon_found 0 "$@"
return
fi
fi
@@ -202,63 +222,250 @@ END
>&2 echo "[gitstatus] error: GITSTATUS_CACHE_DIR is not absolute: $cache_dir"
return 1
fi
- [ -d "$cache_dir" ] || mkdir -p -- "$cache_dir" || return
+ if [ ! -d "$cache_dir" ] && ! mkdir -p -- "$cache_dir" || [ ! -w "$cache_dir" ]; then
+ local dir="$cache_dir"
+ while true; do
+ if [ -e "$dir" ]; then
+ if [ ! -d "$dir" ]; then
+ >&"$e" printf 'Not a directory: \033[4;31m%s\033[0m\n' "$dir"
+ >&"$e" printf '\n'
+ >&"$e" printf 'Delete it, then restart your shell.\n'
+ elif [ ! -w "$dir" ]; then
+ >&"$e" printf 'Directory 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
+ break
+ fi
+ if [ "$dir" = / ] || [ "$dir" = . ]; then
+ break
+ fi
+ dir="$(dirname -- "$dir")"
+ done
+ return 1
+ fi
- local url="https://github.com/romkatv/gitstatus/releases/download/$version/$file.tar.gz"
- local archive="$cache_dir"/"$file".tmp.$$.tar.gz
- if command -v curl >/dev/null 2>&1; then
- if ! err="$(command curl -fsSLo "$archive" -- "$url" 2>&1)"; then
- >&2 echo "[gitstatus] error: failed to download gitstatusd: $url"
- >&2 printf "%s" "$err"
- return 1
- fi
- elif command -v wget >/dev/null 2>&1; then
- if ! err="$(command wget -O "$archive" -- "$url" 2>&1)"; then
- >&2 echo "[gitstatus] error: failed to download gitstatusd: $url"
- >&2 printf "%s" "$err"
- return 1
- fi
+ if [ -n "${TMPDIR-}" -a '(' '(' -d "${TMPDIR-}" -a -w "${TMPDIR-}" ')' -o '!' '(' -d /tmp -a -w /tmp ')' ')' ]; then
+ local tmp="$TMPDIR"
else
- >&2 echo "[gitstatus] error: please install curl or wget"
+ local tmp=/tmp
+ fi
+ if ! command -v mktemp >/dev/null 2>&1 ||
+ ! tmpdir="$(command mktemp -d "$tmp"/gitstatus-install.XXXXXXXXXX)"; then
+ tmpdir="$tmp/gitstatus-install.tmp.$$"
+ if ! mkdir -p -- "$tmpdir"; then
+ if [ "$tmp" = /tmp ]; 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"
+ >&"$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"
+ >&"$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"
+ >&"$e" printf '\n'
+ >&"$e" printf 'Make it writable, then restart your shell.\n'
+ fi
+ return 1
+ fi
+ fi
+
+ if ! command -v curl >/dev/null 2>&1 && ! command -v wget >/dev/null 2>&1; then
+ >&"$e" printf 'Please install \033[32mcurl\033[0m or \033[32mwget\033[0m, then restart your shell.\n'
return 1
fi
(
- if [ -n "${ZSH_VERSION:-}" ]; then
- builtin cd -q -- "$cache_dir" || return
- else
- cd -- "$cache_dir" || return
- fi
-
- local old=
- if [ -e "$daemon" ]; then
- local i=1
- while :; do
- old="$daemon"."$i"
- [ -e "$old" ] || break
- i="$((i+1))"
- done
- command mv -f -- "$daemon" "$old" || return
- fi
-
- command tar -xzf "$archive"
- local ret=$?
- command rm -f -- "$archive"
- if [ -n "$old" ]; then
+ run_cmd() {
+ command -v "$1" >/dev/null 2>/dev/null || return 127
+ local trapped= pid die ret
+ trap 'trapped=1' $sig
+ # The only reason for suppressing stderr is that `curl -f` cannot be silenced:
+ # `-s` doesn't work despite what the docs say.
+ command "$@" 2>/dev/null &
+ ret="$?"
if [ "$ret" = 0 ]; then
- command rm -f -- "$old" 2>/dev/null
- else
- command mv -f -- "$old" "$daemon"
+ pid="$!"
+ die="trap - $sig; kill -- $pid 2>/dev/null; wait -- $pid 2>/dev/null; exit 1"
+ trap "$die" $sig
+ [ -z "$trapped" ] || eval "$die"
+ wait -- "$pid" 2>/dev/null
+ ret="$?"
fi
- fi
- exit "$ret"
- ) || return
+ trap - $sig
+ [ -z "$trapped" ] || exit
+ return "$ret"
+ }
- [ $# = 0 ] || "$@" "$daemon" "$version" 1
+ check_sha256() {
+ 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 sleep "$1"; then
+ echo -n >"$tmpdir"/"$1".status
+ return 1
+ fi
+ fi
+ local cmd part url ret
+ for cmd in 'curl -kfsSL' 'wget -qO-' 'curl -q -kfsSL' 'wget --no-config -qO-'; do
+ part=0
+ while true; do
+ if [ "$part" = 2 ]; then
+ ret=1
+ break
+ elif [ "$part" = 0 ]; then
+ url="$2"
+ else
+ url="$2"."$part"
+ fi
+ run_cmd $cmd -- "$url" >>"$tmpdir"/"$1".tar.gz
+ ret="$?"
+ [ "$ret" = 0 ] || break
+ check_sha256 "$1" && break
+ part=$((part+1))
+ done
+ [ "$ret" = 0 ] && break
+ run_cmd rm -f -- "$tmpdir"/"$1".tar.gz && continue
+ ret="$?"
+ break
+ done
+ echo -n >"$tmpdir"/"$1".status
+ return "$ret"
+ }
+
+ local trapped=
+ trap 'trapped=1' $sig
+ fetch 1 "$url1" &
+ local pid1="$!"
+ fetch 2 "$url2" &
+ local pid2="$!"
+
+ local die="trap - $sig; kill -- $pid1 $pid2 2>/dev/null; wait -- $pid1 $pid2 2>/dev/null; exit 1"
+ trap "$die" $sig
+ [ -z "$trapped" ] || eval "$die"
+
+ local n=
+ while true; do
+ [ -z "$dl_status" ] || eval "$dl_status" || eval "$die"
+ if command -v sleep >/dev/null 2>/dev/null; then
+ command sleep 1
+ elif command -v true >/dev/null 2>/dev/null; then
+ command true
+ fi
+ if [ -n "$pid1" -a -e "$tmpdir"/1.status ]; then
+ wait -- "$pid1" 2>/dev/null
+ local ret="$?"
+ pid1=
+ if [ "$ret" = 0 ]; then
+ if [ -n "$pid2" ]; then
+ kill -- "$pid2" 2>/dev/null
+ wait -- "$pid2" 2>/dev/null
+ fi
+ n=1
+ break
+ elif [ -z "$pid2" ]; then
+ break
+ else
+ die="trap - $sig; kill -- $pid2 2>/dev/null; wait -- $pid2 2>/dev/null; exit 1"
+ trap "$die" $sig
+ fi
+ elif [ -n "$pid2" -a -e "$tmpdir"/2.status ]; then
+ wait -- "$pid2" 2>/dev/null
+ local ret="$?"
+ pid2=
+ if [ "$ret" = 0 ]; then
+ if [ -n "$pid1" ]; then
+ kill -- "$pid1" 2>/dev/null
+ wait -- "$pid1" 2>/dev/null
+ fi
+ n=2
+ break
+ elif [ -z "$pid1" ]; then
+ break
+ else
+ die="trap - $sig; kill -- $pid1 2>/dev/null; wait -- $pid1 2>/dev/null; exit 1"
+ trap "$die" $sig
+ fi
+ fi
+ done
+
+ trap - $sig
+
+ if [ -z "$n" ]; then
+ >&"$e" printf 'Failed to download \033[32m%s\033[0m from any mirror:\n' "$file"
+ >&"$e" printf '\n'
+ >&"$e" printf ' 1. \033[4m%s\033[0m\n' "$url1"
+ >&"$e" printf ' 2. \033[4m%s\033[0m\n' "$url2"
+ >&"$e" printf '\n'
+ >&"$e" printf 'Check your internet connection, then restart your shell.\n'
+ exit 1
+ fi
+
+ command tar -C "$tmpdir" -xzf "$tmpdir"/"$n".tar.gz || exit
+
+ local tmpfile
+ if ! command -v mktemp >/dev/null 2>&1 ||
+ ! tmpfile="$(command mktemp "$cache_dir"/gitstatusd.XXXXXXXXXX)"; then
+ tmpfile="$cache_dir"/gitstatusd.tmp.$$
+ fi
+
+ command mv -f -- "$tmpdir"/"$file" "$tmpfile" || exit
+ command mv -f -- "$tmpfile" "$cache_dir"/"$file" && exit
+ command rm -f -- "$cache_dir"/"$file"
+ command mv -f -- "$tmpfile" "$cache_dir"/"$file" && exit
+ command rm -f -- "$tmpfile"
+ exit 1
+ )
+
+ local ret="$?"
+ command rm -rf -- "$tmpdir"
+ [ "$ret" = 0 ] || return
+
+ _gitstatus_install_daemon_found 1 "$@"
return
done <"$gitstatus_dir"/install.info
- >&2 echo "[gitstatus] error: no gitstatusd found for $uname_s $uname_m"
+ >&"$e" printf 'There is no prebuilt \033[32mgitstatusd\033[0m for \033[1m%s\033[0m.\n' "$uname_s $uname_m"
+ >&"$e" printf '\n'
+ >&"$e" printf 'See: \033[4mhttps://github.com/romkatv/gitstatus#compiling\033[0m\n'
return 1
}
diff --git a/gitstatus/install.info b/gitstatus/install.info
index 853d4056..45807be4 100644
--- a/gitstatus/install.info
+++ b/gitstatus/install.info
@@ -1,24 +1,34 @@
+# 3
+#
# This file is used by ./install and indirectly by shell bindings.
+#
+# The first line is read by powerlevel10k instant prompt. It must
+# be updated whenever the content of this file changes. The actual
+# value doesn't matter as long as it's unique. Consecutive integers
+# work fine.
# Official gitstatusd binaries.
-uname_s_glob="cygwin_nt-10.0"; uname_m_glob="i686"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.0.0";
-uname_s_glob="cygwin_nt-10.0"; uname_m_glob="x86_64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.0.0";
-uname_s_glob="darwin"; uname_m_glob="x86_64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.0.0";
-uname_s_glob="freebsd"; uname_m_glob="amd64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.0.0";
-uname_s_glob="linux"; uname_m_glob="aarch64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.0.0";
-uname_s_glob="linux"; uname_m_glob="armv6l"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.0.0";
-uname_s_glob="linux"; uname_m_glob="armv7l"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.0.0";
-uname_s_glob="linux"; uname_m_glob="i686"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.0.0";
-uname_s_glob="linux"; uname_m_glob="x86_64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.0.0";
-uname_s_glob="msys_nt-10.0"; uname_m_glob="i686"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.0.0";
-uname_s_glob="msys_nt-10.0"; uname_m_glob="x86_64"; file="gitstatusd-${uname_s}-${uname_m}"; version="v1.0.0";
+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";
# Fallbacks to official gitstatusd binaries.
-uname_s_glob="cygwin_nt-*"; uname_m_glob="i686"; file="gitstatusd-cygwin_nt-10.0-${uname_m}"; version="v1.0.0";
-uname_s_glob="cygwin_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-cygwin_nt-10.0-${uname_m}"; version="v1.0.0";
-uname_s_glob="mingw32_nt-*"; uname_m_glob="i686"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.0.0";
-uname_s_glob="mingw32_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.0.0";
-uname_s_glob="mingw64_nt-*"; uname_m_glob="i686"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.0.0";
-uname_s_glob="mingw64_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.0.0";
-uname_s_glob="msys_nt-*"; uname_m_glob="i686"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.0.0";
-uname_s_glob="msys_nt-*"; uname_m_glob="x86_64"; file="gitstatusd-msys_nt-10.0-${uname_m}"; version="v1.0.0";
+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";
diff --git a/gitstatus/mbuild b/gitstatus/mbuild
index a1a8cda8..40316fdf 100755
--- a/gitstatus/mbuild
+++ b/gitstatus/mbuild
@@ -5,7 +5,7 @@
# Usage: mbuild [-b git-ref] [kernel-arch]...
#
# Builds a bunch of gitstatusd-* binaries. Without arguments builds binaries
-# for all platforms. git-ref defaults to src.
+# for all platforms. git-ref defaults to master.
#
# Before using this script you need to set up build servers and list them
# in ~/.ssh/config. There should be a Host entry for every value of `assets`
@@ -46,7 +46,7 @@
# ps> C:\msys64\autorebase.bat
# - Install 64-bit and 32-bit cygwin: https://cygwin.com/install.html.
# - Choose to install 32-bit to c:/cygwin32 instead of the default c:/cygwin.
-# - Select these packages: binutils, cmake, gcc-core, gcc-g++, git, make, wget.
+# - Select these packages: binutils, cmake, gcc-core, gcc-g++, git, make, perl, wget.
#
# IMPORTANT: Install msys2 and cygwin one at a time.
#
@@ -94,9 +94,7 @@
setopt no_unset extended_glob pipe_fail prompt_percent typeset_silent \
no_prompt_subst no_prompt_bang pushd_silent warn_create_global
-autoload -Uz is-at-least
-
-if ! is-at-least 5.1 || [[ $ZSH_VERSION == 5.4.* ]]; then
+if [[ $ZSH_VERSION != (5.<1->*|<6->.*) || $ZSH_VERSION == 5.4(|.*) ]]; then
print -ru2 -- "[error] unsupported zsh version: $ZSH_VERSION"
return 1
fi
@@ -111,12 +109,14 @@ local -rA assets=(
cygwin_nt-10.0-x86_64 build-windows-x86_64
msys_nt-10.0-i686 build-windows-x86_64
msys_nt-10.0-x86_64 build-windows-x86_64
+ darwin-arm64 build-macos-arm64
darwin-x86_64 build-macos-x86_64
freebsd-amd64 build-freebsd-amd64
linux-aarch64 build-linux-aarch64
linux-armv6l build-linux-armv7l
linux-armv7l build-linux-armv7l
linux-i686 build-linux-x86_64
+ linux-ppc64le build-linux-ppc64le
linux-x86_64 build-linux-x86_64
)
@@ -137,7 +137,7 @@ function usage() {
print -r -- 'usage: mbuild [-b REF] [KERNEL-ARCH]...'
}
-local OPTARG opt git_ref=src
+local OPTARG opt git_ref=master
local -i OPTIND
while getopts ":b:h" opt; do
case $opt in
@@ -151,7 +151,7 @@ done
shift $((OPTIND - 1))
-(( $# )) || set -- ${(k)assets}
+(( $# )) || set -- ${(ko)assets}
set -- ${(u)@}
local platform
@@ -180,14 +180,16 @@ local build='
function build-unix() {
local intro flags=(-sw)
case $2 in
- darwin-*) intro='PATH="/usr/local/bin:$PATH"';;
- linux-*) flags+=(-d docker);;
+ linux-ppc64le) ;;
+ linux-*) flags+=(-d docker);;
+ darwin-arm64) intro='PATH="/opt/homebrew/bin:$PATH"';;
+ darwin-*) intro='PATH="/usr/local/bin:$PATH"';;
esac
ssh $1 -- /bin/sh -uex <<<"
$intro
cd /tmp
$build ${2##*-} ${(j: :)${(@q)flags}}"
- scp $1:/tmp/gitstatus/usrbin/gitstatusd-$2 $binaries/
+ scp $1:/tmp/gitstatus/usrbin/gitstatusd $binaries/gitstatusd-$2
}
function build-windows() {
@@ -200,15 +202,23 @@ function build-windows() {
local tmp env bin intro flags=(-w)
case $2 in
- msys_nt-10.0-i686) bin='msys32/usr/bin';|
- msys_nt-10.0-x86_64) bin='msys64/usr/bin';|
cygwin_nt-10.0-i686) bin='cygwin32/bin' ;|
cygwin_nt-10.0-x86_64) bin='cygwin64/bin' ;|
+ msys_nt-10.0-i686) bin='msys32/usr/bin';|
+ msys_nt-10.0-x86_64) bin='msys64/usr/bin';|
+ cygwin_nt-10.0-*)
+ 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+='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.
+ break
local out
out="$(ssh $1 cmd.exe "$c/${bin%%/*}/autorebase.bat" 2>&1)"
[[ $out == *"The following DLLs couldn't be rebased"* ]] || break
@@ -219,6 +229,8 @@ 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 <<<"
@@ -229,7 +241,7 @@ function build-windows() {
while true; do
IFS= read -u $fd -r line || return 0
if [[ $line == *"warning: terminate MSYS2"* ]]; then
- # At this point the machine is hosed. Rogue process with corrupted name
+ # At this point the machine is hosed. A rogue process with a corrupted name
# is eating all CPU. The top SSH connection won't terminate on its own.
ssh $1 powershell.exe <<<'Restart-Computer -Force' || true
sleep 30
@@ -243,12 +255,7 @@ function build-windows() {
}
done
} "$@"
- intro='pacman -Syu --noconfirm; pacman -S --needed --noconfirm git; '
- intro+='PATH="$PATH:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl"'
- ;;
- cygwin_nt-10.0-*)
- tmp='/cygdrive/c/tmp'
- ;;
+ ;|
esac
ssh $1 $c/$bin/env.exe $env c:/$bin/bash.exe -l <<<"
@@ -258,20 +265,56 @@ function build-windows() {
cd -- $tmp
$build ${2##*-} ${(j: :)${(@q)flags}}
exit"
- scp $1:$c/tmp/gitstatus/usrbin/gitstatusd-$2 $binaries/
+ scp $1:$c/tmp/gitstatus/usrbin/gitstatusd $binaries/gitstatusd-$2
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]
- print -n >>$locks/$machine
- zsystem flock $locks/$machine
+ flock $locks/$machine
build-${protocol[(k)$platform]} $machine $platform
local tmp=gitstatusd-$platform.tmp.$$.tar.gz
- ( cd -q -- $binaries; GZIP=-9 tar -czf $tmp gitstatusd-$platform )
+ ( 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() {
@@ -281,17 +324,24 @@ function mbuild() {
print -r -- "starting build for $platform on $assets[$platform] (pid $!)"
pids+=($platform $!)
done
+ local failed=()
for platform pid in $pids; do
print -rn -- "$platform => "
if wait $pid; then
print -r -- "ok"
else
- print -r -- "error $?"
- print -r -- "---------------------"
- >&2 cat $logs/$platform
- return 1
+ print -r -- "error"
+ failed+=$platform
fi
done
+ (( $#failed )) || return 0
+ print
+ print -r -- "Error logs:"
+ print
+ for platform in $failed; do
+ print -r -- " $platform => $logs/$platform"
+ done
+ return 1
}
# Copied from https://github.com/romkatv/run-process-tree.
@@ -349,4 +399,8 @@ function run-process-tree() {
}
mkdir -p -- $logs $locks $binaries
-run-process-tree mbuild $@
+
+() {
+ run-process-tree mbuild $@
+ exit
+} "$@"
diff --git a/gitstatus/src/arena.h b/gitstatus/src/arena.h
index 0bad0bfa..569833ca 100644
--- a/gitstatus/src/arena.h
+++ b/gitstatus/src/arena.h
@@ -37,7 +37,7 @@ namespace gitstatus {
//
// // Donates a block to the arena. When the time comes, it'll be freed with
// // free(p, size, userdata).
-// void Donate(void* p, size_t size, void* userdata, void(*free)(void*, void*));
+// void Donate(void* p, size_t size, void* userdata, void(*free)(void*, size_t, void*));
class Arena {
public:
struct Options {
@@ -62,7 +62,7 @@ class Arena {
//
// void* userdata;
// void (*alloc)(size_t size, size_t alignment, void* userdata);
- // void (*free)(size_t size, void* userdata);
+ // void (*free)(void* p, size_t size, void* userdata);
};
// Requires: opt.min_block_size <= opt.max_block_size.
diff --git a/gitstatus/src/check.h b/gitstatus/src/check.h
index 82dceae1..682675a2 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 evalutes to true. Otherwise
+// Does nothing if the expression evaluates 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 14bc6ac4..39cf1c2c 100644
--- a/gitstatus/src/dir.cc
+++ b/gitstatus/src/dir.cc
@@ -106,32 +106,34 @@ bool ListDir(int dir_fd, Arena& arena, std::vector& entries, bool precomp
};
constexpr size_t kBufSize = 8 << 10;
- entries.clear();
+ const size_t orig_size = entries.size();
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.clear();
+ entries.resize(orig_size);
return false;
}
- if (n == 0) break;
for (int pos = 0; pos < n;) {
auto* ent = reinterpret_cast(buf + pos);
if (!Dots(ent->d_name)) entries.push_back(ent->d_name);
pos += ent->d_reclen;
- // It's tempting to bail here if n + sizeof(linux_dirent64) + 512 <= n. After all, there
- // was enough space for another entry but SYS_getdents64 didn't write it, so this must be
- // the end of the directory listing, right? Unfortuatenly, no. SYS_getdents64 is finicky.
- // It sometimes writes a partial list of entries even if the full list would fit.
}
+ if (n == 0) break;
+ // The following optimization relies on SYS_getdents64 always returning as many
+ // entries as would fit. This is not guaranteed by the specification and I don't
+ // know if this is true in practice. The optimization has no measurable effect on
+ // gitstatus performance, so it's turned off.
+ //
+ // if (n + sizeof(linux_dirent64) + 512 <= kBufSize) break;
}
if (case_sensitive) {
- SortEntries(entries.data(), entries.data() + entries.size());
+ SortEntries(entries.data() + orig_size, entries.data() + entries.size());
} else {
- SortEntries(entries.data(), entries.data() + entries.size());
+ SortEntries(entries.data() + orig_size, entries.data() + entries.size());
}
return true;
@@ -209,23 +211,24 @@ 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) {
- VERIFY((dir_fd = dup(dir_fd)) >= 0);
+ const size_t orig_size = entries.size();
+ dir_fd = dup(dir_fd);
+ if (dir_fd < 0) return false;
DIR* dir = fdopendir(dir_fd);
if (!dir) {
CHECK(!close(dir_fd)) << Errno();
- return -1;
+ return false;
}
ON_SCOPE_EXIT(&) { CHECK(!closedir(dir)) << Errno(); };
- entries.clear();
while (struct dirent* ent = (errno = 0, readdir(dir))) {
if (Dots(ent->d_name)) continue;
entries.push_back(DirenvConvert(arena, *ent, precompose_unicode));
}
if (errno) {
- entries.clear();
+ entries.resize(orig_size);
return false;
}
- StrSort(entries.data(), entries.data() + entries.size(), case_sensitive);
+ StrSort(entries.data() + orig_size, entries.data() + entries.size(), case_sensitive);
return true;
}
diff --git a/gitstatus/src/dir.h b/gitstatus/src/dir.h
index 42ab29bb..2a7533a3 100644
--- a/gitstatus/src/dir.h
+++ b/gitstatus/src/dir.h
@@ -25,11 +25,11 @@
namespace gitstatus {
-// On error, clears entries and returns false. Does not throw.
+// On error, leaves entries unchanged and returns false. Does not throw.
//
-// 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.
+// 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.
//
// Does not close dir_fd.
//
diff --git a/gitstatus/src/git.cc b/gitstatus/src/git.cc
index 029b02bf..552100cb 100644
--- a/gitstatus/src/git.cc
+++ b/gitstatus/src/git.cc
@@ -239,4 +239,12 @@ 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 7e5a6f9d..b85f09f7 100644
--- a/gitstatus/src/git.h
+++ b/gitstatus/src/git.h
@@ -48,6 +48,15 @@ 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 35351b85..81399ea7 100644
--- a/gitstatus/src/gitstatus.cc
+++ b/gitstatus/src/gitstatus.cc
@@ -41,6 +41,10 @@ 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"); };
@@ -118,7 +122,7 @@ void ProcessRequest(const Options& opts, RepoCache& cache, Request req) {
resp.Print(stats.num_untracked);
if (remote && remote->ref) {
- const char* ref = git_reference_shorthand(remote->ref);
+ const char* ref = git_reference_name(remote->ref);
// Number of commits we are ahead of upstream. Non-negative integer.
resp.Print(CountRange(repo->repo(), ref + "..HEAD"s));
// Number of commits we are behind upstream. Non-negative integer.
@@ -152,7 +156,7 @@ void ProcessRequest(const Options& opts, RepoCache& cache, Request req) {
resp.Print(push_remote ? push_remote->url : "");
if (push_remote && push_remote->ref) {
- const char* ref = git_reference_shorthand(push_remote->ref);
+ const char* ref = git_reference_name(push_remote->ref);
// Number of commits we are ahead of push remote. Non-negative integer.
resp.Print(CountRange(repo->repo(), ref + "..HEAD"s));
// Number of commits we are behind upstream. Non-negative integer.
@@ -167,6 +171,11 @@ 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 ae8ca54c..4d66876b 100644
--- a/gitstatus/src/index.cc
+++ b/gitstatus/src/index.cc
@@ -242,6 +242,7 @@ 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 421e5854..b7abe5db 100644
--- a/gitstatus/src/options.cc
+++ b/gitstatus/src/options.cc
@@ -53,9 +53,15 @@ 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 directores in stdin.\n"
+ << "Print machine-readable status of the git repos for directories in stdin.\n"
<< "\n"
<< "OPTIONS\n"
<< " -l, --lock-fd=NUM [default=-1]\n"
@@ -72,7 +78,7 @@ void PrintUsage() {
<< " maximum performance.\n"
<< "\n"
<< " -v, --log-level=STR [default=INFO]\n"
- << " Don't write entires to log whose log level is below this. Log levels in\n"
+ << " Don't write entries 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"
@@ -81,12 +87,18 @@ 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"
@@ -129,7 +141,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 remaning path\n"
+ << " If the first character is ':', it is removed and the remaining 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"
@@ -170,6 +182,8 @@ 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"
@@ -212,6 +226,8 @@ void PrintUsage() {
<< " '0'\n"
<< " '0'\n"
<< " '0'\n"
+ << " ''\n"
+ << " 'add a build server for darwin-arm64'\n"
<< "\n"
<< "EXIT STATUS\n"
<< "\n"
@@ -239,12 +255,13 @@ 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", no_argument, nullptr, 'G'},
+ {"version-glob", required_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'},
@@ -257,7 +274,7 @@ Options ParseOptions(int argc, char** argv) {
{}};
Options res;
while (true) {
- switch (getopt_long(argc, argv, "hVG:l:p:t:v:r:s:u:c:d:m:eUWD", opts, nullptr)) {
+ switch (getopt_long(argc, argv, "hVG:l:p:t:v:r:z:s:u:c:d:m:eUWD", opts, nullptr)) {
case -1:
if (optind != argc) {
std::cerr << "unexpected positional argument: " << argv[optind] << std::endl;
@@ -306,20 +323,23 @@ 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 = ParseLong(optarg);
+ res.max_num_staged = ParseSizeT(optarg);
break;
case 'u':
- res.max_num_unstaged = ParseLong(optarg);
+ res.max_num_unstaged = ParseSizeT(optarg);
break;
case 'c':
- res.max_num_conflicted = ParseLong(optarg);
+ res.max_num_conflicted = ParseSizeT(optarg);
break;
case 'd':
- res.max_num_untracked = ParseLong(optarg);
+ res.max_num_untracked = ParseSizeT(optarg);
break;
case 'm':
- res.dirty_max_index_size = ParseLong(optarg);
+ res.dirty_max_index_size = ParseSizeT(optarg);
break;
case 'e':
res.recurse_untracked_dirs = true;
diff --git a/gitstatus/src/options.h b/gitstatus/src/options.h
index 7cbfeed8..bb373155 100644
--- a/gitstatus/src/options.h
+++ b/gitstatus/src/options.h
@@ -27,6 +27,8 @@
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.
@@ -60,7 +62,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 entires to log whose log level is below this. Log levels in increasing order:
+ // Don't write entries 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 d7ea7d3e..a81594a4 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 synchrnonization.
+ // that result from lazy cache initialization without synchronization.
// 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 0e440791..8bd445c7 100644
--- a/gitstatus/src/tag_db.cc
+++ b/gitstatus/src/tag_db.cc
@@ -155,6 +155,8 @@ 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);
}
@@ -212,14 +214,30 @@ void TagDb::ParsePack() {
char* p = &pack_[0];
char* e = p + pack_.size();
- 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;
+ // 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;
}
+ 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);
@@ -249,7 +267,10 @@ void TagDb::ParsePack() {
id2name_.push_back(tag);
}
- VERIFY(std::is_sorted(name2id_.begin(), name2id_.end(), ByName));
+ 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);
+ }
id2name_dirty_ = true;
GlobalThreadPool()->Schedule([this] {
diff --git a/internal/configure.zsh b/internal/configure.zsh
index 5b3df9ad..0e13bdec 100644
--- a/internal/configure.zsh
+++ b/internal/configure.zsh
@@ -1,5 +1,7 @@
-typeset -gr __p9k_wizard_columns=51
-typeset -gr __p9k_wizard_lines=12
+# Fewer than 47 columns will probably work. Haven't tried it.
+typeset -gr __p9k_wizard_columns=47
+# The bottleneck is ask_tails with nerd fonts. Everything else works fine with 12 lines.
+typeset -gr __p9k_wizard_lines=14
typeset -gr __p9k_zd=${ZDOTDIR:-$HOME}
typeset -gr __p9k_zd_u=${${${(q)__p9k_zd}/#(#b)${(q)HOME}(|\/*)/'~'$match[1]}//\%/%%}
typeset -gr __p9k_zshrc=${${:-$__p9k_zd/.zshrc}:A}
@@ -16,13 +18,22 @@ 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 }
- [[ -w $__p9k_zd ]] || { $0_error "$__p9k_zd_u is not writable"; return 1 }
[[ ! -d $__p9k_cfg_path ]] || { $0_error "$__p9k_cfg_path_u is a directory"; return 1 }
[[ ! -d $__p9k_zshrc ]] || { $0_error "$__p9k_zshrc_u is a directory"; return 1 }
+ local dir=${__p9k_cfg_path:h}
+ while [[ ! -e $dir && $dir != ${dir:h} ]]; do dir=${dir:h}; done
+ if [[ ! -d $dir ]]; then
+ $0_error "cannot create $__p9k_cfg_path_u because ${dir//\%/%%} is not a directory"
+ return 1
+ fi
+ if [[ ! -w $dir ]]; then
+ $0_error "cannot create $__p9k_cfg_path_u because ${dir//\%/%%} is readonly"
+ return 1
+ fi
+
[[ ! -e $__p9k_cfg_path || -f $__p9k_cfg_path || -h $__p9k_cfg_path ]] || {
$0_error "$__p9k_cfg_path_u is a special file"
return 1
@@ -44,10 +55,13 @@ function _p9k_can_configure() {
done
(( LINES >= __p9k_wizard_lines && COLUMNS >= __p9k_wizard_columns )) || {
- $0_error "terminal size too small; must be at least $__p9k_wizard_columns x $__p9k_wizard_lines"
+ $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
@@ -59,11 +73,11 @@ function p9k_configure() {
_p9k_can_configure || return
(
set -- -f
- source $__p9k_root_dir/internal/wizard.zsh
+ builtin source $__p9k_root_dir/internal/wizard.zsh
)
local ret=$?
case $ret in
- 0) source $__p9k_cfg_path; _p9k__force_must_init=1;;
+ 0) builtin source $__p9k_cfg_path; _p9k__force_must_init=1;;
69) return 0;;
*) return $ret;;
esac
diff --git a/internal/icons.zsh b/internal/icons.zsh
index 403beea6..1d1cafbb 100644
--- a/internal/icons.zsh
+++ b/internal/icons.zsh
@@ -1,6 +1,7 @@
typeset -gA icons
function _p9k_init_icons() {
+ [[ -n ${POWERLEVEL9K_MODE-} || ${langinfo[CODESET]} == (utf|UTF)(-|)8 ]] || local POWERLEVEL9K_MODE=ascii
[[ $_p9k__icon_mode == $POWERLEVEL9K_MODE/$POWERLEVEL9K_LEGACY_ICON_SPACING/$POWERLEVEL9K_ICON_PADDING ]] && return
typeset -g _p9k__icon_mode=$POWERLEVEL9K_MODE/$POWERLEVEL9K_LEGACY_ICON_SPACING/$POWERLEVEL9K_ICON_PADDING
@@ -51,6 +52,7 @@ 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 # ๎ฑ
@@ -67,6 +69,14 @@ function _p9k_init_icons() {
LINUX_SABAYON_ICON '\uE271'$s # ๎ฑ
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_ALMALINUX_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 # ๎
@@ -97,10 +107,23 @@ 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'
@@ -117,6 +140,7 @@ 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'
@@ -130,6 +154,8 @@ 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'
@@ -140,6 +166,11 @@ function _p9k_init_icons() {
PHP_ICON 'php'
HASKELL_ICON 'hs'
PACKAGE_ICON 'pkg'
+ JULIA_ICON 'jl'
+ SCALA_ICON 'scala'
+ TOOLBOX_ICON '\u2B22' # โฌข
+ ARCH_ICON 'arch'
+ HISTORY_ICON 'hist'
)
;;
'awesome-fontconfig')
@@ -180,6 +211,7 @@ 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 # ๏
ผ
@@ -196,6 +228,14 @@ function _p9k_init_icons() {
LINUX_SABAYON_ICON '\uF17C'$s # ๏
ผ
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_ALMALINUX_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 # ๏ผ
@@ -222,10 +262,23 @@ 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'
@@ -234,7 +287,7 @@ function _p9k_init_icons() {
NORDVPN_ICON '\UF023' # ๏ฃ
EXECUTION_TIME_ICON '\uF253'$s # ๏
SSH_ICON 'ssh'
- VPN_ICON '\uF023'
+ VPN_ICON '\uF023'
KUBERNETES_ICON '\U2388' # โ
DROPBOX_ICON '\UF16B'$s # ๏
ซ
DATE_ICON '\uF073 ' # ๏ณ
@@ -242,6 +295,7 @@ 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'
@@ -255,6 +309,8 @@ 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'
@@ -265,6 +321,11 @@ function _p9k_init_icons() {
PHP_ICON 'php'
HASKELL_ICON 'hs'
PACKAGE_ICON 'pkg'
+ JULIA_ICON 'jl'
+ SCALA_ICON 'scala'
+ TOOLBOX_ICON '\u2B22' # โฌข
+ ARCH_ICON 'arch'
+ HISTORY_ICON 'hist'
)
;;
'awesome-mapped-fontconfig')
@@ -310,6 +371,7 @@ 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}"
@@ -326,6 +388,14 @@ function _p9k_init_icons() {
LINUX_SABAYON_ICON "${CODEPOINT_OF_AWESOME_LINUX:+\\u$CODEPOINT_OF_AWESOME_LINUX$s}"
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_ALMALINUX_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}"
@@ -352,10 +422,23 @@ 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}"
@@ -370,6 +453,7 @@ 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'
@@ -383,6 +467,8 @@ 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'
@@ -393,6 +479,172 @@ function _p9k_init_icons() {
PHP_ICON 'php'
HASKELL_ICON 'hs'
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_ALMALINUX_ICON '\UF31D'$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')
@@ -448,14 +700,23 @@ function _p9k_init_icons() {
LINUX_SABAYON_ICON '\uF317'$s # ๏
LINUX_SLACKWARE_ICON '\uF319'$s # ๏
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_ALMALINUX_ICON '\uF17C' # ๏
ผ
+ 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 '\uFBF1'$s # ๏ฏฑ
+ NETWORK_ICON '\uF50D'$s # ๏กท
LOAD_ICON '\uF080 ' # ๏
SWAP_ICON '\uF464'$s # ๏ค
RAM_ICON '\uF0E4'$s # ๏ค
@@ -476,10 +737,23 @@ 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' # ๎ฆ
@@ -496,6 +770,7 @@ 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 ' # ๏ป
@@ -509,6 +784,8 @@ 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 ' # ๏
@@ -519,6 +796,11 @@ function _p9k_init_icons() {
PHP_ICON '\uE608' # ๎
HASKELL_ICON '\uE61F' # ๎
PACKAGE_ICON '\uF8D6' # ๏ฃ
+ JULIA_ICON '\uE624' # ๎ค
+ SCALA_ICON '\uE737' # ๎ท
+ TOOLBOX_ICON '\uE20F'$s # ๎
+ ARCH_ICON '\uE266' # ๎ฆ
+ HISTORY_ICON '\uF1DA'$s # ๏
)
;;
ascii)
@@ -557,6 +839,7 @@ 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'
@@ -573,6 +856,14 @@ function _p9k_init_icons() {
LINUX_SABAYON_ICON 'sabayon'
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_ALMALINUX_ICON 'alma'
+ LINUX_GUIX_ICON 'guix'
+ LINUX_NEON_ICON 'neon'
SUNOS_ICON 'sunos'
HOME_ICON ''
HOME_SUB_ICON ''
@@ -599,10 +890,23 @@ 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'
@@ -619,6 +923,7 @@ 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'
@@ -632,6 +937,8 @@ 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'
@@ -642,6 +949,11 @@ function _p9k_init_icons() {
PHP_ICON 'php'
HASKELL_ICON 'hs'
PACKAGE_ICON 'pkg'
+ JULIA_ICON 'jl'
+ SCALA_ICON 'scala'
+ TOOLBOX_ICON 'toolbox'
+ ARCH_ICON 'arch'
+ HISTORY_ICON 'hist'
)
;;
*)
@@ -664,7 +976,7 @@ function _p9k_init_icons() {
TEST_ICON ''
TODO_ICON '\u2206' # โ
BATTERY_ICON '\U1F50B' # ๐
- DISK_ICON 'hdd'
+ DISK_ICON 'hdd'
OK_ICON '\u2714' # โ
FAIL_ICON '\u2718' # โ
SYMFONY_ICON 'SF'
@@ -682,6 +994,7 @@ 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'
@@ -698,6 +1011,14 @@ function _p9k_init_icons() {
LINUX_SABAYON_ICON 'Sab'
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_ALMALINUX_ICON 'Alma'
+ LINUX_GUIX_ICON 'Guix'
+ LINUX_NEON_ICON 'Neon'
SUNOS_ICON 'Sun'
HOME_ICON ''
HOME_SUB_ICON ''
@@ -724,10 +1045,23 @@ 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'
@@ -744,6 +1078,7 @@ 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'
@@ -757,6 +1092,8 @@ 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'
@@ -767,6 +1104,11 @@ function _p9k_init_icons() {
PHP_ICON 'php'
HASKELL_ICON 'hs'
PACKAGE_ICON 'pkg'
+ JULIA_ICON 'jl'
+ SCALA_ICON 'scala'
+ TOOLBOX_ICON '\u2B22' # โฌข
+ ARCH_ICON 'arch'
+ HISTORY_ICON 'hist'
)
;;
esac
@@ -791,6 +1133,7 @@ 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/notes.md b/internal/notes.md
index fbbaa5e9..dea28d30 100644
--- a/internal/notes.md
+++ b/internal/notes.md
@@ -76,16 +76,6 @@ emulate zsh -o prompt_percent -c 'print -P "%F{#ff0000}red%F{green}%B bold green
---
-bug: open a new tab and hit ctrl-p. an empty line will appear before prompt.
-
----
-
-take a look at https://github.com/skywind3000/z.lua. it claims to have fzf support. would be nice
-if alt-down showed two groups -- one for subdirs and another for directory history (sorted by
-frequency of use? by last use? three sections? more key bindings?).
-
----
-
add `p10k explain` that prints something like this:
```text
@@ -163,7 +153,8 @@ Prompt connection should have matching options.
Add `POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_MIRROR_SEPARATOR`. If set, left segments get separated with
`POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR` followed by `POWERLEVEL9K_LEFT_SEGMENT_MIRROR_SEPARATOR`.
Each is drawn without background. The first with the foreground of left segment, the second with
-the background of right segment. To insert space in between, embed it in one of these parameters.
+the background of right segment. To insert space in between, embed it in
+`POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_MIRROR_SEPARATOR`.
`POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR` is unused.
---
@@ -177,41 +168,6 @@ two filled separators similar to heads and tail. Figure out how to present this
---
-Get rid of `saved_columns` in the wizard and always present all options as if horizontal space was
-unlimited. `print_prompt` should print something like this if prompt is too wide:
-
- Terminal window too narrow to display prompt.
- Make it wider and press ENTER to refresh.
-
-Terminal dimensions will need to be checked more often.
-
-Try getting rid of the "press ENTER" requirement by trapping `SIGWINCH`. Might need to run `read -k`
-with timeout in a loop.
-
-Print all text with a helper function that keeps track of the number of lines remaining on screen.
-`print_prompt` will then be able to show a similar message for Terminal window being too short. This
-makes sense only for two-line prompts. This is probably OK.
-
-If `print_prompt` can be told in advance how many prompts we are going to display, it might be able
-to insert or avoid inserting `\n` in between, depending on terminal height. There is one screen
-where one prompt is a one-liner while another is a two-liner. This is fine because there are only
-two options. `print_prompt` can assume that all options will use the current prompt height.
-
-Don't use `print_prompt` directly. Create `ask_prompt` and use it like this:
-
-```zsh
-ask_prompt \
- 1 "No frame" "left_frame=0 right_frame=0" \
- 2 "Left frame" "left_frame=1 right_frame=0" \
- ...
-```
-
-There are two prompt questions that don't fit this pattern: `ask_empty_line` and
-`ask_transient_prompt`. The first is easy to adapt (`print_prompt` can print prompt twice if
-`empty_line=1`) but the second will probably have to be hand-coded.
-
----
-
Optimize auto-wizard check.
```text
@@ -225,3 +181,17 @@ user=0.17s system=0.00s cpu=99% total=0.175
---
Add the equivalent of `P9K_PYTHON_VERSION` to all `*env` segments where it makes sense.
+
+---
+
+Define `P9K_ICON` on initialization. Fill it with `$icon`. Duplicate every key that ends in `_ICON`.
+Respect `POWERLEVEL9K_VCS_STASH_ICON` overrides but not anything with segment name or state.
+
+Define `POWERLEVEL9K_VCS_*` parameters in config templates for all symbols used in
+`my_git_formatter`. Add missing entries to `icons`. Use `$P9K_ICON[...]` within `my_git_formatter`.
+Add a screen to the wizard to choose between clear and circled icons.
+
+---
+
+Add a screen to the wizard asking whether to set `POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~'`.
+Show it only if there is `$HOME/.git`. By default this parameter should be commented out.
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index 21217fd1..f73dd208 100644
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -1,9 +1,9 @@
-if [[ $__p9k_sourced != 11 ]]; then
+if [[ $__p9k_sourced != 13 ]]; then
>&2 print -P ""
>&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 folowing command to fix:"
+ >&2 print -P "If using %Bantigen%b, run the following 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 != 11 ]]; then
return 1
fi
-if ! autoload -Uz is-at-least || ! is-at-least 5.1; then
+if [[ $ZSH_VERSION != (5.<1->*|<6->.*) ]]; 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 ! autoload -Uz is-at-least || ! is-at-least 5.1; then
>&2 echo -E "The shell you are currently running is likely $cur."
fi
local other=${${:-zsh}:c}
- 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 ]] && $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_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
@@ -49,10 +49,10 @@ if ! autoload -Uz is-at-least || ! is-at-least 5.1; then
return 1
fi
-source "${__p9k_root_dir}/internal/configure.zsh"
-source "${__p9k_root_dir}/internal/worker.zsh"
-source "${__p9k_root_dir}/internal/parser.zsh"
-source "${__p9k_root_dir}/internal/icons.zsh"
+builtin source "${__p9k_root_dir}/internal/configure.zsh"
+builtin source "${__p9k_root_dir}/internal/worker.zsh"
+builtin source "${__p9k_root_dir}/internal/parser.zsh"
+builtin source "${__p9k_root_dir}/internal/icons.zsh"
# For compatibility with Powerlevel9k. It's not recommended to use mnemonic color
# names in the configuration except for colors 0-7 as these are standard.
@@ -193,25 +193,30 @@ function _p9k_read_word() {
local rest
_p9k__ret=
{ read _p9k__ret rest <$1 } 2>/dev/null
+ _p9k__ret=${_p9k__ret%$'\r'}
_p9k__read_word_cache[$1]=$stat[1]:$_p9k__ret
fi
[[ -n $_p9k__ret ]]
}
function _p9k_fetch_cwd() {
- _p9k__cwd=${(%):-%/}
- _p9k__cwd_a=${_p9k__cwd:A}
+ if [[ $PWD == /* && $PWD -ef . ]]; then
+ _p9k__cwd=$PWD
+ else
+ _p9k__cwd=${${${:-.}:a}:-.}
+ fi
+ _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=~/
+ ~|~/*)
+ local parent=${${${:-~/..}:a}%/}/
local parts=(${(s./.)_p9k__cwd#$parent})
;;
*)
@@ -228,7 +233,7 @@ function _p9k_fetch_cwd() {
_p9k__parent_mtimes_s="$_p9k__parent_mtimes_i"
}
-# Usage: _p9k_glob parent_dir_index pattern
+# Usage: _p9k_glob parent_dir_index pattern [glob_qual]
#
# parent_dir_index indexes _p9k__parent_dirs.
#
@@ -245,16 +250,16 @@ function _p9k_glob() {
fi
local -a stat
zstat -A stat +mtime -- $dir 2>/dev/null || stat=(-1)
- local files=($dir/$~2(N:t))
+ eval 'local files=($dir/$~2('$3'N:t))'
_p9k__glob_cache[$dir/$2]="$stat[1]:$#files"
return $#files
}
-# Usage: _p9k_upglob pattern
+# Usage: _p9k_upglob pattern [glob_qual]
#
# Returns index within _p9k__parent_dirs or 0 if there is no match.
#
-# Pattern cannot have slashes. Never matches in / or ~. Search stops before reaching / or ~.
+# Search stops before reaching ~/../ or / and never matches in those directories.
#
# Example: _p9k_upglob '*.csproj'
function _p9k_upglob() {
@@ -268,7 +273,7 @@ function _p9k_upglob() {
cached[-1]=()
local -i i
for i in ${(@)${cached:|_p9k__parent_mtimes_i}%:*}; do
- _p9k_glob $i $1 && continue
+ _p9k_glob $i "$@" && continue
_p9k__upsearch_cache[$_p9k__cwd/$1]="${_p9k__parent_mtimes_i[1,i]} $i"
return i
done
@@ -281,7 +286,7 @@ function _p9k_upglob() {
local -i i=1
fi
for ((; i <= $#_p9k__parent_mtimes; ++i)); do
- _p9k_glob $i $1 && continue
+ _p9k_glob $i "$@" && continue
_p9k__upsearch_cache[$_p9k__cwd/$1]="${_p9k__parent_mtimes_i[1,i]} $i"
return i
done
@@ -299,37 +304,44 @@ function _p9k_upglob() {
# _p9k_prompt_length '%F{red}abc' => 3
# _p9k_prompt_length $'%{a\b%Gb%}' => 1
function _p9k_prompt_length() {
- local COLUMNS=1024
- local -i x y=$#1 m
+ local -i COLUMNS=1024
+ local -i x y=${#1} m
if (( y )); then
while (( ${${(%):-$1%$y(l.1.0)}[-1]} )); do
x=y
- (( y *= 2 ));
+ (( y *= 2 ))
done
- local xy
while (( y > x + 1 )); do
- m=$(( x + (y - x) / 2 ))
- typeset ${${(%):-$1%$m(l.x.y)}[-1]}=$m
+ (( m = x + (y - x) / 2 ))
+ (( ${${(%):-$1%$m(l.x.y)}[-1]} = m ))
done
fi
- _p9k__ret=$x
+ typeset -g _p9k__ret=$x
}
typeset -gr __p9k_byte_suffix=('B' 'K' 'M' 'G' 'T' 'P' 'E' 'Z' 'Y')
-# 42 => 42B
-# 1536 => 1.5K
+# 512 => 512B
+# 1800 => 1.76K
+# 18000 => 17.6K
function _p9k_human_readable_bytes() {
- typeset -F 2 n=$1
+ typeset -F n=$1
local suf
for suf in $__p9k_byte_suffix; do
- (( n < 100 )) && break
+ (( n < 1024 )) && break
(( n /= 1024 ))
done
- _p9k__ret=${${n%%0#}%.}$suf
+ 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
}
-if is-at-least 5.4; then
+if [[ $ZSH_VERSION == (5.<4->*|<6->.*) ]]; then
function _p9k_print_params() { typeset -p -- "$@" }
else
# Cannot use `typeset -p` unconditionally because of bugs in zsh.
@@ -466,12 +478,12 @@ _p9k_param() {
if [[ -n $_p9k__ret ]]; then
_p9k__ret[-1,-1]=''
else
- if [[ $1 == (#b)prompt_([a-z0-9_]#)(*) ]]; then
- local var=_POWERLEVEL9K_${(U)match[1]}$match[2]_$2
+ if [[ ${1//-/_} == (#b)prompt_([a-z0-9_]#)(*) ]]; then
+ local var=_POWERLEVEL9K_${${(U)match[1]}//ฤฐ/I}$match[2]_$2
if (( $+parameters[$var] )); then
_p9k__ret=${(P)var}
else
- var=_POWERLEVEL9K_${(U)match[1]%_}_$2
+ var=_POWERLEVEL9K_${${(U)match[1]%_}//ฤฐ/I}_$2
if (( $+parameters[$var] )); then
_p9k__ret=${(P)var}
else
@@ -520,8 +532,8 @@ _p9k_get_icon() {
_p9k_translate_color() {
if [[ $1 == <-> ]]; then # decimal color code: 255
_p9k__ret=${(l.3..0.)1}
- elif [[ $1 == '#'[[:xdigit:]]## ]]; then # hexademical color code: #ffffff
- _p9k__ret=${(L)1}
+ elif [[ $1 == '#'[[:xdigit:]]## ]]; then # hexadecimal color code: #ffffff
+ _p9k__ret=${${(L)1}//ฤฑ/i}
else # named color: red
# Strip prifixes if there are any.
_p9k__ret=$__p9k_colors[${${${1#bg-}#fg-}#br}]
@@ -734,8 +746,8 @@ _p9k_left_prompt_segment() {
fi
fi
- p+="\${_p9k__c::=$content_exp_}"
- p+='${_p9k__e::=${${_p9k__'${_p9k__line_index}l${${1#prompt_}%%[A-Z_]#}'+00}:-'
+ p+='${_p9k__c::='$content_exp_'}${_p9k__c::=${_p9k__c//'$'\r''}}'
+ p+='${_p9k__e::=${${_p9k__'${_p9k__line_index}l${${1#prompt_}%%[A-Z0-9_]#}'+00}:-'
if (( has_icon == -1 )); then
p+='${${(%):-$_p9k__c%1(l.1.0)}[-1]}${${(%):-$_p9k__v%1(l.1.0)}[-1]}}'
else
@@ -759,8 +771,12 @@ _p9k_left_prompt_segment() {
_p9k_foreground $_p9k__ret
_p9k__ret=%b$bg$_p9k__ret
_p9k__ret=${_p9k__ret//\}/\\\}}
- [[ $_p9k__ret != $style_ || $need_style == 1 ]] && p+=$_p9k__ret
- p+='${_p9k__v}'
+ if [[ $_p9k__ret != $style_ ]]; then
+ p+=$_p9k__ret'${_p9k__v}'$style_
+ else
+ (( need_style )) && p+=$style_
+ p+='${_p9k__v}'
+ fi
_p9k_get_icon $1 LEFT_MIDDLE_WHITESPACE ' '
if [[ -n $_p9k__ret ]]; then
@@ -961,8 +977,8 @@ _p9k_right_prompt_segment() {
fi
fi
- p+="\${_p9k__c::=$content_exp_}"
- p+='${_p9k__e::=${${_p9k__'${_p9k__line_index}r${${1#prompt_}%%[A-Z_]#}'+00}:-'
+ p+='${_p9k__c::='$content_exp_'}${_p9k__c::=${_p9k__c//'$'\r''}}'
+ p+='${_p9k__e::=${${_p9k__'${_p9k__line_index}r${${1#prompt_}%%[A-Z0-9_]#}'+00}:-'
if (( has_icon == -1 )); then
p+='${${(%):-$_p9k__c%1(l.1.0)}[-1]}${${(%):-$_p9k__v%1(l.1.0)}[-1]}}'
else
@@ -1011,8 +1027,12 @@ _p9k_right_prompt_segment() {
_p9k_foreground $_p9k__ret
_p9k__ret=%b$bg$_p9k__ret
_p9k__ret=${_p9k__ret//\}/\\\}}
- [[ $_p9k__ret != $style_ || $need_style == 1 ]] && p+=$_p9k__ret
- p+='${_p9k__v}'
+ if [[ $_p9k__ret != $style_ ]]; then
+ p+=$_p9k__ret'${_p9k__v}'$style_
+ else
+ (( need_style )) && p+=$style_
+ p+='${_p9k__v}'
+ fi
_p9k_get_icon $1 RIGHT_MIDDLE_WHITESPACE ' '
if [[ -n $_p9k__ret ]]; then
@@ -1082,8 +1102,24 @@ function _p9k_prompt_segment() { "_p9k_${_p9k__prompt_side}_prompt_segment" "$@"
function p9k_prompt_segment() { p10k segment "$@" }
function _p9k_python_version() {
- _p9k_cached_cmd 1 python --version || return
- [[ $_p9k__ret == (#b)Python\ ([[:digit:].]##)* ]] && _p9k__ret=$match[1]
+ 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
}
################################################################
@@ -1093,11 +1129,16 @@ function _p9k_python_version() {
################################################################
# Anaconda Environment
prompt_anaconda() {
- local p=${CONDA_PREFIX:-$CONDA_ENV_PATH}
- local msg=''
- if (( _POWERLEVEL9K_ANACONDA_SHOW_PYTHON_VERSION )) && _p9k_python_version; then
- msg="${_p9k__ret//\%//%%} "
+ local msg
+ if _p9k_python_version; then
+ P9K_ANACONDA_PYTHON_VERSION=$_p9k__ret
+ if (( _POWERLEVEL9K_ANACONDA_SHOW_PYTHON_VERSION )); then
+ msg="${P9K_ANACONDA_PYTHON_VERSION//\%/%%} "
+ fi
+ else
+ unset P9K_ANACONDA_PYTHON_VERSION
fi
+ local p=${CONDA_PREFIX:-$CONDA_ENV_PATH}
msg+="$_POWERLEVEL9K_ANACONDA_LEFT_DELIMITER${${p:t}//\%/%%}$_POWERLEVEL9K_ANACONDA_RIGHT_DELIMITER"
_p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '' "$msg"
}
@@ -1106,28 +1147,72 @@ _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() {
- local aws_profile="${AWS_VAULT:-${AWSUME_PROFILE:-${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}}}"
- local pat class
+ typeset -g P9K_AWS_PROFILE="${AWS_SSO_PROFILE:-${AWS_VAULT:-${AWSUME_PROFILE:-${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}}}}"
+ local pat class state
for pat class in "${_POWERLEVEL9K_AWS_CLASSES[@]}"; do
- if [[ $aws_profile == ${~pat} ]]; then
- [[ -n $class ]] && state=_${(U)class}
+ if [[ $P9K_AWS_PROFILE == ${~pat} ]]; then
+ [[ -n $class ]] && state=_${${(U)class}//ฤฐ/I}
break
fi
done
- _p9k_prompt_segment "$0$state" red white 'AWS_ICON' 0 '' "${aws_profile//\%/%%}"
+
+ 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_aws_init() {
- typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${AWS_VAULT:-${AWSUME_PROFILE:-${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}}}'
+ typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${AWS_SSO_PROFILE:-${AWS_VAULT:-${AWSUME_PROFILE:-${AWS_PROFILE:-$AWS_DEFAULT_PROFILE}}}}'
}
################################################################
# 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
@@ -1218,14 +1303,28 @@ function _p9k_read_file() {
[[ -n $_p9k__ret ]]
}
-prompt_fvm() {
- _p9k_upglob fvm && return
- local link=$_p9k__parent_dirs[$?]/fvm
- if [[ -L $link ]]; then
- if [[ ${link:A} == (#b)*/versions/([^/]##)/bin/flutter ]]; then
- _p9k_prompt_segment $0 blue $_p9k_color1 FLUTTER_ICON 0 '' ${match[1]//\%/%%}
- fi
+function _p9k_fvm_old() {
+ _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
fi
+ return 1
+}
+
+function _p9k_fvm_new() {
+ _p9k_upglob .fvm/flutter_sdk @ && 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
+ fi
+ return 1
+}
+
+prompt_fvm() {
+ _p9k_fvm_new || _p9k_fvm_old
}
_p9k_prompt_fvm_init() {
@@ -1246,7 +1345,7 @@ _p9k_prompt_battery_init() {
return
fi
if [[ $_p9k_os != (Linux|Android) ||
- -z /sys/class/power_supply/(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
}
@@ -1304,13 +1403,16 @@ _p9k_prompt_battery_set_args() {
Linux|Android)
# See https://sourceforge.net/projects/acpiclient.
- local -a bats=( /sys/class/power_supply/(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} ))
@@ -1318,12 +1420,11 @@ _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/(energy|charge)_now(N); then
- (( energy_now += _p9k__ret ))
- elif _p9k_read_file $dir/capacity(N); then
+ 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
+ (( energy_now += _p9k__ret ))
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
@@ -1360,7 +1461,7 @@ _p9k_prompt_battery_set_args() {
;;
esac
- (( bat_percent >= _POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD )) && return
+ (( bat_percent >= _POWERLEVEL9K_BATTERY_${state}_HIDE_ABOVE_THRESHOLD )) && return
local msg="$bat_percent%%"
[[ $_POWERLEVEL9K_BATTERY_VERBOSE == 1 && -n $remain ]] && msg+=" ($remain)"
@@ -1568,6 +1669,20 @@ 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.
@@ -1631,14 +1746,22 @@ 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=$_p9k__cwd
+ local p=${(V)_p9k__cwd}
local -a parts=("${(s:/:)p}")
elif [[ -o auto_name_dirs ]]; then
- local p=${_p9k__cwd/#(#b)$HOME(|\/*)/'~'$match[1]}
+ local p=${(V)${_p9k__cwd/#(#b)$HOME(|\/*)/'~'$match[1]}}
local -a parts=("${(s:/:)p}")
else
local p=${(%):-%~}
@@ -1652,15 +1775,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 == '~['$reply[1]']'* ]]; then
- parts+='~['$reply[1]']'
+ if (( $+functions[$func] )) && $func d $_p9k__cwd && [[ $p == '~['${(V)reply[1]}']'* ]]; then
+ parts+='~['${(V)reply[1]}']'
break
fi
done
if (( $#parts )); then
parts+=(${(s:/:)${p#$parts[1]}})
else
- p=$_p9k__cwd
+ p=${(V)_p9k__cwd}
parts=("${(s:/:)p}")
fi
else
@@ -1745,9 +1868,12 @@ prompt_dir() {
fi
;;
truncate_to_last)
- if [[ $#parts -gt 2 || $p[1] != / && $#parts -gt 1 ]]; then
+ 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
fake_first=1
- parts[1,-2]=()
+ parts[1,-i]=()
fi
;;
truncate_to_first_and_last)
@@ -1764,6 +1890,9 @@ 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 ))
@@ -1777,9 +1906,9 @@ prompt_dir() {
else
local key=
fi
- 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]
+ 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]
_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'
@@ -1788,7 +1917,8 @@ prompt_dir() {
local -i m=1
for (( ; i <= e; ++i, ++m )); do
local sub=$parts[i]
- local dir=$parent/$sub mtime=$mtimes[m]
+ local rsub=$rparts[i]
+ local dir=$parent/$rsub mtime=$mtimes[m]
local pair=$_p9k__dir_stat_cache[$dir]
if [[ $pair == ${mtime:-x}:* ]]; then
parts[i]=${pair#*:}
@@ -1796,22 +1926,22 @@ prompt_dir() {
[[ $sub != *["~!#\`\$^&*()\\\"'<>?{}[]"]* ]]
local -i q=$?
if [[ -n $_POWERLEVEL9K_SHORTEN_FOLDER_MARKER &&
- -n $parent/$sub/${~_POWERLEVEL9K_SHORTEN_FOLDER_MARKER}(#qN) ]]; then
+ -n $dir/${~_POWERLEVEL9K_SHORTEN_FOLDER_MARKER}(#qN) ]]; then
(( q )) && parts[i]="\${(Q)\${:-${(qqq)${(q)sub}}}}"
parts[i]+=$'\2'
else
- local -i j=$sub[(i)[^.]]
- for (( ; j + d < $#sub; ++j )); do
- local -a matching=($parent/$sub[1,j]*/(N))
+ local -i j=$rsub[(i)[^.]]
+ for (( ; j + d < $#rsub; ++j )); do
+ local -a matching=($parent/$rsub[1,j]*/(N))
(( $#matching == 1 )) && break
done
- local -i saved=$(($#sub - j - d))
+ local -i saved=$((${(m)#${(V)${rsub:$j}}} - d))
if (( saved > 0 )); then
if (( q )); then
parts[i]='${${${_p9k__d:#-*}:+${(Q)${:-'${(qqq)${(q)sub}}'}}}:-${(Q)${:-'
- parts[i]+=$'\3'${(qqq)${(q)sub[1,j]}}$'}}\1\3''${$((_p9k__d+='$saved'))+}}'
+ parts[i]+=$'\3'${(qqq)${(q)${(V)${rsub[1,j]}}}}$'}}\1\3''${$((_p9k__d+='$saved'))+}}'
else
- parts[i]='${${${_p9k__d:#-*}:+'$sub$'}:-\3'$sub[1,j]$'\1\3''${$((_p9k__d+='$saved'))+}}'
+ parts[i]='${${${_p9k__d:#-*}:+'$sub$'}:-\3'${(V)${rsub[1,j]}}$'\1\3''${$((_p9k__d+='$saved'))+}}'
fi
else
(( q )) && parts[i]="\${(Q)\${:-${(qqq)${(q)sub}}}}"
@@ -1819,14 +1949,14 @@ prompt_dir() {
fi
[[ -n $mtime ]] && _p9k__dir_stat_cache[$dir]="$mtime:$parts[i]"
fi
- parent+=/$sub
+ parent+=/$rsub
done
if [[ -n $_POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER ]]; then
local _2=$'\2'
- if [[ $_POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER == last ]]; then
- (( e = ${parts[(I)*$_2]} ))
+ if [[ $_POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER == last* ]]; then
+ (( e = ${parts[(I)*$_2]} + ${_POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER#*:} ))
else
- (( e = ${parts[(ib:2:)*$_2]} ))
+ (( e = ${parts[(ib:2:)*$_2]} + ${_POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER#*:} ))
fi
if (( e > 1 && e <= $#parts )); then
parts[1,e-1]=()
@@ -1878,28 +2008,36 @@ prompt_dir() {
;;
esac
- [[ $_POWERLEVEL9K_DIR_SHOW_WRITABLE != 0 && ! -w $_p9k__cwd ]]
- local w=$?
+ # w=0: writable
+ # w=1: not writable
+ # w=2: does not exist
+ (( !_POWERLEVEL9K_DIR_SHOW_WRITABLE )) || [[ -w $_p9k__cwd ]]
+ local -i w=$?
+ (( w && _POWERLEVEL9K_DIR_SHOW_WRITABLE > 2 )) && [[ ! -e $_p9k__cwd ]] && w=2
if ! _p9k_cache_ephemeral_get $0 $_p9k__cwd $p $w $fake_first "${parts[@]}"; then
local state=$0
local icon=''
local a='' b='' c=''
for a b c in "${_POWERLEVEL9K_DIR_CLASSES[@]}"; do
if [[ $_p9k__cwd == ${~a} ]]; then
- [[ -n $b ]] && state+=_${(U)b}
+ [[ -n $b ]] && state+=_${${(U)b}//ฤฐ/I}
icon=$'\1'$c
break
fi
done
- if (( ! w )); then
+ if (( w )); then
if (( _POWERLEVEL9K_DIR_SHOW_WRITABLE == 1 )); then
state=${0}_NOT_WRITABLE
+ elif (( w == 2 )); then
+ state+=_NON_EXISTENT
else
state+=_NOT_WRITABLE
fi
icon=LOCK_ICON
fi
+ local state_u=${${(U)state}//ฤฐ/I}
+
local style=%b
_p9k_color $state BACKGROUND blue
_p9k_background $_p9k__ret
@@ -1925,7 +2063,7 @@ prompt_dir() {
_p9k_param $state PATH_HIGHLIGHT_BOLD ''
[[ $_p9k__ret == true ]] && last_style+=%B
if (( $+parameters[_POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND] ||
- $+parameters[_POWERLEVEL9K_${(U)state}_PATH_HIGHLIGHT_FOREGROUND] )); then
+ $+parameters[_POWERLEVEL9K_${state_u}_PATH_HIGHLIGHT_FOREGROUND] )); then
_p9k_color $state PATH_HIGHLIGHT_FOREGROUND ''
_p9k_foreground $_p9k__ret
last_style+=$_p9k__ret
@@ -1939,7 +2077,7 @@ prompt_dir() {
_p9k_param $state ANCHOR_BOLD ''
[[ $_p9k__ret == true ]] && anchor_style+=%B
if (( $+parameters[_POWERLEVEL9K_DIR_ANCHOR_FOREGROUND] ||
- $+parameters[_POWERLEVEL9K_${(U)state}_ANCHOR_FOREGROUND] )); then
+ $+parameters[_POWERLEVEL9K_${state_u}_ANCHOR_FOREGROUND] )); then
_p9k_color $state ANCHOR_FOREGROUND ''
_p9k_foreground $_p9k__ret
anchor_style+=$_p9k__ret
@@ -1957,7 +2095,7 @@ prompt_dir() {
fi
if (( $+parameters[_POWERLEVEL9K_DIR_SHORTENED_FOREGROUND] ||
- $+parameters[_POWERLEVEL9K_${(U)state}_SHORTENED_FOREGROUND] )); then
+ $+parameters[_POWERLEVEL9K_${state_u}_SHORTENED_FOREGROUND] )); then
_p9k_color $state SHORTENED_FOREGROUND ''
_p9k_foreground $_p9k__ret
(( expand )) && _p9k_escape_style $_p9k__ret
@@ -1973,22 +2111,28 @@ prompt_dir() {
parts=("${(@)parts//$'\3'}")
fi
- local sep=''
- if (( $+parameters[_POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND] ||
- $+parameters[_POWERLEVEL9K_${(U)state}_PATH_SEPARATOR_FOREGROUND] )); then
- _p9k_color $state PATH_SEPARATOR_FOREGROUND ''
- _p9k_foreground $_p9k__ret
- (( expand )) && _p9k_escape_style $_p9k__ret
- sep=$_p9k__ret
+ if [[ $_p9k__cwd == / && $_POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER == 1 ]]; then
+ local sep='/'
+ else
+ local sep=''
+ if (( $+parameters[_POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND] ||
+ $+parameters[_POWERLEVEL9K_${state_u}_PATH_SEPARATOR_FOREGROUND] )); then
+ _p9k_color $state PATH_SEPARATOR_FOREGROUND ''
+ _p9k_foreground $_p9k__ret
+ (( expand )) && _p9k_escape_style $_p9k__ret
+ sep=$_p9k__ret
+ fi
+ _p9k_param $state PATH_SEPARATOR /
+ _p9k__ret=${(g::)_p9k__ret}
+ (( expand )) && _p9k_escape $_p9k__ret
+ sep+=$_p9k__ret
+ [[ $sep == *%* ]] && sep+=$style
fi
- _p9k_param $state PATH_SEPARATOR /
- (( expand )) && _p9k_escape $_p9k__ret
- sep+=$_p9k__ret
- [[ $sep == *%* ]] && sep+=$style
local content="${(pj.$sep.)parts}"
- if (( _POWERLEVEL9K_DIR_HYPERLINK && _p9k_term_has_href )); then
- local header=$'%{\e]8;;file://'${${_p9k__cwd//\%/%%25}//'#'/%%23}$'\a%}'
+ 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 footer=$'%{\e]8;;\a%}'
if (( expand )); then
_p9k_escape $header
@@ -2030,7 +2174,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
@@ -2043,7 +2187,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//\%/%%}"
@@ -2063,7 +2207,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
@@ -2073,7 +2217,7 @@ prompt_package() {
# Redneck json parsing. Yields correct results for any well-formed json document.
# Produces random garbage for invalid json.
{ data="$(<$file)" || return } 2>/dev/null
- data=${data##[[:space:]]#}
+ data=${${data//$'\r'}##[[:space:]]#}
[[ $data == '{'* ]] || return
data[1]=
local -i depth=1
@@ -2147,7 +2291,7 @@ prompt_ip() {
# Segment to display if VPN is active
prompt_vpn_ip() {
typeset -ga _p9k__vpn_ip_segments
- _p9k__vpn_ip_segments+=($_p9k__prompt_side $_p9k__segment_index)
+ _p9k__vpn_ip_segments+=($_p9k__prompt_side $_p9k__line_index $_p9k__segment_index)
local p='${(e)_p9k__vpn_ip_'$_p9k__prompt_side$_p9k__segment_index'}'
_p9k__prompt+=$p
typeset -g "_p9k__segment_val_${_p9k__prompt_side}[_p9k__segment_index]"=$p
@@ -2156,7 +2300,7 @@ prompt_vpn_ip() {
_p9k_vpn_ip_render() {
local _p9k__segment_name=vpn_ip _p9k__prompt_side ip
local -i _p9k__has_upglob _p9k__segment_index
- for _p9k__prompt_side _p9k__segment_index in $_p9k__vpn_ip_segments; do
+ for _p9k__prompt_side _p9k__line_index _p9k__segment_index in $_p9k__vpn_ip_segments; do
local _p9k__prompt=
for ip in $_p9k__vpn_ip_ips; do
_p9k_prompt_segment prompt_vpn_ip "cyan" "$_p9k_color1" 'VPN_ICON' 0 '' $ip
@@ -2168,13 +2312,18 @@ _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)"
- _p9k_cache_stat_set "${${(M)v:#Laravel Framework *}#Laravel Framework }"
+ 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"
fi
[[ -n $_p9k__cache_val[1] ]] || return
_p9k_prompt_segment "$0" "maroon" "white" 'LARAVEL_ICON' 0 '' "${_p9k__cache_val[1]//\%/%%}"
@@ -2200,9 +2349,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 > 70 )); then
+ if (( pct > _POWERLEVEL9K_LOAD_CRITICAL_PCT )); then
_p9k_prompt_segment $0_CRITICAL red "$_p9k_color1" LOAD_ICON 0 '' $load
- elif (( pct > 50 )); then
+ elif (( pct > _POWERLEVEL9K_LOAD_WARNING_PCT )); 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
@@ -2235,9 +2384,9 @@ _p9k_prompt_load_async() {
_p9k__load_warning=
_p9k__load_critical=
local -F pct='100. * _p9k__load_value / _p9k_num_cpus'
- if (( pct > 70 )); then
+ if (( pct > _POWERLEVEL9K_LOAD_CRITICAL_PCT )); then
_p9k__load_critical=1
- elif (( pct > 50 )); then
+ elif (( pct > _POWERLEVEL9K_LOAD_WARNING_PCT )); then
_p9k__load_warning=1
else
_p9k__load_normal=1
@@ -2255,18 +2404,20 @@ _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[$2]
+ local cmd=$commands[$3]
[[ -n $cmd ]] || return
- if ! _p9k_cache_stat_get $0" ${(q)*}" $cmd; then
+ if ! _p9k_cache_stat_get $0" ${(q)*}" $2 $cmd; then
local out
if (( $1 )); then
- out="$($cmd "${@:3}" 2>&1)"
+ out="$($cmd "${@:4}" 2>&1)"
else
- out="$($cmd "${@:3}" 2>/dev/null)"
+ out="$($cmd "${@:4}" 2>/dev/null)"
fi
_p9k_cache_stat_set $(( ! $? )) "$out"
fi
@@ -2275,13 +2426,45 @@ function _p9k_cached_cmd() {
}
################################################################
-# Segment to diplay Node version
+# Segment to display Node version
prompt_node_version() {
- if (( _POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY )); then
- _p9k_upglob package.json && return
+ _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)
fi
- _p9k_cached_cmd 0 node --version && [[ $_p9k__ret == v?* ]] || return
- _p9k_prompt_segment "$0" "green" "white" 'NODE_ICON' 0 '' "${_p9k__ret#v}"
+
+ 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_prompt_node_version_init() {
@@ -2296,6 +2479,7 @@ function _p9k_nvm_ls_default() {
while [[ -r $NVM_DIR/alias/$v ]]; do
local target=
IFS='' read -r target <$NVM_DIR/alias/$v
+ target=${target%$'\r'}
[[ -z $target ]] && break
(( $seen[(I)$target] )) && return
seen+=$target
@@ -2373,10 +2557,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
@@ -2389,7 +2573,13 @@ _p9k_nvm_ls_current() {
prompt_nvm() {
[[ -n $NVM_DIR ]] && _p9k_nvm_ls_current || return
local current=$_p9k__ret
- ! _p9k_nvm_ls_default || [[ $_p9k__ret != $current ]] || return
+ (( _POWERLEVEL9K_NVM_SHOW_SYSTEM )) ||
+ [[ $current != system ]] ||
+ return
+ (( _POWERLEVEL9K_NVM_PROMPT_ALWAYS_SHOW )) ||
+ ! _p9k_nvm_ls_default ||
+ [[ $_p9k__ret != $current ]] ||
+ return
_p9k_prompt_segment "$0" "magenta" "black" 'NODE_ICON' 0 '' "${${current#v}//\%/%%}"
}
@@ -2401,7 +2591,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"
@@ -2445,13 +2635,13 @@ prompt_nodenv() {
(( ${_POWERLEVEL9K_NODENV_SOURCES[(I)local]} )) || return
break
fi
- [[ $dir == / ]] && break
+ [[ $dir == (/|.) ]] && break
dir=${dir:h}
done
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
@@ -2487,9 +2677,12 @@ _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
- _p9k_cached_cmd 0 dotnet --version || return
+
+ local cfg
+ _p9k_upglob global.json -. || cfg=$_p9k__parent_dirs[$?]/global.json
+ _p9k_cached_cmd 0 "$cfg" dotnet --version || return
_p9k_prompt_segment "$0" "magenta" "white" 'DOTNET_ICON' 0 '' "$_p9k__ret"
}
@@ -2511,9 +2704,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//\%/%%}"
@@ -2557,7 +2750,13 @@ _p9k_prompt_ram_async() {
(( free_bytes += match[1] ))
[[ $stat =~ 'Pages inactive:[[:space:]]+([0-9]+)' ]] || return
(( free_bytes += match[1] ))
- (( free_bytes *= 4096 ))
+ if (( ! $+_p9k__ram_pagesize )); then
+ local p
+ (( $+commands[pagesize] )) && p=$(pagesize 2>/dev/null) && [[ $p == <1-> ]] || p=4096
+ typeset -gi _p9k__ram_pagesize=p
+ _p9k_print_params _p9k__ram_pagesize
+ fi
+ (( free_bytes *= _p9k__ram_pagesize ))
;;
BSD)
local stat && stat="$(grep -F 'avail memory' /var/run/dmesg.boot 2>/dev/null)" || return
@@ -2606,13 +2805,13 @@ prompt_rbenv() {
(( ${_POWERLEVEL9K_RBENV_SOURCES[(I)local]} )) || return
break
fi
- [[ $dir == / ]] && break
+ [[ $dir == (/|.) ]] && break
dir=${dir:h}
done
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
@@ -2648,6 +2847,69 @@ function _p9k_phpenv_global_version() {
_p9k_read_word ${PHPENV_ROOT:-$HOME/.phpenv}/version || _p9k__ret=system
}
+function _p9k_scalaenv_global_version() {
+ _p9k_read_word ${SCALAENV_ROOT:-$HOME/.scalaenv}/version || _p9k__ret=system
+}
+
+# https://github.com/scalaenv/scalaenv
+prompt_scalaenv() {
+ if [[ -n $SCALAENV_VERSION ]]; then
+ (( ${_POWERLEVEL9K_SCALAENV_SOURCES[(I)shell]} )) || return
+ local v=$SCALAENV_VERSION
+ else
+ (( ${_POWERLEVEL9K_SCALAENV_SOURCES[(I)local|global]} )) || return
+ _p9k__ret=
+ if [[ $SCALAENV_DIR != (|.) ]]; then
+ [[ $SCALAENV_DIR == /* ]] && local dir=$SCALAENV_DIR || local dir="$_p9k__cwd_a/$SCALAENV_DIR"
+ dir=${dir:A}
+ if [[ $dir != $_p9k__cwd_a ]]; then
+ while true; do
+ if _p9k_read_word $dir/.scala-version; then
+ (( ${_POWERLEVEL9K_SCALAENV_SOURCES[(I)local]} )) || return
+ break
+ fi
+ [[ $dir == (/|.) ]] && break
+ dir=${dir:h}
+ done
+ fi
+ fi
+ if [[ -z $_p9k__ret ]]; then
+ _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
+ else
+ _p9k__ret=
+ fi
+ fi
+ if [[ -z $_p9k__ret ]]; then
+ (( _POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW )) || return
+ (( ${_POWERLEVEL9K_SCALAENV_SOURCES[(I)global]} )) || return
+ _p9k_scalaenv_global_version
+ fi
+ local v=$_p9k__ret
+ fi
+
+ if (( !_POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW )); then
+ _p9k_scalaenv_global_version
+ [[ $v == $_p9k__ret ]] && return
+ fi
+
+ if (( !_POWERLEVEL9K_SCALAENV_SHOW_SYSTEM )); then
+ [[ $v == system ]] && return
+ fi
+
+ _p9k_prompt_segment "$0" "red" "$_p9k_color1" 'SCALA_ICON' 0 '' "${v//\%/%%}"
+}
+
+_p9k_prompt_scalaenv_init() {
+ typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[scalaenv]:-${${+functions[scalaenv]}:#0}}'
+}
+
+function _p9k_phpenv_global_version() {
+ _p9k_read_word ${PHPENV_ROOT:-$HOME/.phpenv}/version || _p9k__ret=system
+}
+
prompt_phpenv() {
if [[ -n $PHPENV_VERSION ]]; then
(( ${_POWERLEVEL9K_PHPENV_SOURCES[(I)shell]} )) || return
@@ -2664,13 +2926,13 @@ prompt_phpenv() {
(( ${_POWERLEVEL9K_PHPENV_SOURCES[(I)local]} )) || return
break
fi
- [[ $dir == / ]] && break
+ [[ $dir == (/|.) ]] && break
dir=${dir:h}
done
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
@@ -2725,13 +2987,13 @@ prompt_luaenv() {
(( ${_POWERLEVEL9K_LUAENV_SOURCES[(I)local]} )) || return
break
fi
- [[ $dir == / ]] && break
+ [[ $dir == (/|.) ]] && break
dir=${dir:h}
done
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
@@ -2786,13 +3048,13 @@ prompt_jenv() {
(( ${_POWERLEVEL9K_JENV_SOURCES[(I)local]} )) || return
break
fi
- [[ $dir == / ]] && break
+ [[ $dir == (/|.) ]] && break
dir=${dir:h}
done
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
@@ -2847,13 +3109,13 @@ prompt_plenv() {
(( ${_POWERLEVEL9K_PLENV_SOURCES[(I)local]} )) || return
break
fi
- [[ $dir == / ]] && break
+ [[ $dir == (/|.) ]] && break
dir=${dir:h}
done
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
@@ -2885,13 +3147,31 @@ _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
- (( _POWERLEVEL9K_CHRUBY_SHOW_ENGINE )) && v=$RUBY_ENGINE
- if [[ $_POWERLEVEL9K_CHRUBY_SHOW_VERSION == 1 && -n $RUBY_VERSION ]] && v+=${v:+ }$RUBY_VERSION
+ local v=${(M)RUBY_ENGINE:#$~_POWERLEVEL9K_CHRUBY_SHOW_ENGINE_PATTERN}
+ [[ $_POWERLEVEL9K_CHRUBY_SHOW_VERSION == 1 && -n $RUBY_VERSION ]] && v+=${v:+ }$RUBY_VERSION
_p9k_prompt_segment "$0" "red" "$_p9k_color1" 'RUBY_ICON' 0 '' "${v//\%/%%}"
}
@@ -2912,70 +3192,57 @@ instant_prompt_root_indicator() { prompt_root_indicator; }
################################################################
# Segment to display Rust version number
prompt_rust_version() {
- 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//\%/%%}"
+ 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]
}
-_p9k_prompt_rust_version_init() {
+function _p9k_prompt_rust_version_init() {
+ _p9k__async_segments_compute+='_p9k_rust_version_prefetch'
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
@@ -3169,6 +3436,8 @@ _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
@@ -3289,10 +3558,9 @@ instant_prompt_date() {
# todo.sh: shows the number of tasks in your todo.sh file
prompt_todo() {
unset P9K_TODO_TOTAL_TASK_COUNT P9K_TODO_FILTERED_TASK_COUNT
- [[ -r $_p9k__todo_file ]] || return
- local todo=$commands[todo.sh]
+ [[ -r $_p9k__todo_file && -x $_p9k__todo_command ]] || return
if ! _p9k_cache_stat_get $0 $_p9k__todo_file; then
- local count="$($todo -p ls | tail -1)"
+ local count="$($_p9k__todo_command -p ls | command tail -1)"
if [[ $count == (#b)'TODO: '([[:digit:]]##)' of '([[:digit:]]##)' '* ]]; then
_p9k_cache_stat_set 1 $match[1] $match[2]
else
@@ -3314,7 +3582,7 @@ prompt_todo() {
}
_p9k_prompt_todo_init() {
- typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[todo.sh]'
+ typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$_p9k__todo_file'
}
################################################################
@@ -3443,7 +3711,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 sting we just generated, set the special
+ # To signal that we want to use the string we just generated, set the special
# variable `ret' to something other than the default zero:
ret=1
return 0
@@ -3452,20 +3720,9 @@ 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)"
- 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
-
+ _p9k_vcs_icon "$remote"
+ vcs_visual_identifier=$_p9k__ret
elif [[ "${hook_com[vcs]}" == "hg" ]]; then
vcs_visual_identifier='VCS_HG_ICON'
elif [[ "${hook_com[vcs]}" == "svn" ]]; then
@@ -3576,7 +3833,7 @@ function _p9k_vcs_status_for_dir() {
while true; do
_p9k__ret=$_p9k__gitstatus_last[$dir]
[[ -n $_p9k__ret ]] && return 0
- [[ $dir == / ]] && return 1
+ [[ $dir == (/|.) ]] && return 1
dir=${dir:h}
done
fi
@@ -3591,20 +3848,21 @@ function _p9k_vcs_status_purge() {
# unset doesn't work if $dir contains weird shit
_p9k__gitstatus_last[$dir]=""
_p9k_git_slow[$dir]=""
- [[ $dir == / ]] && break
+ [[ $dir == (/|.) ]] && break
dir=${dir:h}
done
fi
}
function _p9k_vcs_icon() {
- 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_GITHUB_ICON;;
- *gitlab*) _p9k__ret=VCS_GIT_GITLAB_ICON;;
- *) _p9k__ret=VCS_GIT_ICON;;
- esac
+ 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=
}
function _p9k_vcs_render() {
@@ -3634,7 +3892,7 @@ function _p9k_vcs_render() {
state=CLEAN
fi
fi
- _p9k_vcs_icon
+ _p9k_vcs_icon "$VCS_STATUS_REMOTE_URL"
_p9k_prompt_segment prompt_vcs_$state "${__p9k_vcs_states[$state]}" "$_p9k_color1" "$_p9k__ret" 0 '' ""
return 0
fi
@@ -3687,14 +3945,9 @@ 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 compatiblity.
- case "$VCS_STATUS_REMOTE_URL" in
- *github*) icon=VCS_GIT_GITHUB_ICON;;
- *bitbucket*) icon=VCS_GIT_BITBUCKET_ICON;;
- *stash*) icon=VCS_GIT_GITHUB_ICON;;
- *gitlab*) icon=VCS_GIT_GITLAB_ICON;;
- *) icon=VCS_GIT_ICON;;
- esac
+ # 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"
+ icon=$_p9k__ret
fi
: ${state:=CLEAN}
@@ -3833,7 +4086,7 @@ function _p9k_vcs_resume() {
if (( _p9k_vcs_index && $+GITSTATUS_DAEMON_PID_POWERLEVEL9K )); then
local _p9k__prompt _p9k__prompt_side=$_p9k_vcs_side _p9k__segment_name=vcs
- local -i _p9k__has_upglob _p9k__segment_index=_p9k_vcs_index
+ local -i _p9k__has_upglob _p9k__segment_index=_p9k_vcs_index _p9k__line_index=_p9k_vcs_line_index
_p9k_vcs_render
typeset -g _p9k__vcs=$_p9k__prompt
else
@@ -3845,7 +4098,8 @@ function _p9k_vcs_resume() {
}
function _p9k_vcs_gitstatus() {
- if [[ $_p9k__refresh_reason == precmd ]]; then
+ if [[ $_p9k__refresh_reason == precmd ]] && (( !_p9k__vcs_called )); then
+ typeset -gi _p9k__vcs_called=1
if (( $+_p9k__gitstatus_next_dir )); then
_p9k__gitstatus_next_dir=$_p9k__cwd_a
else
@@ -3866,7 +4120,7 @@ function _p9k_vcs_gitstatus() {
local dir=$_p9k__cwd_a
while true; do
case $_p9k_git_slow[$dir] in
- "") [[ $dir == / ]] && break; dir=${dir:h};;
+ "") [[ $dir == (/|.) ]] && break; dir=${dir:h};;
0) break;;
1) timeout=0; break;;
esac
@@ -3934,7 +4188,7 @@ prompt_vcs() {
current_state='CLEAN'
fi
fi
- _p9k_prompt_segment "${0}_${(U)current_state}" "${__p9k_vcs_states[$current_state]}" "$_p9k_color1" "$vcs_visual_identifier" 0 '' "$vcs_prompt"
+ _p9k_prompt_segment "${0}_${${(U)current_state}//ฤฐ/I}" "${__p9k_vcs_states[$current_state]}" "$_p9k_color1" "$vcs_visual_identifier" 0 '' "$vcs_prompt"
fi
fi
}
@@ -3989,6 +4243,49 @@ 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):
@@ -3998,10 +4295,35 @@ prompt_virtualenv() {
if (( _POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION )) && _p9k_python_version; then
msg="${_p9k__ret//\%/%%} "
fi
- local v=${VIRTUAL_ENV:t}
- [[ $v == $~_POWERLEVEL9K_VIRTUALENV_GENERIC_NAMES ]] && v=${VIRTUAL_ENV:h:t}
+ 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
msg+="$_POWERLEVEL9K_VIRTUALENV_LEFT_DELIMITER${v//\%/%%}$_POWERLEVEL9K_VIRTUALENV_RIGHT_DELIMITER"
- _p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '' "$msg"
+ case $_POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV in
+ false)
+ _p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '${(M)${#P9K_PYENV_PYTHON_VERSION}:#0}' "$msg"
+ ;;
+ if-different)
+ _p9k_escape $v
+ _p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '${${:-'$_p9k__ret'}:#$_p9k__pyenv_version}' "$msg"
+ ;;
+ *)
+ _p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '' "$msg"
+ ;;
+ esac
}
_p9k_prompt_virtualenv_init() {
@@ -4023,7 +4345,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
@@ -4034,11 +4356,8 @@ function _p9k_pyenv_global_version() {
_p9k_read_pyenv_like_version_file ${PYENV_ROOT:-$HOME/.pyenv}/version python- || _p9k__ret=system
}
-################################################################
-# Segment to display pyenv information
-# https://github.com/pyenv/pyenv#choosing-the-python-version
-prompt_pyenv() {
- unset P9K_PYENV_PYTHON_VERSION
+function _p9k_pyenv_compute() {
+ unset P9K_PYENV_PYTHON_VERSION _p9k__pyenv_version
local v=${(j.:.)${(@)${(s.:.)PYENV_VERSION}#python-}}
if [[ -n $v ]]; then
@@ -4055,13 +4374,13 @@ prompt_pyenv() {
(( ${_POWERLEVEL9K_PYENV_SOURCES[(I)local]} )) || return
break
fi
- [[ $dir == / ]] && break
+ [[ $dir == (/|.) ]] && break
dir=${dir:h}
done
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
@@ -4079,22 +4398,34 @@ prompt_pyenv() {
if (( !_POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW )); then
_p9k_pyenv_global_version
- [[ $v == $_p9k__ret ]] && return
+ [[ $v == $_p9k__ret ]] && return 1
fi
if (( !_POWERLEVEL9K_PYENV_SHOW_SYSTEM )); then
- [[ $v == system ]] && return
+ [[ $v == system ]] && return 1
fi
local versions=${PYENV_ROOT:-$HOME/.pyenv}/versions
versions=${versions:A}
- local version=$versions/$v
- version=${version:A}
- if [[ $version == (#b)$versions/([^/]##)* ]]; then
- typeset -g P9K_PYENV_PYTHON_VERSION=$match[1]
- fi
+ 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
- _p9k_prompt_segment "$0" "blue" "$_p9k_color1" 'PYTHON_ICON' 0 '' "${v//\%/%%}"
+ 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_pyenv_init() {
@@ -4123,13 +4454,13 @@ prompt_goenv() {
(( ${_POWERLEVEL9K_GOENV_SOURCES[(I)local]} )) || return
break
fi
- [[ $dir == / ]] && break
+ [[ $dir == (/|.) ]] && break
dir=${dir:h}
done
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
@@ -4178,7 +4509,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]//\%/%%}"
}
@@ -4204,27 +4535,36 @@ prompt_kubecontext() {
local name namespace cluster user cloud_name cloud_account cloud_zone cloud_cluster text state
() {
local cfg && cfg=(${(f)"$(kubectl config view -o=yaml 2>/dev/null)"}) || return
- local ctx=(${(@M)cfg:#current-context: [^\"\'\|\>]*})
+ local qstr='"*"'
+ local str='([^"'\''|>]*|'$qstr')'
+ local ctx=(${(@M)cfg:#current-context: $~str})
(( $#ctx == 1 )) || return
name=${ctx[1]#current-context: }
local -i pos=${cfg[(i)contexts:]}
- (( pos <= $#cfg )) || return
- shift $pos cfg
- pos=${cfg[(i) name: $name]}
- (( pos <= $#cfg )) || return
- (( --pos ))
- for ((; pos > 0; --pos)); do
- local line=$cfg[pos]
- if [[ $line == '- context:' ]]; then
- return 0
- elif [[ $line == (#b)' cluster: '([^\"\'\|\>]*) ]]; then
- cluster=$match[1]
- elif [[ $line == (#b)' namespace: '([^\"\'\|\>]*) ]]; then
- namespace=$match[1]
- elif [[ $line == (#b)' user: '([^\"\'\|\>]*) ]]; then
- user=$match[1]
- fi
- done
+ {
+ (( pos <= $#cfg )) || return
+ shift $pos cfg
+ pos=${cfg[(i) name: ${(b)name}]}
+ (( pos <= $#cfg )) || return
+ (( --pos ))
+ for ((; pos > 0; --pos)); do
+ local line=$cfg[pos]
+ if [[ $line == '- context:' ]]; then
+ return 0
+ elif [[ $line == (#b)' cluster: '($~str) ]]; then
+ cluster=$match[1]
+ [[ $cluster == $~qstr ]] && cluster=$cluster[2,-2]
+ elif [[ $line == (#b)' namespace: '($~str) ]]; then
+ namespace=$match[1]
+ [[ $namespace == $~qstr ]] && namespace=$namespace[2,-2]
+ elif [[ $line == (#b)' user: '($~str) ]]; then
+ user=$match[1]
+ [[ $user == $~qstr ]] && user=$user[2,-2]
+ fi
+ done
+ } always {
+ [[ $name == $~qstr ]] && name=$name[2,-2]
+ }
}
if [[ -n $name ]]; then
: ${namespace:=default}
@@ -4233,13 +4573,13 @@ prompt_kubecontext() {
if [[ $cluster == (#b)gke_(?*)_(asia|australia|europe|northamerica|southamerica|us)-([a-z]##<->)(-[a-z]|)_(?*) ]]; then
cloud_name=gke
cloud_account=$match[1]
- cloud_zone=$match[2]-$match[3]-$match[4]
+ cloud_zone=$match[2]-$match[3]$match[4]
cloud_cluster=$match[5]
if (( ${_POWERLEVEL9K_KUBECONTEXT_SHORTEN[(I)gke]} )); then
text=$cloud_cluster
fi
# arn:aws:eks:us-east-1:123456789012:cluster/cluster-01
- elif [[ $cluster == (#b)arn:aws:eks:([[:alnum:]-]##):([[:digit:]]##):cluster/(?*) ]]; then
+ elif [[ $cluster == (#b)arn:aws[[:alnum:]-]#:eks:([[:alnum:]-]##):([[:digit:]]##):cluster/(?*) ]]; then
cloud_name=eks
cloud_zone=$match[1]
cloud_account=$match[2]
@@ -4257,12 +4597,12 @@ prompt_kubecontext() {
local pat class
for pat class in "${_POWERLEVEL9K_KUBECONTEXT_CLASSES[@]}"; do
if [[ $text == ${~pat} ]]; then
- [[ -n $class ]] && state=_${(U)class}
+ [[ -n $class ]] && state=_${${(U)class}//ฤฐ/I}
break
fi
done
fi
- _p9k_cache_stat_set "$name" "$namespace" "$cluster" "$user" "$cloud_name" "$cloud_account" "$cloud_zone" "$cloud_cluster" "$text" "$state"
+ _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"
fi
typeset -g P9K_KUBECONTEXT_NAME=$_p9k__cache_val[1]
@@ -4305,7 +4645,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]
@@ -4326,9 +4666,10 @@ _p9k_prompt_java_version_init() {
}
prompt_azure() {
- local cfg=${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json
- if ! _p9k_cache_stat_get $0 $cfg; then
- local name
+ local name cfg=${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json
+ if _p9k_cache_stat_get $0 $cfg; then
+ name=$_p9k__cache_val[1]
+ else
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
@@ -4336,8 +4677,15 @@ prompt_azure() {
fi
_p9k_cache_stat_set "$name"
fi
- [[ -n $_p9k__cache_val[1] ]] || return
- _p9k_prompt_segment "$0" "blue" "white" "AZURE_ICON" 0 '' "${_p9k__cache_val[1]//\%/%%}"
+ [[ -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//\%/%%}"
}
_p9k_prompt_azure_init() {
@@ -4361,11 +4709,11 @@ _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 ~/.config/gcloud/active_config || return
+ _p9k_read_word ${CLOUDSDK_CONFIG:-~/.config/gcloud}/active_config || return
P9K_GCLOUD_CONFIGURATION=$_p9k__ret
- if ! _p9k_cache_stat_get $0 ~/.config/gcloud/configurations/config_$P9K_GCLOUD_CONFIGURATION; then
+ if ! _p9k_cache_stat_get $0 ${CLOUDSDK_CONFIG:-~/.config/gcloud}/configurations/config_$P9K_GCLOUD_CONFIGURATION; then
local pair account project_id
- pair="$(gcloud config configurations list --configuration=$P9K_GCLOUD_CONFIGURATION \
+ pair="$(gcloud config configurations describe $P9K_GCLOUD_CONFIGURATION \
--format=$'value[separator="\1"](properties.core.account,properties.core.project)')"
(( ! $? )) && IFS=$'\1' read account project_id <<<$pair
_p9k_cache_stat_set "$account" "$project_id"
@@ -4442,7 +4790,7 @@ prompt_google_app_cred() {
local pat class state
for pat class in "${_POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES[@]}"; do
if [[ $text == ${~pat} ]]; then
- [[ -n $class ]] && state=_${(U)class}
+ [[ -n $class ]] && state=_${${(U)class}//ฤฐ/I}
break
fi
done
@@ -4474,34 +4822,60 @@ typeset -gra __p9k_nordvpn_tag=(
)
function _p9k_fetch_nordvpn_status() {
- setopt err_return
+ setopt err_return no_multi_byte
local REPLY
- zsocket /run/nordvpnd.sock
- local -i fd=$REPLY
+ zsocket /run/nordvpn/nordvpnd.sock
+ local -i fd=REPLY
{
- >&$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
+ 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
{
- IFS='' read -t 0.25 -r tag
- tag=$'\n'
+ IFS='' read -t 0.25 -r val
+ val=$'\n'
while true; do
- tag=$((#tag))
+ tag=$((#val))
+ wire='tag & 7'
(( (tag >>= 3) && tag <= $#__p9k_nordvpn_tag )) || break
- tag=$__p9k_nordvpn_tag[tag]
- [[ -t $fd ]] || true # https://www.zsh.org/mla/workers/2020/msg00207.html
- sysread -s 1 -t 0.25 len
- len=$((#len))
- val=
- while true; do
- (( len )) || 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 -c n -s $len -t 0.25 'val[$#val+1]'
- len+=-n
- done
- typeset -g $tag=$val
+ 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
[[ -t $fd ]] || true # https://www.zsh.org/mla/workers/2020/msg00207.html
- sysread -s 1 -t 0.25 tag
+ sysread -s 1 -t 0.25 val
done
} <&$fd
} always {
@@ -4511,13 +4885,6 @@ 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
@@ -4551,22 +4918,28 @@ function _p9k_fetch_nordvpn_status() {
# POWERLEVEL9K_NORDVPN_CONNECTING_CONTENT_EXPANSION='${P9K_NORDVPN_COUNTRY_CODE}'
# POWERLEVEL9K_NORDVPN_CONNECTING_BACKGROUND=cyan
function prompt_nordvpn() {
+ # This prompt segment is broken. See https://github.com/romkatv/powerlevel10k/issues/2860.
+ # It is disabled until it is fixed.
+ return
+
unset $__p9k_nordvpn_tag P9K_NORDVPN_COUNTRY_CODE
- if [[ -e /run/nordvpnd.sock ]]; then
- _p9k_fetch_nordvpn_status 2>/dev/null
- if [[ $P9K_NORDVPN_SERVER == (#b)([[:alpha:]]##)[[:digit:]]##.nordvpn.com ]]; then
- typeset -g P9K_NORDVPN_COUNTRY_CODE=${(U)match[1]}
- fi
+ [[ -e /run/nordvpn/nordvpnd.sock ]] || return
+ _p9k_fetch_nordvpn_status 2>/dev/null || return
+ if [[ $P9K_NORDVPN_SERVER == (#b)([[:alpha:]]##)[[:digit:]]##.nordvpn.com ]]; then
+ typeset -g P9K_NORDVPN_COUNTRY_CODE=${${(U)match[1]}//ฤฐ/I}
fi
case $P9K_NORDVPN_STATUS in
Connected)
- _p9k_prompt_segment $0_CONNECTED blue white NORDVPN_ICON 0 '' "$P9K_NORDVPN_COUNTRY_CODE";;
+ _p9k_prompt_segment $0_CONNECTED blue white NORDVPN_ICON 0 '' "$P9K_NORDVPN_COUNTRY_CODE"
+ ;;
Disconnected|Connecting|Disconnecting)
- local state=${(U)P9K_NORDVPN_STATUS}
+ local state=${${(U)P9K_NORDVPN_STATUS}//ฤฐ/I}
_p9k_get_icon $0_$state FAIL_ICON
- _p9k_prompt_segment $0_$state yellow white NORDVPN_ICON 0 '' "$_p9k__ret";;
+ _p9k_prompt_segment $0_$state yellow white NORDVPN_ICON 0 '' "$_p9k__ret"
+ ;;
*)
- _p9k_prompt_segment $0_MISSING blue white '' 0 '' '';;
+ return
+ ;;
esac
}
@@ -4586,6 +4959,18 @@ 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 '' ''
@@ -4612,6 +4997,32 @@ 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 '' ''
@@ -4631,11 +5042,11 @@ function prompt_nix_shell() {
}
_p9k_prompt_nix_shell_init() {
- typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${IN_NIX_SHELL:#0}'
+ typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"=$_p9k_nix_shell_cond
}
function instant_prompt_nix_shell() {
- _p9k_prompt_segment prompt_nix_shell 4 $_p9k_color1 NIX_SHELL_ICON 1 '${IN_NIX_SHELL:#0}' '${(M)IN_NIX_SHELL:#(pure|impure)}'
+ _p9k_prompt_segment prompt_nix_shell 4 $_p9k_color1 NIX_SHELL_ICON 1 "$_p9k_nix_shell_cond" '${(M)IN_NIX_SHELL:#(pure|impure)}'
}
function prompt_terraform() {
@@ -4643,11 +5054,11 @@ function prompt_terraform() {
if [[ -z $TF_WORKSPACE ]]; then
_p9k_read_word ${${TF_DATA_DIR:-.terraform}:A}/environment && ws=$_p9k__ret
fi
- [[ $ws == (|default) ]] && return
- local pat class
+ [[ -z $ws || $ws == default && $_POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT == 0 ]] && return
+ local pat class state
for pat class in "${_POWERLEVEL9K_TERRAFORM_CLASSES[@]}"; do
if [[ $ws == ${~pat} ]]; then
- [[ -n $class ]] && state=_${(U)class}
+ [[ -n $class ]] && state=_${${(U)class}//ฤฐ/I}
break
fi
done
@@ -4658,6 +5069,23 @@ _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
@@ -4673,18 +5101,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
}
@@ -4700,8 +5128,11 @@ 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=()
@@ -4767,7 +5198,7 @@ function _p9k_taskwarrior_init_meta() {
local last_sig=$_p9k_taskwarrior_meta_sig
{
local cfg
- cfg="$(task show data.location /dev/null)" || return
+ cfg="$(command task show data.location rc.color=0 rc._forcecolor=0 /dev/null)" || return
local lines=(${(@M)${(f)cfg}:#data.location[[:space:]]##[^[:space:]]*})
(( $#lines == 1 )) || return
local dir=${lines[1]##data.location[[:space:]]#}
@@ -4803,10 +5234,14 @@ function _p9k_taskwarrior_check_data() {
zstat -A stat +mtime -- $_p9k_taskwarrior_data_files 2>/dev/null || return
fi
[[ $_p9k_taskwarrior_data_sig == ${(pj:\0:)stat}$'\0'$TASKRC$'\0'$TASKDATA ]] || return
+ (( _p9k_taskwarrior_next_due == 0 || _p9k_taskwarrior_next_due > EPOCHSECONDS )) || return
}
function _p9k_taskwarrior_init_data() {
- local -a stat files=($_p9k_taskwarrior_data_dir/{pending,completed}.data)
+ local -a stat files=(
+ $_p9k_taskwarrior_data_dir/{pending,completed}.data
+ $_p9k_taskwarrior_data_dir/taskchampion.sqlite3
+ )
_p9k_taskwarrior_data_files=($^files(N))
_p9k_taskwarrior_data_non_files=(${files:|_p9k_taskwarrior_data_files})
if (( $#_p9k_taskwarrior_data_files )); then
@@ -4822,11 +5257,25 @@ function _p9k_taskwarrior_init_data() {
local name val
for name in PENDING OVERDUE; do
- val="$(task +$name count /dev/null)" || continue
+ val="$(command task +$name count rc.color=0 rc._forcecolor=0 /dev/null)" || continue
[[ $val == <1-> ]] || continue
_p9k_taskwarrior_counters[$name]=$val
done
+ _p9k_taskwarrior_next_due=0
+
+ 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 \
+ 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
+ _p9k_taskwarrior_next_due=${${(on)ts}[1]}
+ (( _p9k_taskwarrior_next_due > EPOCHSECONDS )) || _p9k_taskwarrior_next_due=$((EPOCHSECONDS+60))
+ fi
+ fi
+
_p9k__state_dump_scheduled=1
}
@@ -4837,6 +5286,7 @@ function prompt_taskwarrior() {
_p9k_taskwarrior_data_non_files=()
_p9k_taskwarrior_data_sig=
_p9k_taskwarrior_counters=()
+ _p9k_taskwarrior_next_due=0
_p9k_taskwarrior_check_meta || _p9k_taskwarrior_init_meta || return
_p9k_taskwarrior_init_data
fi
@@ -4867,7 +5317,8 @@ prompt_wifi() {
}
_p9k_prompt_wifi_init() {
- if [[ -x /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport ]]; then
+ if [[ -x /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport ||
+ -r /proc/net/wireless && -n $commands[iw] ]]; then
typeset -g _p9k__wifi_on=
typeset -g P9K_WIFI_LAST_TX_RATE=
typeset -g P9K_WIFI_SSID=
@@ -4887,28 +5338,63 @@ _p9k_prompt_wifi_compute() {
_p9k_prompt_wifi_async() {
local airport=/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport
- local last_tx_rate ssid link_auth rssi noise bars on out line v state
+ local last_tx_rate ssid link_auth rssi noise bars on out line v state iface
{
- [[ -x $airport ]] || return 0
- out="$($airport -I)" || return 0
- for line in ${${${(f)out}##[[:space:]]#}%%[[:space:]]#}; do
- v=${line#*: }
- case $line[1,-$#v-3] in
- agrCtlRSSI) rssi=$v;;
- agrCtlNoise) noise=$v;;
- state) state=$v;;
- lastTxRate) last_tx_rate=$v;;
- link\ auth) link_auth=$v;;
- SSID) ssid=$v;;
- esac
- done
- if [[ $state != running || $rssi != (0|-<->) || $noise != (0|-<->) ]]; then
- rssi=
- noise=
- last_tx_rate=
- link_auth=
- ssid=
- bars=
+ if [[ -x $airport ]]; then
+ out="$($airport -I)" || return 0
+ for line in ${${${(f)out}##[[:space:]]#}%%[[:space:]]#}; do
+ v=${line#*: }
+ case $line[1,-$#v-3] in
+ agrCtlRSSI) rssi=$v;;
+ agrCtlNoise) noise=$v;;
+ state) state=$v;;
+ lastTxRate) last_tx_rate=$v;;
+ link\ auth) link_auth=$v;;
+ SSID) ssid=$v;;
+ esac
+ done
+ [[ $state == running && $rssi == (0|-<->) && $noise == (0|-<->) ]] || return 0
+ elif [[ -r /proc/net/wireless && -n $commands[iw] ]]; then
+ # Content example (https://github.com/romkatv/powerlevel10k/pull/973#issuecomment-680251804):
+ #
+ # Inter-| sta-| Quality | Discarded packets | Missed | WE
+ # face | tus | link level noise | nwid crypt frag retry misc | beacon | 22
+ # wlp3s0: 0000 58. -52. -256 0 0 0 0 76 0
+ local -a lines
+ lines=(${${(f)"$() && $noise == (0|-<->) ]] || return 0
+ # Output example (https://github.com/romkatv/powerlevel10k/pull/973#issuecomment-680251804):
+ #
+ # Connected to 74:83:c2:be:76:da (on wlp3s0)
+ # SSID: DailyGrindGuest1
+ # freq: 5745
+ # RX: 35192066 bytes (27041 packets)
+ # TX: 4090471 bytes (24287 packets)
+ # signal: -52 dBm
+ # rx bitrate: 243.0 MBit/s VHT-MCS 6 40MHz VHT-NSS 2
+ # tx bitrate: 240.0 MBit/s VHT-MCS 5 40MHz short GI VHT-NSS 2
+ #
+ # bss flags: short-slot-time
+ # dtim period: 1
+ # beacon int: 100
+ lines=(${(f)"$(command iw dev $iface link)"}) || return 0
+ local -a match mbegin mend
+ for line in $lines; do
+ if [[ $line == (#b)[[:space:]]#SSID:[[:space:]]##(*) ]]; then
+ ssid=$match[1]
+ elif [[ $line == (#b)[[:space:]]#'tx bitrate:'[[:space:]]##([^[:space:]]##)' MBit/s'* ]]; then
+ last_tx_rate=$match[1]
+ [[ $last_tx_rate == <->.<-> ]] && last_tx_rate=${${last_tx_rate%%0#}%.}
+ fi
+ done
+ [[ -n $ssid && -n $last_tx_rate ]] || return 0
+ else
return 0
fi
# https://www.speedguide.net/faq/how-to-read-rssisignal-and-snrnoise-ratings-440
@@ -4927,6 +5413,14 @@ _p9k_prompt_wifi_async() {
fi
on=1
} always {
+ if (( ! on )); then
+ rssi=
+ noise=
+ ssid=
+ last_tx_rate=
+ bars=
+ link_auth=
+ fi
if [[ $_p9k__wifi_on != $on ||
$P9K_WIFI_LAST_TX_RATE != $last_tx_rate ||
$P9K_WIFI_SSID != $ssid ||
@@ -4995,18 +5489,20 @@ function _p9k_asdf_init_meta() {
# legacy_version_file = yes
#
# We do the same.
- local lines=(${(@M)${(f)"$(<$cfg)"}:#[[:space:]]#legacy_version_file[[:space:]]#=*})
+ local lines=(${(@M)${(@)${(f)"$(<$cfg)"}%$'\r'}:#[[:space:]]#legacy_version_file[[:space:]]#=*})
if [[ $#lines == 1 && ${${(s:=:)lines[1]}[2]} == [[:space:]]#yes[[:space:]]# ]]; then
legacy_enabled=1
fi
fi
- local root=${ASDF_DATA_DIR:-~/.asdf}/plugins
- files+=$root
- if [[ -d $root ]]; then
+ local root=${ASDF_DATA_DIR:-~/.asdf}
+ files+=$root/plugins
+ if [[ -d $root/plugins ]]; then
local plugin
- for plugin in $root/[^[:space:]]##(N); do
- _p9k_asdf_plugins+=${plugin:t}
+ for plugin in $root/plugins/[^[:space:]]##(/N); do
+ files+=$root/installs/${plugin:t}
+ local -aU installed=($root/installs/${plugin:t}/[^[:space:]]##(/N:t) system)
+ _p9k_asdf_plugins[${plugin:t}]=${(j:|:)${(@b)installed}}
(( legacy_enabled )) || continue
if [[ ! -e $plugin/bin ]]; then
files+=$plugin/bin
@@ -5019,7 +5515,7 @@ function _p9k_asdf_init_meta() {
files+=$parse
[[ -x $parse ]] && has_parse=1
local name
- for name in $($list_names 2>/dev/null); do
+ for name in ${$($list_names 2>/dev/null)%$'\r'}; do
[[ $name == (*/*|.tool-versions) ]] && continue
_p9k_asdf_file_info[$name]+="${plugin:t} $has_parse "
done
@@ -5036,6 +5532,8 @@ function _p9k_asdf_init_meta() {
zstat -A stat +mtime -- $_p9k_asdf_meta_files 2>/dev/null || return
fi
_p9k_asdf_meta_sig=$ASDF_CONFIG_FILE$'\0'$ASDF_DATA_DIR$'\0'${(pj:\0:)stat}
+ _p9k__asdf_dir2files=()
+ _p9k_asdf_file2versions=()
} always {
if (( $? == 0 )); then
_p9k__state_dump_scheduled=1
@@ -5072,10 +5570,12 @@ function _p9k_asdf_parse_version_file() {
else
{ local v=($(<$file)) } 2>/dev/null
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
fi
- (( $#v )) && : ${versions[$plugin]="$v"}
+ [[ -n $v ]] && : ${versions[$plugin]="$v"}
done
else
local cached=$_p9k_asdf_file2versions[:$file]
@@ -5083,12 +5583,14 @@ function _p9k_asdf_parse_version_file() {
local file_versions=(${(0)${cached#*:}})
else
local file_versions=()
- { local lines=(${(@)${(f)"$(<$file)"}/\#*}) } 2>/dev/null
+ { local lines=(${(@)${(@)${(f)"$(<$file)"}%$'\r'}/\#*}) } 2>/dev/null
local line
for line in $lines; do
local words=($=line)
- (( $#words > 1 && $_p9k_asdf_plugins[(Ie)$words[1]] )) || continue
- file_versions+=($words[1] "${words[2,-1]}")
+ (( $#words > 1 )) || continue
+ local installed=$_p9k_asdf_plugins[$words[1]]
+ [[ -n $installed ]] || continue
+ file_versions+=($words[1] ${${words:1}[(r)$installed]:-$words[2]})
done
_p9k_asdf_file2versions[:$file]=$stat[1]:${(pj:\0:)file_versions}
_p9k__state_dump_scheduled=1
@@ -5106,10 +5608,14 @@ 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
@@ -5144,8 +5650,8 @@ function prompt_asdf() {
fi
local plugin
- for plugin in $_p9k_asdf_plugins; do
- local upper=${(U)plugin//-/_}
+ for plugin in ${(k)_p9k_asdf_plugins}; do
+ local upper=${${(U)plugin//-/_}//ฤฐ/I}
if (( $+parameters[_POWERLEVEL9K_ASDF_${upper}_SOURCES] )); then
local sources=(${(P)${:-_POWERLEVEL9K_ASDF_${upper}_SOURCES}})
else
@@ -5213,7 +5719,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
@@ -5240,6 +5746,68 @@ _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
+ if [[ -r /proc/sys/kernel/arch ]]; then
+ text=$(/dev/null && [[ $text == [a-zA-Z][a-zA-Z0-9_]# ]]; then
+ break
+ else
+ text=
+ fi
+ done
+ fi
+ 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() {
@@ -5249,8 +5817,10 @@ _p9k_preexec1() {
}
_p9k_preexec2() {
- _p9k__preexec_cmd=$2
+ typeset -g _p9k__preexec_cmd=$2
_p9k__timer_start=EPOCHREALTIME
+ P9K_TTY=old
+ (( ! $+_p9k__iterm_cmd )) || _p9k_iterm2_preexec "$1"
}
function _p9k_prompt_net_iface_init() {
@@ -5260,6 +5830,8 @@ 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=
@@ -5289,19 +5861,19 @@ function _p9k_prompt_net_iface_async() {
# netstat -inbI en0
local iface ip line var
typeset -a iface2ip ips ifaces
- if (( $+commands[ifconfig] )); then
- for line in ${(f)"$(command ifconfig 2>/dev/null)"}; do
- if [[ $line == (#b)([^[:space:]]##):[[:space:]]##flags=(<->)'<'* ]]; then
- [[ $match[2] == *[13579] ]] && iface=$match[1] || iface=
+ 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=
elif [[ -n $iface && $line == (#b)[[:space:]]##inet[[:space:]]##([0-9.]##)* ]]; then
iface2ip+=($iface $match[1])
iface=
fi
done
- 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 (( $+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=
@@ -5390,6 +5962,16 @@ 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
@@ -5403,6 +5985,8 @@ 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 \
@@ -5419,9 +6003,11 @@ _p9k_prompt_net_iface_sync() {
}
function _p9k_set_prompt() {
+ local -i _p9k__vcs_called
+
PROMPT=
RPROMPT=
- [[ $1 == instant_ ]] || PROMPT+='${$((_p9k_on_expand()))+}'
+ [[ $1 == instant_ ]] || PROMPT+='${$((_p9k_on_expand()))+}%{${_p9k__raw_msg-}${_p9k__raw_msg::=}%}'
PROMPT+=$_p9k_prompt_prefix_left
local -i _p9k__has_upglob
@@ -5437,7 +6023,7 @@ function _p9k_set_prompt() {
if [[ $1 == instant_ ]]; then
for _p9k__segment_name in ${${(0)_p9k_line_segments_right[_p9k__line_index]}%_joined}; do
if (( $+functions[instant_prompt_$_p9k__segment_name] )); then
- local disabled=_POWERLEVEL9K_${(U)_p9k__segment_name}_DISABLED_DIR_PATTERN
+ local disabled=_POWERLEVEL9K_${${(U)_p9k__segment_name}//ฤฐ/I}_DISABLED_DIR_PATTERN
if [[ $_p9k__cwd != ${(P)~disabled} ]]; then
local -i len=$#_p9k__prompt
_p9k__non_hermetic_expansion=0
@@ -5453,7 +6039,7 @@ function _p9k_set_prompt() {
for _p9k__segment_name in ${${(0)_p9k_line_segments_right[_p9k__line_index]}%_joined}; do
local cond=$_p9k__segment_cond_right[_p9k__segment_index]
if [[ -z $cond || -n ${(e)cond} ]]; then
- local disabled=_POWERLEVEL9K_${(U)_p9k__segment_name}_DISABLED_DIR_PATTERN
+ local disabled=_POWERLEVEL9K_${${(U)_p9k__segment_name}//ฤฐ/I}_DISABLED_DIR_PATTERN
if [[ $_p9k__cwd != ${(P)~disabled} ]]; then
local val=$_p9k__segment_val_right[_p9k__segment_index]
if [[ -n $val ]]; then
@@ -5483,7 +6069,7 @@ function _p9k_set_prompt() {
if [[ $1 == instant_ ]]; then
for _p9k__segment_name in ${${(0)_p9k_line_segments_left[_p9k__line_index]}%_joined}; do
if (( $+functions[instant_prompt_$_p9k__segment_name] )); then
- local disabled=_POWERLEVEL9K_${(U)_p9k__segment_name}_DISABLED_DIR_PATTERN
+ local disabled=_POWERLEVEL9K_${${(U)_p9k__segment_name}//ฤฐ/I}_DISABLED_DIR_PATTERN
if [[ $_p9k__cwd != ${(P)~disabled} ]]; then
local -i len=$#_p9k__prompt
_p9k__non_hermetic_expansion=0
@@ -5499,7 +6085,7 @@ function _p9k_set_prompt() {
for _p9k__segment_name in ${${(0)_p9k_line_segments_left[_p9k__line_index]}%_joined}; do
local cond=$_p9k__segment_cond_left[_p9k__segment_index]
if [[ -z $cond || -n ${(e)cond} ]]; then
- local disabled=_POWERLEVEL9K_${(U)_p9k__segment_name}_DISABLED_DIR_PATTERN
+ local disabled=_POWERLEVEL9K_${${(U)_p9k__segment_name}//ฤฐ/I}_DISABLED_DIR_PATTERN
if [[ $_p9k__cwd != ${(P)~disabled} ]]; then
local val=$_p9k__segment_val_left[_p9k__segment_index]
if [[ -n $val ]]; then
@@ -5543,7 +6129,7 @@ function _p9k_set_prompt() {
fi
fi
_p9k__prompt+='${${_p9k__d::=$((_p9k__m-_p9k__h))}+}'
- _p9k__prompt+='${_p9k__lprompt/\%\{d\%\}*\%\{d\%\}/'$_p9k__dir'}'
+ _p9k__prompt+='${_p9k__lprompt/\%\{d\%\}*\%\{d\%\}/${_p9k__'$_p9k__line_index'ldir-'$_p9k__dir'}}'
_p9k__prompt+='${${_p9k__m::=$((_p9k__d+_p9k__h))}+}'
else
_p9k__prompt+='${_p9k__lprompt}'
@@ -5577,7 +6163,7 @@ _p9k_set_instant_prompt() {
[[ -n $RPROMPT ]] || unset RPROMPT
}
-typeset -gri __p9k_instant_prompt_version=21
+typeset -gri __p9k_instant_prompt_version=47
_p9k_dump_instant_prompt() {
local user=${(%):-%n}
@@ -5593,28 +6179,47 @@ _p9k_dump_instant_prompt() {
local -i fd
sysopen -a -m 600 -o creat,trunc -u fd -- $tmp || return
{
- [[ $TERM_PROGRAM == Hyper ]] && local hyper='==' || local hyper='!='
+ [[ $TERM == (screen*|tmux*) ]] && local screen='-n' || local screen='-z'
local -a display_v=("${_p9k__display_v[@]}")
local -i i
for ((i = 6; i <= $#display_v; i+=2)); do display_v[i]=show; done
display_v[2]=hide
display_v[4]=hide
+ local gitstatus_dir=${${_POWERLEVEL9K_GITSTATUS_DIR:A}:-${__p9k_root_dir}/gitstatus}
+ local gitstatus_header
+ if [[ -r $gitstatus_dir/install.info ]]; then
+ IFS= read -r gitstatus_header <$gitstatus_dir/install.info || return
+ fi
+ >&$fd print -r -- '[[ -t 0 && -t 1 && -t 2 && -o interactive && -o zle && -o no_xtrace ]] &&
+ ! (( ${+__p9k_instant_prompt_disabled} || ZSH_SUBSHELL || ${+ZSH_SCRIPT} || ${+ZSH_EXECUTION_STRING} )) || return 0'
>&$fd print -r -- "() {
$__p9k_intro_no_locale
- (( ! \$+__p9k_instant_prompt_disabled )) || return
- typeset -gi __p9k_instant_prompt_disabled=1 __p9k_instant_prompt_sourced=$__p9k_instant_prompt_version
- [[ -t 0 && -t 1 && -t 2 && \$ZSH_VERSION == ${(q)ZSH_VERSION} && \$ZSH_PATCHLEVEL == ${(q)ZSH_PATCHLEVEL} &&
- \$TERM_PROGRAM $hyper 'Hyper' && \$+VTE_VERSION == $+VTE_VERSION &&
+ 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)}}" &&
\$POWERLEVEL9K_DISABLE_INSTANT_PROMPT != 'true' &&
- \$POWERLEVEL9K_INSTANT_PROMPT != 'off' ]] || { __p9k_instant_prompt_sourced=0; return 1; }
+ \$POWERLEVEL9K_INSTANT_PROMPT != 'off' ]] || return
+ typeset -g __p9k_instant_prompt_param_sig=${(q+)_p9k__param_sig}
+ local gitstatus_dir=${(q)gitstatus_dir}
+ local gitstatus_header=${(q)gitstatus_header}
local -i ZLE_RPROMPT_INDENT=${ZLE_RPROMPT_INDENT:-1}
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
+ local -i height=${_POWERLEVEL9K_INSTANT_PROMPT_COMMAND_LINES-1}
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 -- '
- zmodload zsh/langinfo
+ 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
+ fi
+ [[ $real_gitstatus_header == $gitstatus_header ]] || return
+ zmodload zsh/langinfo zsh/terminfo zsh/system || return
if [[ $langinfo[CODESET] != (utf|UTF)(-|)8 ]]; then
local loc_cmd=$commands[locale]
[[ -z $loc_cmd ]] && loc_cmd='${(q)commands[locale]}'
@@ -5626,24 +6231,33 @@ _p9k_dump_instant_prompt() {
fi
fi
fi
- zmodload zsh/terminfo
+ (( terminfo[colors] == '${terminfo[colors]:-0}' )) || return
(( $+terminfo[cuu] && $+terminfo[cuf] && $+terminfo[ed] && $+terminfo[sc] && $+terminfo[rc] )) || return
local pwd=${(%):-%/}
+ [[ $pwd == /* ]] || return
local prompt_file=$prompt_dir/prompt-${#pwd}
local key=$pwd:$ssh:${(%):-%#}
local content
+ if [[ ! -e $prompt_file ]]; then
+ typeset -gi __p9k_instant_prompt_sourced='$__p9k_instant_prompt_version'
+ return 1
+ fi
{ content="$(<$prompt_file)" } 2>/dev/null || return
local tail=${content##*$rs$key$us}
- [[ ${#tail} != ${#content} ]] || return
+ if (( ${#tail} == ${#content} )); then
+ typeset -gi __p9k_instant_prompt_sourced='$__p9k_instant_prompt_version'
+ return 1
+ fi
+ local _p9k__ipe
local P9K_PROMPT=instant
- if (( ! $+P9K_TTY )); then'
+ if [[ -z $P9K_TTY || $P9K_TTY == old && -n ${_P9K_TTY:#$TTY} ]]; then'
if (( _POWERLEVEL9K_NEW_TTY_MAX_AGE_SECONDS < 0 )); then
>&$fd print -r -- ' typeset -gx P9K_TTY=new'
else
>&$fd print -r -- '
typeset -gx P9K_TTY=old
- zmodload -F zsh/stat b:zstat
- zmodload zsh/datetime
+ zmodload -F zsh/stat b:zstat || return
+ zmodload zsh/datetime || return
local -a stat
if zstat -A stat +ctime -- $TTY 2>/dev/null &&
(( EPOCHREALTIME - stat[1] < '$_POWERLEVEL9K_NEW_TTY_MAX_AGE_SECONDS' )); then
@@ -5651,6 +6265,7 @@ _p9k_dump_instant_prompt() {
fi'
fi
>&$fd print -r -- ' fi
+ typeset -gx _P9K_TTY=$TTY
local -i _p9k__empty_line_i=3 _p9k__ruler_i=3
local -A _p9k_display_k=('${(j: :)${(@q)${(kv)_p9k_display_k}}}')
local -a _p9k__display_v=('${(j: :)${(@q)display_v}}')
@@ -5759,122 +6374,163 @@ _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 ]]; then
- if [[ $TERM_PROGRAM == Hyper ]]; then
- local bad_lines=40 bad_columns=100
- else
- local bad_lines=24 bad_columns=80
- fi
- >&$fd print -r -- '
- if (( LINES == '$bad_lines' && COLUMNS == '$bad_columns' )); then
- zmodload -F zsh/stat b:zstat
- zmodload zsh/datetime
- local -a tty_ctime
- if ! zstat -A tty_ctime +ctime -- $TTY 2>/dev/null || (( tty_ctime[1] + 2 > EPOCHREALTIME )); then
- zmodload zsh/datetime
- local -F deadline=$((EPOCHREALTIME+0.025))
- local tty_size
- while true; do
- if (( EPOCHREALTIME > deadline )) || ! tty_size="$(/bin/stty size 2>/dev/null)" || [[ $tty_size != <->" "<-> ]]; then
- (( $+_p9k__ruler_i )) || local -i _p9k__ruler_i=1
- local _p9k__g= _p9k__'$#_p9k_line_segments_right'r= _p9k__'$#_p9k_line_segments_right'r_frame=
- break
- fi
- if [[ $tty_size != "'$bad_lines' '$bad_columns'" ]]; then
- local lines_columns=(${=tty_size})
- local LINES=$lines_columns[1]
- local COLUMNS=$lines_columns[2]
- break
- fi
- done
+ local -a _p9k_t=("${(@ps:$us:)${tail%%$rs*}}")
+ if [[ $+VTE_VERSION == 1 || $TERM_PROGRAM == Hyper ]] && (( $+commands[stty] )); then
+ if [[ $TERM_PROGRAM == Hyper ]]; then
+ local bad_lines=40 bad_columns=100
+ else
+ local bad_lines=24 bad_columns=80
+ fi
+ if (( LINES == bad_lines && COLUMNS == bad_columns )); then
+ zmodload -F zsh/stat b:zstat || return
+ zmodload zsh/datetime || return
+ local -a tty_ctime
+ if ! zstat -A tty_ctime +ctime -- $TTY 2>/dev/null || (( tty_ctime[1] + 2 > EPOCHREALTIME )); then
+ local -F deadline=$((EPOCHREALTIME+0.025))
+ local tty_size
+ while true; do
+ if (( EPOCHREALTIME > deadline )) || ! tty_size="$(command stty size 2>/dev/null)" || [[ $tty_size != <->" "<-> ]]; then
+ (( $+_p9k__ruler_i )) || local -i _p9k__ruler_i=1
+ local _p9k__g= _p9k__'$#_p9k_line_segments_right'r= _p9k__'$#_p9k_line_segments_right'r_frame=
+ break
+ fi
+ if [[ $tty_size != "$bad_lines $bad_columns" ]]; then
+ local lines_columns=(${=tty_size})
+ local LINES=$lines_columns[1]
+ local COLUMNS=$lines_columns[2]
+ break
+ fi
+ done
+ fi
fi
fi'
- fi
(( __p9k_ksh_arrays )) && >&$fd print -r -- ' setopt ksh_arrays'
(( __p9k_sh_glob )) && >&$fd print -r -- ' setopt sh_glob'
>&$fd print -r -- ' typeset -ga __p9k_used_instant_prompt=("${(@e)_p9k_t[-3,-1]}")'
(( __p9k_ksh_arrays )) && >&$fd print -r -- ' unsetopt ksh_arrays'
(( __p9k_sh_glob )) && >&$fd print -r -- ' unsetopt sh_glob'
>&$fd print -r -- '
- (( height += ${#${__p9k_used_instant_prompt[1]//[^$lf]}} ))
+ local -i prompt_height=${#${__p9k_used_instant_prompt[1]//[^$lf]}}
+ (( height += prompt_height ))
local _p9k__ret
function _p9k_prompt_length() {
- local COLUMNS=1024
- local -i x y=$#1 m
+ local -i COLUMNS=1024
+ local -i x y=${#1} m
if (( y )); then
while (( ${${(%):-$1%$y(l.1.0)}[-1]} )); do
x=y
- (( y *= 2 ));
+ (( y *= 2 ))
done
- local xy
while (( y > x + 1 )); do
- m=$(( x + (y - x) / 2 ))
- typeset ${${(%):-$1%$m(l.x.y)}[-1]}=$m
+ (( m = x + (y - x) / 2 ))
+ (( ${${(%):-$1%$m(l.x.y)}[-1]} = m ))
done
fi
- _p9k__ret=$x
+ typeset -g _p9k__ret=$x
}
- local out'
- [[ $+VTE_VERSION == 1 || $TERM_PROGRAM == Hyper ]] && >&$fd print -r -- ' if (( ! $+_p9k__g )); then'
- >&$fd print -r -- '
- 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+="${(%):-%b%k%f%s%u$mark${(pl.$fill.. .)}$cr%b%k%f%s%u%E}"'
- [[ $+VTE_VERSION == 1 || $TERM_PROGRAM == Hyper ]] && >&$fd print -r -- ' fi'
- >&$fd print -r -- '
- out+="${(pl.$height..$lf.)}$esc${height}A$terminfo[sc]"
+ local out=${(%):-%b%k%f%s%u}
+ if [[ $P9K_TTY == old && ( $+VTE_VERSION == 0 && $TERM_PROGRAM != Hyper || $+_p9k__g == 0 ) ]]; 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]"
+ fi
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]"
- 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"
+ 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
fi
fi
- typeset -g __p9k_instant_prompt_output=${TMPDIR:-/tmp}/p10k-instant-prompt-output-${(%):-%n}-$$
- { echo -n > $__p9k_instant_prompt_output } || return
- print -rn -- "$out" || return
- exec {__p9k_fd_0}<&0 {__p9k_fd_1}>&1 {__p9k_fd_2}>&2 0$__p9k_instant_prompt_output
- exec 2>&1
+ 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
+ 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
+ exec 2>&1 {fd_null}>&-
typeset -gi __p9k_instant_prompt_active=1
+ if (( _z4h_can_save_restore_screen == 1 )); then
+ typeset -g _z4h_saved_screen
+ -z4h-save-screen
+ fi
typeset -g __p9k_instant_prompt_dump_file=${XDG_CACHE_HOME:-~/.cache}/p10k-dump-${(%):-%n}.zsh
- if source $__p9k_instant_prompt_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then
+ if builtin source $__p9k_instant_prompt_dump_file 2>/dev/null && (( $+functions[_p9k_preinit] )); then
_p9k_preinit
fi
+ function _p9k_instant_prompt_cleanup() {
+ (( ZSH_SUBSHELL == 0 && ${+__p9k_instant_prompt_active} )) || return 0
+ '$__p9k_intro_no_locale'
+ unset __p9k_instant_prompt_active
+ exec 0<&$__p9k_fd_0 1>&$__p9k_fd_1 2>&$__p9k_fd_2 {__p9k_fd_0}>&- {__p9k_fd_1}>&- {__p9k_fd_2}>&-
+ unset __p9k_fd_0 __p9k_fd_1 __p9k_fd_2
+ typeset -gi __p9k_instant_prompt_erased=1
+ if (( _z4h_can_save_restore_screen == 1 && __p9k_instant_prompt_sourced >= 35 )); then
+ -z4h-restore-screen
+ unset _z4h_saved_screen
+ fi
+ print -rn -- $terminfo[rc]${(%):-%b%k%f%s%u}$terminfo[ed]
+ if [[ -s $__p9k_instant_prompt_output ]]; then
+ command cat $__p9k_instant_prompt_output 2>/dev/null
+ if (( $1 )); then
+ local _p9k__ret mark="${(e)${PROMPT_EOL_MARK-%B%S%#%s%b}}"
+ _p9k_prompt_length $mark
+ local -i fill=$((COLUMNS > _p9k__ret ? COLUMNS - _p9k__ret : 0))
+ echo -nE - "${(%):-%b%k%f%s%u$mark${(pl.$fill.. .)}$cr%b%k%f%s%u%E}"
+ fi
+ fi
+ zshexit_functions=(${zshexit_functions:#_p9k_instant_prompt_cleanup})
+ zmodload -F zsh/files b:zf_rm || return
+ local user=${(%):-%n}
+ local root_dir=${__p9k_instant_prompt_dump_file:h}
+ zf_rm -f -- $__p9k_instant_prompt_output $__p9k_instant_prompt_dump_file{,.zwc} $root_dir/p10k-instant-prompt-$user.zsh{,.zwc} $root_dir/p10k-$user/prompt-*(N) 2>/dev/null
+ }
function _p9k_instant_prompt_precmd_first() {
'$__p9k_intro'
function _p9k_instant_prompt_sched_last() {
- (( $+__p9k_instant_prompt_active )) || return 0
- () {
- '$__p9k_intro'
- exec 0<&$__p9k_fd_0 1>&$__p9k_fd_1 2>&$__p9k_fd_2 {__p9k_fd_0}>&- {__p9k_fd_1}>&- {__p9k_fd_2}>&-
- unset __p9k_fd_0 __p9k_fd_1 __p9k_fd_2 __p9k_instant_prompt_active
- typeset -gi __p9k_instant_prompt_erased=1
- print -rn -- $terminfo[rc]${(%):-%b%k%f%s%u}$terminfo[ed]
- if [[ -s $__p9k_instant_prompt_output ]]; then
- cat $__p9k_instant_prompt_output 2>/dev/null
- local _p9k__ret mark="${(e)${PROMPT_EOL_MARK-%B%S%#%s%b}}"
- _p9k_prompt_length $mark
- local -i fill=$((COLUMNS > _p9k__ret ? COLUMNS - _p9k__ret : 0))
- echo -nE - "${(%):-%b%k%f%s%u$mark${(pl.$fill.. .)}$cr%b%k%f%s%u%E}"
- fi
- zmodload -F zsh/files b:zf_rm
- zf_rm -f -- $__p9k_instant_prompt_output ${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh{,.zwc} 2>/dev/null
- }
+ (( ${+__p9k_instant_prompt_active} )) || return 0
+ _p9k_instant_prompt_cleanup 1
setopt no_local_options prompt_cr prompt_sp
}
zmodload zsh/sched
sched +0 _p9k_instant_prompt_sched_last
precmd_functions=(${(@)precmd_functions:#_p9k_instant_prompt_precmd_first})
}
+ zshexit_functions=(_p9k_instant_prompt_cleanup $zshexit_functions)
precmd_functions=(_p9k_instant_prompt_precmd_first $precmd_functions)
DISABLE_UPDATE_PROMPT=true
-} && unsetopt prompt_cr prompt_sp || true'
+} && unsetopt prompt_cr prompt_sp && typeset -gi __p9k_instant_prompt_sourced='$__p9k_instant_prompt_version' ||
+ typeset -gi __p9k_instant_prompt_sourced=${__p9k_instant_prompt_sourced:-0}'
} always {
exec {fd}>&-
}
@@ -5974,7 +6630,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|OS|DEFAULT_COLOR|DEFAULT_COLOR_INVERTED' >&$fd || return
+ typeset -pm '_POWERLEVEL9K_*|_p9k_[^_]*|icons' >&$fd || return
print -r -- '}' >&$fd || return
} always {
exec {fd}>&-
@@ -6000,16 +6656,20 @@ function _p9k_restore_state() {
[[ $__p9k_cached_param_pat == $_p9k__param_pat && $__p9k_cached_param_sig == $_p9k__param_sig ]] || return
(( $+functions[_p9k_restore_state_impl] )) || return
_p9k_restore_state_impl
- _p9k__state_restored=1
+ return 0
} always {
- unset __p9k_cached_param_sig
- if (( !_p9k__state_restored )); then
+ if (( $? )); then
if (( $+functions[_p9k_preinit] )); then
unfunction _p9k_preinit
(( $+functions[gitstatus_stop_p9k_] )) && gitstatus_stop_p9k_ POWERLEVEL9K
fi
_p9k_delete_instant_prompt
+ zf_rm -f -- $__p9k_dump_file{,.zwc} 2>/dev/null
+ elif [[ $__p9k_instant_prompt_param_sig != $_p9k__param_sig ]]; then
+ _p9k_delete_instant_prompt
+ _p9k_dumped_instant_prompt_sigs=()
fi
+ unset __p9k_cached_param_sig
}
}
@@ -6020,6 +6680,7 @@ function _p9k_clear_instant_prompt() {
fi
exec 1>&$__p9k_fd_1 2>&$__p9k_fd_2 {__p9k_fd_1}>&- {__p9k_fd_2}>&-
unset __p9k_fd_1 __p9k_fd_2
+ zshexit_functions=(${zshexit_functions:#_p9k_instant_prompt_cleanup})
if (( _p9k__can_hide_cursor )); then
echoti civis
_p9k__cursor_hidden=1
@@ -6033,13 +6694,23 @@ function _p9k_clear_instant_prompt() {
local -i fill=$((COLUMNS > _p9k__ret ? COLUMNS - _p9k__ret : 0))
local cr=$'\r'
local sp="${(%):-%b%k%f%s%u$mark${(pl.$fill.. .)}$cr%b%k%f%s%u%E}"
+ if (( _z4h_can_save_restore_screen == 1 && __p9k_instant_prompt_sourced >= 35 )); then
+ -z4h-restore-screen
+ unset _z4h_saved_screen
+ fi
print -rn -- $terminfo[rc]${(%):-%b%k%f%s%u}$terminfo[ed]
- local unexpected=${${${(S)content//$'\e'*($'\a'|$'\e\\')}//$'\e[?'<->'c'}//$'\e['<->' q'}
+ 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")
if [[ -n $unexpected ]]; then
local omz1='[Oh My Zsh] Would you like to update? [Y/n]: '
local omz2='Updating Oh My Zsh'
local omz3='https://shop.planetargon.com/collections/oh-my-zsh'
- if [[ -n ${${unexpected/$omz1}/$omz2*$omz3($'\n'|)} ]]; then
+ local omz4='There was an error updating. Try again later?'
+ if [[ $unexpected != ($omz1|)$omz2*($omz3|$omz4)[^$'\n']#($'\n'|) ]]; then
echo -E - ""
echo -E - "${(%):-[%3FWARNING%f]: Console output during zsh initialization detected.}"
echo -E - ""
@@ -6077,21 +6748,25 @@ 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/blob/master/README.md#instant-prompt\ahttps://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt\e]8;;\a}"
+ echo - "${(%):-\e]8;;https://github.com/romkatv/powerlevel10k#instant-prompt\ahttps://github.com/romkatv/powerlevel10k#instant-prompt\e]8;;\a}"
else
- echo - "${(%):-https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt}"
+ echo - "${(%):-https://github.com/romkatv/powerlevel10k#instant-prompt}"
fi
echo -E - ""
echo - "${(%):-%3F-- console output produced during zsh initialization follows --%f}"
echo -E - ""
fi
fi
- cat -- $__p9k_instant_prompt_output
+ command cat -- $__p9k_instant_prompt_output
echo -nE - $sp
zf_rm -f -- $__p9k_instant_prompt_output
} 2>/dev/null
else
zf_rm -f -- $__p9k_instant_prompt_output 2>/dev/null
+ if (( _z4h_can_save_restore_screen == 1 && __p9k_instant_prompt_sourced >= 35 )); then
+ -z4h-restore-screen
+ unset _z4h_saved_screen
+ fi
print -rn -- $terminfo[rc]${(%):-%b%k%f%s%u}$terminfo[ed]
fi
prompt_opts=(percent subst sp cr)
@@ -6134,6 +6809,7 @@ function _p9k_do_dump() {
eval "$__p9k_intro"
zle -F $1
exec {1}>&-
+ (( _p9k__state_dump_fd )) || return
if (( ! _p9k__instant_prompt_disabled )); then
_p9k__instant_prompt_sig=$_p9k__cwd:$P9K_SSH:${(%):-%#}
_p9k_set_instant_prompt
@@ -6194,11 +6870,11 @@ function _p9k_on_expand() {
if (( ! _p9k__expanded )); then
if _p9k_should_dump; then
- exec {_p9k__state_dump_fd}/dev/null
+ () {
+ local key
+ while true; do
+ [[ -t 2 ]]
+ read -t0 -k key || break
+ done 2>/dev/null
+ }
+ _p9k_can_configure -q
+ ret=$?
+ fi
+ if (( ret == 0 )); then
+ if (( $+commands[git] )); then
(
- source "$__p9k_root_dir"/internal/wizard.zsh
+ local -i pid
+ {
+ { /bin/sh "$__p9k_root_dir"/gitstatus/install /dev/null & } && pid=$!
+ ( builtin source "$__p9k_root_dir"/internal/wizard.zsh )
+ } always {
+ if (( pid )); then
+ kill -- $pid 2>/dev/null
+ wait -- $pid 2>/dev/null
+ fi
+ }
)
- if (( $? )); then
- instant_prompt_disabled=1
- else
- source "$__p9k_cfg_path"
- _p9k__force_must_init=1
- _p9k_must_init
- fi
- ;;
- 2)
- _p9k_delete_instant_prompt
+ else
+ ( builtin source "$__p9k_root_dir"/internal/wizard.zsh )
+ fi
+ if (( $? )); then
instant_prompt_disabled=1
- ;;
- esac
+ else
+ builtin source "$__p9k_cfg_path"
+ _p9k__force_must_init=1
+ _p9k_must_init
+ fi
+ fi
fi
fi
+ typeset -gi _p9k__instant_prompt_disabled=instant_prompt_disabled
_p9k_init
- _p9k__instant_prompt_disabled=$((_POWERLEVEL9K_DISABLE_INSTANT_PROMPT || instant_prompt_disabled))
fi
if (( _p9k__timer_start )); then
@@ -6361,6 +7062,10 @@ _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
@@ -6374,6 +7079,7 @@ _p9k_precmd_impl() {
local -F start_time=EPOCHREALTIME
unset _p9k__vcs
unset _p9k__vcs_timeout
+ local -i _p9k__vcs_called
_p9k_vcs_gitstatus
local -i fast_vcs=1
fi
@@ -6408,7 +7114,7 @@ _p9k_precmd_impl() {
fi
if (( ! $+_p9k__vcs )); then
local _p9k__prompt _p9k__prompt_side=$_p9k_vcs_side _p9k__segment_name=vcs
- local -i _p9k__has_upglob _p9k__segment_index=_p9k_vcs_index
+ local -i _p9k__has_upglob _p9k__segment_index=_p9k_vcs_index _p9k__line_index=_p9k_vcs_line_index
_p9k_vcs_render
typeset -g _p9k__vcs=$_p9k__prompt
fi
@@ -6421,6 +7127,7 @@ _p9k_precmd_impl() {
_p9k_trapint() {
if (( __p9k_enabled )); then
eval "$__p9k_intro"
+ _p9k_deschedule_redraw
zle && _p9k_on_widget_zle-line-finish int
fi
return 0
@@ -6444,6 +7151,8 @@ _p9k_precmd() {
# See https://www.zsh.org/mla/workers/2020/msg00612.html for the reason behind __p9k_trapint.
typeset -g __p9k_trapint='_p9k_trapint; return 130'
trap "$__p9k_trapint" INT
+
+ : ${(%):-%b%k%s%u}
}
function _p9k_reset_prompt() {
@@ -6452,12 +7161,12 @@ function _p9k_reset_prompt() {
setopt prompt_subst
(( __p9k_ksh_arrays )) && setopt ksh_arrays
(( __p9k_sh_glob )) && setopt sh_glob
- (( _p9k__can_hide_cursor )) && echoti civis
{
+ (( _p9k__can_hide_cursor )) && echoti civis
zle .reset-prompt
- zle -R
+ (( ${+functions[z4h]} )) || zle -R
} always {
- (( _p9k__can_hide_cursor )) && echoti cnorm
+ (( _p9k__can_hide_cursor )) && print -rn -- $_p9k__cnorm
_p9k__cursor_hidden=0
}
fi
@@ -6469,14 +7178,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.
+# ZSH_PATCHLEVEL=zsh-5.7.1-50-g64d137383. Released in 5.7.2.
#
# Test: PROMPT="${(pl:$((COLUMNS))::-:)}<%1(l.%2(l.FAIL.PASS).FAIL)> " zsh -dfis <<= 50 ))
- is-at-least 5.5 && ! is-at-least 5.7.2
+ [[ $ZSH_VERSION == 5.<5-7>* && $ZSH_VERSION != 5.7.<2->* ]]
}
typeset -g _p9k__param_pat
@@ -6492,6 +7201,7 @@ _p9k_init_vars() {
typeset -gi _p9k_term_has_href
typeset -gi _p9k_vcs_index
+ typeset -gi _p9k_vcs_line_index
typeset -g _p9k_vcs_side
typeset -ga _p9k_taskwarrior_meta_files
@@ -6503,13 +7213,15 @@ _p9k_init_vars() {
typeset -ga _p9k_taskwarrior_data_non_files
typeset -g _p9k_taskwarrior_data_sig
typeset -gA _p9k_taskwarrior_counters
+ typeset -gF _p9k_taskwarrior_next_due
typeset -ga _p9k_asdf_meta_files
typeset -ga _p9k_asdf_meta_non_files
typeset -g _p9k_asdf_meta_sig
- # example: (ruby lua chubaka)
- typeset -ga _p9k_asdf_plugins
+ # plugin => installed_version_pattern
+ # example: (ruby '2.7.0|2.6.3|system' lua 'system' chubaka '1.0.0|system')
+ typeset -gA _p9k_asdf_plugins
# example: (.ruby-version "ruby 1 chubaka 0")
#
@@ -6574,9 +7286,17 @@ _p9k_init_vars() {
typeset -gi _p9k__fully_initialized
typeset -gi _p9k__must_restore_prompt
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__instant_prompt_disabled
typeset -gi _p9k__non_hermetic_expansion
typeset -g _p9k__time
typeset -g _p9k__date
@@ -6586,7 +7306,6 @@ _p9k_init_vars() {
typeset -gi _p9k__state_dump_scheduled
typeset -gi _p9k__state_dump_fd
typeset -gi _p9k__prompt_idx
- typeset -gi _p9k__state_restored
typeset -gi _p9k_reset_on_line_finish
typeset -gF _p9k__timer_start
typeset -gi _p9k__status
@@ -6606,6 +7325,7 @@ _p9k_init_vars() {
typeset -ga _p9k_left_join
typeset -ga _p9k_right_join
typeset -g _p9k__public_ip
+ typeset -g _p9k__todo_command
typeset -g _p9k__todo_file
typeset -g _p9k__git_dir
# git workdir => 1 if gitstatus is slow on it, 0 if it's fast.
@@ -6701,9 +7421,16 @@ _p9k_init_params() {
fi
fi
+ (( _POWERLEVEL9K_DISABLE_INSTANT_PROMPT )) && _p9k__instant_prompt_disabled=1
+
_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 --
@@ -6711,7 +7438,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 1
+ _p9k_declare -i POWERLEVEL9K_INSTANT_PROMPT_COMMAND_LINES
_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
@@ -6735,6 +7462,36 @@ _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
@@ -6756,9 +7513,11 @@ _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
+ _p9k_declare -i POWERLEVEL9K_BATTERY_${state}_HIDE_ABOVE_THRESHOLD $_POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD
local var=POWERLEVEL9K_BATTERY_${state}_STAGES
case $parameters[$var] in
scalar*) eval "typeset -ga _$var=(${(@qq)${(@s::)${(g::)${(P)var}}}})";;
@@ -6797,6 +7556,7 @@ _p9k_init_params() {
case $_POWERLEVEL9K_DIR_SHOW_WRITABLE in
true) _POWERLEVEL9K_DIR_SHOW_WRITABLE=1;;
v2) _POWERLEVEL9K_DIR_SHOW_WRITABLE=2;;
+ v3) _POWERLEVEL9K_DIR_SHOW_WRITABLE=3;;
*) _POWERLEVEL9K_DIR_SHOW_WRITABLE=0;;
esac
typeset -gi _POWERLEVEL9K_DIR_SHOW_WRITABLE
@@ -6871,9 +7631,8 @@ _p9k_init_params() {
_p9k_declare -e POWERLEVEL9K_SHORTEN_DELIMITER
_p9k_declare -s POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER ''
case $_POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER in
- first) ;;
- last) ;;
- true) _POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=last;;
+ first|last) _POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER+=:0;;
+ (first|last):(|-)<->);;
*) _POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=;;
esac
[[ -z $_POWERLEVEL9K_SHORTEN_FOLDER_MARKER ]] && _POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=
@@ -6881,7 +7640,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 "(wg|(.*tun))[0-9]*"
+ _p9k_declare -s POWERLEVEL9K_VPN_IP_INTERFACE "(gpd|wg|(.*tun)|tailscale)[0-9]*|(zt.*)"
: ${_POWERLEVEL9K_VPN_IP_INTERFACE:='.*'}
_p9k_segment_in_use vpn_ip || _POWERLEVEL9K_VPN_IP_INTERFACE=
_p9k_declare -b POWERLEVEL9K_VPN_IP_SHOW_ALL 0
@@ -6891,18 +7650,27 @@ _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
+ _p9k_declare -b POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW 0
+ _p9k_declare -a POWERLEVEL9K_SCALAENV_SOURCES -- shell local global
+ _p9k_declare -b POWERLEVEL9K_SCALAENV_SHOW_SYSTEM 1
_p9k_declare -b POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW 0
_p9k_declare -a POWERLEVEL9K_PHPENV_SOURCES -- shell local global
_p9k_declare -b POWERLEVEL9K_PHPENV_SHOW_SYSTEM 1
@@ -6940,6 +7708,10 @@ _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
@@ -6961,9 +7733,10 @@ _p9k_init_params() {
_p9k_declare -a POWERLEVEL9K_VCS_SVN_HOOKS -- vcs-detect-changes svn-detect-changes
# If it takes longer than this to fetch git repo status, display the prompt with a greyed out
# vcs segment and fix it asynchronously when the results come it.
- _p9k_declare -F POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS 0.02
+ _p9k_declare -F POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS 0.01
(( POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS >= 0 )) || (( POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS = 0 ))
_p9k_declare -a POWERLEVEL9K_VCS_BACKENDS -- git
+ (( $+commands[git] )) || _POWERLEVEL9K_VCS_BACKENDS=(${_POWERLEVEL9K_VCS_BACKENDS:#git})
_p9k_declare -b POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING 0
_p9k_declare -i POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY -1
_p9k_declare -i POWERLEVEL9K_VCS_STAGED_MAX_NUM 1
@@ -6973,6 +7746,7 @@ _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"
@@ -6980,6 +7754,7 @@ _p9k_init_params() {
_p9k_declare -e POWERLEVEL9K_VI_VISUAL_MODE_STRING
# OVERWRITE mode is shown as INSERT unless POWERLEVEL9K_VI_OVERWRITE_MODE_STRING is explicitly set.
_p9k_declare -e POWERLEVEL9K_VI_OVERWRITE_MODE_STRING
+ _p9k_declare -s POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV true
_p9k_declare -b POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION 1
_p9k_declare -e POWERLEVEL9K_VIRTUALENV_LEFT_DELIMITER "("
_p9k_declare -e POWERLEVEL9K_VIRTUALENV_RIGHT_DELIMITER ")"
@@ -7015,7 +7790,9 @@ _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
# Specifies the format of java version.
#
@@ -7035,9 +7812,15 @@ _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]}
+ local segment=${${(U)_POWERLEVEL9K_LEFT_PROMPT_ELEMENTS[i]}//ฤฐ/I}
local var=POWERLEVEL9K_${segment}_LEFT_DISABLED
(( $+parameters[$var] )) || var=POWERLEVEL9K_${segment}_DISABLED
if [[ ${(P)var} == true ]]; then
@@ -7049,7 +7832,7 @@ _p9k_init_params() {
local -i i=1
while (( i <= $#_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS )); do
- local segment=${(U)_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[i]}
+ local segment=${${(U)_POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS[i]}//ฤฐ/I}
local var=POWERLEVEL9K_${segment}_RIGHT_DISABLED
(( $+parameters[$var] )) || var=POWERLEVEL9K_${segment}_DISABLED
if [[ ${(P)var} == true ]]; then
@@ -7072,7 +7855,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 is-at-least 5.3; then
+if [[ $ZSH_VERSION == (5.<3->*|<6->.*) ]]; then
function _p9k_check_visual_mode() {
[[ ${KEYMAP:-} == vicmd ]] || return 0
local region=${${REGION_ACTIVE:-0}/2/1}
@@ -7091,44 +7874,52 @@ 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
- echoti cnorm
+ print -rn -- $_p9k__cnorm
}
function _p9k_on_widget_zle-line-finish() {
(( $+_p9k__line_finished )) && return
+ local P9K_PROMPT=transient
+
_p9k__line_finished=
(( _p9k_reset_on_line_finish )) && __p9k_reset_state=2
(( $+functions[p10k-on-post-prompt] )) && p10k-on-post-prompt
+ local -i optimized
+
if [[ -n $_p9k_transient_prompt ]]; then
if [[ $_POWERLEVEL9K_TRANSIENT_PROMPT == always || $_p9k__cwd == $_p9k__last_prompt_pwd ]]; then
- RPROMPT=
- PROMPT=$_p9k_transient_prompt
+ optimized=1
__p9k_reset_state=2
else
_p9k__last_prompt_pwd=$_p9k__cwd
fi
fi
+ if [[ $1 == int ]]; then
+ _p9k__must_restore_prompt=1
+ if (( !_p9k__restore_prompt_fd )); then
+ sysopen -o cloexec -ru _p9k__restore_prompt_fd /dev/null
+ zle -F $_p9k__restore_prompt_fd _p9k_restore_prompt
+ fi
+ fi
+
if (( __p9k_reset_state == 2 )); then
- if [[ $1 == int ]]; then
- _p9k__must_restore_prompt=1
- if (( !_p9k__restore_prompt_fd )); then
- exec {_p9k__restore_prompt_fd}&-
+ _p9k__redraw_fd=0
+
+ () {
+ local -h WIDGET=zle-line-pre-redraw
+ _p9k_widget_hook ''
+ }
+}
+
+function _p9k_deschedule_redraw() {
+ (( _p9k__redraw_fd )) || return
+ zle -F $_p9k__redraw_fd
+ exec {_p9k__redraw_fd}>&-
+ _p9k__redraw_fd=0
+}
+
function _p9k_widget_hook() {
- if (( $+functions[p10k-on-post-widget] || $#_p9k_show_on_command )); then
+ _p9k_deschedule_redraw
+
+ if (( ${+functions[p10k-on-post-widget]} || ${#_p9k_show_on_command} )); then
local -a P9K_COMMANDS
if [[ "$_p9k__last_buffer" == "$PREBUFFER$BUFFER" ]]; then
P9K_COMMANDS=(${_p9k__last_commands[@]})
@@ -7154,7 +7965,7 @@ function _p9k_widget_hook() {
eval "$__p9k_intro"
(( _p9k__restore_prompt_fd )) && _p9k_restore_prompt $_p9k__restore_prompt_fd
- if [[ $1 == clear-screen ]]; then
+ if [[ $1 == (clear-screen|z4h-clear-screen-*-top) ]]; then
P9K_TTY=new
_p9k__expanded=0
_p9k_reset_prompt
@@ -7176,19 +7987,52 @@ function _p9k_widget_hook() {
}
function _p9k_widget() {
- (( ! ${+widgets[._p9k_orig_$1]} )) || zle ._p9k_orig_$1 "${@:2}"
- local res=$?
+ local f=${widgets[._p9k_orig_$1]:-}
+ local -i res
+ [[ -z $f ]] || {
+ [[ $f == user:-z4h-* ]] && {
+ "${f#user:}" "${@:2}"
+ res=$?
+ } || {
+ zle ._p9k_orig_$1 -- "${@:2}"
+ 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
+ }
+ return
+ }
+ _p9k_widget_hook zle-line-pre-redraw
+}
+
+function _p9k_widget_send-break() {
+ (( ! __p9k_enabled )) || [[ $CONTEXT != start ]] || {
+ _p9k_widget_hook send-break "$@"
+ }
+ local f=${widgets[._p9k_orig_send-break]:-}
+ [[ -z $f ]] || zle ._p9k_orig_send-break -- "$@"
+}
+
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 is-at-least 5.3; then
+ if [[ $ZSH_VERSION == (5.<3->*|<6->.*) ]]; then
local -aU widget_list=(
zle-line-pre-redraw
zle-line-init
@@ -7200,13 +8044,21 @@ function _p9k_wrap_widgets() {
visual-line-mode
deactivate-region
clear-screen
+ z4h-clear-screen-soft-top
+ z4h-clear-screen-hard-top
+ send-break
$_POWERLEVEL9K_HOOK_WIDGETS
)
else
# 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.
- local keymap tmp=${TMPDIR:-/tmp}/p10k.bindings.$sysparams[pid]
+ 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]
{
for keymap in $keymaps; do bindkey -M $keymap; done >$tmp
local -aU widget_list=(
@@ -7216,6 +8068,7 @@ function _p9k_wrap_widgets() {
zle-line-finish
zle-history-line-set
zle-keymap-select
+ send-break
$_POWERLEVEL9K_HOOK_WIDGETS
${${${(f)"$(<$tmp)"}##* }:#(*\"|.*)}
)
@@ -7223,13 +8076,44 @@ function _p9k_wrap_widgets() {
zf_rm -f -- $tmp
}
fi
+
local widget
for widget in $widget_list; do
- functions[_p9k_widget_$widget]='_p9k_widget '${(q)widget}' "$@"'
- # The leading dot is to work around bugs in zsh-syntax-highlighting.
- zle -A $widget ._p9k_orig_$widget
- zle -N $widget _p9k_widget_$widget
+ 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
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() {
@@ -7255,25 +8139,29 @@ instant_prompt__p9k_internal_nothing() { prompt__p9k_internal_nothing; }
# _p9k_build_gap_post line_number
_p9k_build_gap_post() {
- [[ $1 == 1 ]] && local kind=first || local kind=newline
- _p9k_get_icon '' MULTILINE_${(U)kind}_PROMPT_GAP_CHAR
+ if [[ $1 == 1 ]]; then
+ local kind_l=first kind_u=FIRST
+ else
+ local kind_l=newline kind_u=NEWLINE
+ fi
+ _p9k_get_icon '' MULTILINE_${kind_u}_PROMPT_GAP_CHAR
local char=${_p9k__ret:- }
_p9k_prompt_length $char
if (( _p9k__ret != 1 || $#char != 1 )); then
- >&2 print -rP -- "%F{red}WARNING!%f %BMULTILINE_${(U)kind}_PROMPT_GAP_CHAR%b is not one character long. Will use ' '."
- >&2 print -rP -- "Either change the value of %BPOWERLEVEL9K_MULTILINE_${(U)kind}_PROMPT_GAP_CHAR%b or remove it."
+ >&2 print -rP -- "%F{red}WARNING!%f %BMULTILINE_${kind_u}_PROMPT_GAP_CHAR%b is not one character long. Will use ' '."
+ >&2 print -rP -- "Either change the value of %BPOWERLEVEL9K_MULTILINE_${kind_u}_PROMPT_GAP_CHAR%b or remove it."
char=' '
fi
local style
- _p9k_color prompt_multiline_${kind}_prompt_gap BACKGROUND ""
+ _p9k_color prompt_multiline_${kind_l}_prompt_gap BACKGROUND ""
[[ -n $_p9k__ret ]] && _p9k_background $_p9k__ret
style+=$_p9k__ret
- _p9k_color prompt_multiline_${kind}_prompt_gap FOREGROUND ""
+ _p9k_color prompt_multiline_${kind_l}_prompt_gap FOREGROUND ""
[[ -n $_p9k__ret ]] && _p9k_foreground $_p9k__ret
style+=$_p9k__ret
_p9k_escape_style $style
style=$_p9k__ret
- local exp=_POWERLEVEL9K_MULTILINE_${(U)kind}_PROMPT_GAP_EXPANSION
+ local exp=_POWERLEVEL9K_MULTILINE_${kind_u}_PROMPT_GAP_EXPANSION
(( $+parameters[$exp] )) && exp=${(P)exp} || exp='${P9K_GAP}'
[[ $char == '.' ]] && local s=',' || local s='.'
_p9k__ret=$'${${_p9k__g+\n}:-'$style'${${${_p9k__m:#-*}:+'
@@ -7490,7 +8378,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' '' &&
- ! is-at-least 5.7.2; then
+ [[ $ZSH_VERSION != (5.7.<2->*|5.<8->*|<6->.*) ]]; 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}}'
@@ -7499,9 +8387,21 @@ _p9k_init_prompt() {
_p9k_prompt_prefix_left+='${${_p9k__ind::=${${ZLE_RPROMPT_INDENT:-1}/#-*/0}}+}'
fi
- if [[ $ITERM_SHELL_INTEGRATION_INSTALLED == Yes ]]; then
+ 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 (( $+_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
+ fi
fi
if (( _POWERLEVEL9K_PROMPT_ADD_NEWLINE_COUNT > 0 )); then
@@ -7516,6 +8416,23 @@ _p9k_init_prompt() {
_p9k_prompt_prefix_left+='${_p9k_t[${_p9k__empty_line_i:-'$#_p9k_t'}]}'
fi
+ local -i num_lines=$#_p9k_line_segments_left
+ if (( $+terminfo[cuu1] )); then
+ _p9k_escape $terminfo[cuu1]
+ if (( __p9k_ksh_arrays )); then
+ local scroll=$'${_p9k_t[${_p9k__ruler_i:-1}-1]:+\n'$_p9k__ret'}'
+ else
+ local scroll=$'${_p9k_t[${_p9k__ruler_i:-1}]:+\n'$_p9k__ret'}'
+ fi
+ if (( num_lines > 1 )); then
+ local -i line_index=
+ for line_index in {1..$((num_lines-1))}; do
+ scroll='${_p9k__'$line_index-$'\n}'$scroll'${_p9k__'$line_index-$_p9k__ret'}'
+ done
+ fi
+ _p9k_prompt_prefix_left+='%{${_p9k__ipe-'$scroll'}%}'
+ fi
+
_p9k_get_icon '' RULER_CHAR
local ruler_char=$_p9k__ret
_p9k_prompt_length $ruler_char
@@ -7560,8 +8477,9 @@ _p9k_init_ssh() {
#
# License: https://github.com/sindresorhus/pure/blob/e8abf9d37185ec9b7b4398ca9c5eba555a1028eb/license.
- [[ -n $P9K_SSH ]] && return
+ [[ -n $P9K_SSH && $_P9K_SSH_TTY == $TTY ]] && 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
@@ -7583,6 +8501,21 @@ _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)"$(|4801)}\1$DEFAULT_USER\1$P9K_SSH\1$+commands[uname]\1'
+ _p9k__param_pat+=$'$__p9k_root_dir\1$functions[p10k-on-init]\1$functions[p10k-on-pre-prompt]\1'
+ _p9k__param_pat+=$'$functions[p10k-on-post-widget]\1$functions[p10k-on-post-prompt]\1'
+ _p9k__param_pat+=$'$+commands[git]\1$terminfo[colors]\1${+_z4h_iterm_cmd}\1'
+ _p9k__param_pat+=$'$_z4h_can_save_restore_screen'
local MATCH
IFS=$'\1' _p9k__param_pat+="${(@)${(@o)parameters[(I)POWERLEVEL9K_*]}:/(#m)*/\${${(q)MATCH}-$IFS\}}"
IFS=$'\2' _p9k__param_sig="${(e)_p9k__param_pat}"
@@ -7627,16 +8563,16 @@ function _p9k_init_cacheable() {
local -i i=0
for i in {1..$#_p9k_line_segments_left}; do
- for elem in ${${(@0)_p9k_line_segments_left[i]}%_joined}; do
- local var=POWERLEVEL9K_${(U)elem}_SHOW_ON_COMMAND
+ for elem in ${${${(@0)_p9k_line_segments_left[i]}%_joined}//-/_}; do
+ local var=POWERLEVEL9K_${${(U)elem}//ฤฐ/I}_SHOW_ON_COMMAND
(( $+parameters[$var] )) || continue
_p9k_show_on_command+=(
$'(|*[/\0])('${(j.|.)${(P)var}}')'
$((1+_p9k_display_k[$i/left/$elem]))
_p9k__${i}l$elem)
done
- for elem in ${${(@0)_p9k_line_segments_right[i]}%_joined}; do
- local var=POWERLEVEL9K_${(U)elem}_SHOW_ON_COMMAND
+ for elem in ${${${(@0)_p9k_line_segments_right[i]}%_joined}//-/_}; do
+ local var=POWERLEVEL9K_${${(U)elem}//ฤฐ/I}_SHOW_ON_COMMAND
(( $+parameters[$var] )) || continue
local cmds=(${(P)var})
_p9k_show_on_command+=(
@@ -7647,15 +8583,34 @@ function _p9k_init_cacheable() {
done
if [[ $_POWERLEVEL9K_TRANSIENT_PROMPT != off ]]; then
- _p9k_transient_prompt='%b%k%s%u%F{%(?.'
+ local sep=$'\1'
+ _p9k_transient_prompt='%b%k%s%u%(?'$sep
_p9k_color prompt_prompt_char_OK_VIINS FOREGROUND 76
- _p9k_transient_prompt+=$_p9k__ret'.'
- _p9k_color prompt_prompt_char_ERROR_VIINS FOREGROUND 196
- _p9k_transient_prompt+=$_p9k__ret')}${${P9K_CONTENT::="โฏ"}+}'
+ _p9k_foreground $_p9k__ret
+ _p9k_transient_prompt+=$_p9k__ret
+ _p9k_transient_prompt+='${${P9K_CONTENT::="โฏ"}+}'
_p9k_param prompt_prompt_char_OK_VIINS CONTENT_EXPANSION '${P9K_CONTENT}'
- _p9k_transient_prompt+='${:-"'$_p9k__ret'"}%b%k%f%s%u '
- if [[ $ITERM_SHELL_INTEGRATION_INSTALLED == Yes ]]; then
+ _p9k_transient_prompt+='${:-"'$_p9k__ret'"}'
+ _p9k_transient_prompt+=$sep
+ _p9k_color prompt_prompt_char_ERROR_VIINS FOREGROUND 196
+ _p9k_foreground $_p9k__ret
+ _p9k_transient_prompt+=$_p9k__ret
+ _p9k_transient_prompt+='${${P9K_CONTENT::="โฏ"}+}'
+ _p9k_param prompt_prompt_char_ERROR_VIINS CONTENT_EXPANSION '${P9K_CONTENT}'
+ _p9k_transient_prompt+='${:-"'$_p9k__ret'"}'
+ _p9k_transient_prompt+=')%b%k%f%s%u'
+ _p9k_get_icon '' LEFT_SEGMENT_END_SEPARATOR
+ if [[ $_p9k__ret != (| ) ]]; then
+ _p9k__ret+=%b%k%f
+ # Not escaped for historical reasons.
+ _p9k__ret='${:-"'$_p9k__ret'"}'
+ fi
+ _p9k_transient_prompt+=$_p9k__ret
+ if (( _POWERLEVEL9K_TERM_SHELL_INTEGRATION )); then
_p9k_transient_prompt=$'%{\e]133;A\a%}'$_p9k_transient_prompt$'%{\e]133;B\a%}'
+ if (( $+_z4h_iterm_cmd && _z4h_can_save_restore_screen == 1 )); then
+ _p9k_transient_prompt=$'%{\ePtmux;\e\e]133;A\a\e\\%}'$_p9k_transient_prompt$'%{\ePtmux;\e\e]133;B\a\e\\%}'
+ fi
fi
fi
@@ -7669,7 +8624,7 @@ function _p9k_init_cacheable() {
case $_p9k_uname in
SunOS) _p9k_set_os Solaris SUNOS_ICON;;
Darwin) _p9k_set_os OSX APPLE_ICON;;
- CYGWIN_NT-* | MSYS_NT-*) _p9k_set_os Windows WINDOWS_ICON;;
+ CYGWIN*|MSYS*|MINGW*) _p9k_set_os Windows WINDOWS_ICON;;
FreeBSD|OpenBSD|DragonFly) _p9k_set_os BSD FREEBSD_ICON;;
Linux)
_p9k_os='Linux'
@@ -7677,16 +8632,25 @@ function _p9k_init_cacheable() {
if [[ -r /etc/os-release ]]; then
local lines=(${(f)"$(/dev/null -c "
+ if [[ -n ${_p9k__todo_command::=${commands[todo.sh]}} ]]; then
+ local todo_global=/etc/todo/config
+ elif [[ -n ${_p9k__todo_command::=${commands[todo-txt]}} ]]; then
+ local todo_global=/etc/todo-txt/config
+ fi
+ if [[ -n $_p9k__todo_command ]]; then
+ _p9k__todo_file="$(exec -a $_p9k__todo_command ${commands[bash]:-:} 3>&1 &>/dev/null -c "
[ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\$HOME/.todo/config
[ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\$HOME/todo.cfg
[ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\$HOME/.todo.cfg
[ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\${XDG_CONFIG_HOME:-\$HOME/.config}/todo/config
- [ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=${(qqq)todo:h}/todo.cfg
- [ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\${TODOTXT_GLOBAL_CFG_FILE:-/etc/todo/config}
+ [ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=${(qqq)_p9k__todo_command:h}/todo.cfg
+ [ -e \"\$TODOTXT_CFG_FILE\" ] || TODOTXT_CFG_FILE=\${TODOTXT_GLOBAL_CFG_FILE:-${(qqq)todo_global}}
[ -r \"\$TODOTXT_CFG_FILE\" ] || exit
- source \"\$TODOTXT_CFG_FILE\" &>/dev/null
- echo \"\$TODO_FILE\"")"
+ source \"\$TODOTXT_CFG_FILE\"
+ printf "%s" \"\$TODO_FILE\" >&3")"
fi
fi
@@ -7966,44 +8998,66 @@ _p9k_init() {
_p9k_init_vcs
- if (( _POWERLEVEL9K_DISABLE_INSTANT_PROMPT )); then
- unset __p9k_instant_prompt_erased
+ if (( _p9k__instant_prompt_disabled )); then
+ (( _POWERLEVEL9K_DISABLE_INSTANT_PROMPT )) && unset __p9k_instant_prompt_erased
_p9k_delete_instant_prompt
+ _p9k_dumped_instant_prompt_sigs=()
+ fi
+
+ if (( $+__p9k_instant_prompt_sourced && __p9k_instant_prompt_sourced != __p9k_instant_prompt_version )); then
+ _p9k_delete_instant_prompt
+ _p9k_dumped_instant_prompt_sigs=()
fi
if (( $+__p9k_instant_prompt_erased )); then
unset __p9k_instant_prompt_erased
- >&2 echo -E - ""
- >&2 echo -E - "${(%):-[%1FERROR%f]: When using instant prompt, Powerlevel10k must be loaded before the first prompt.}"
- >&2 echo -E - ""
- >&2 echo -E - "${(%):-You can:}"
- >&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/blob/master/README.md#installation\ahttps://github.com/romkatv/powerlevel10k/blob/master/README.md#installation\e]8;;\a.}"
+ if [[ -w $TTY ]]; then
+ local tty=$TTY
+ elif [[ -w /dev/tty ]]; then
+ local tty=/dev/tty
else
- >&2 echo - "${(%):- See https://github.com/romkatv/powerlevel10k/blob/master/README.md#installation.}"
+ local tty=/dev/null
fi
- if (( $+functins[zplugin] )); then
- >&2 echo -E - "${(%):- NOTE: If using %2Fzplugin%f to load %3F'romkatv/powerlevel10k'%f, %Bdo not apply%b %1Fice wait%f.}"
- fi
- >&2 echo -E - ""
- >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}"
- >&2 echo -E - "${(%):- * Zsh will start %Bquickly%b.}"
- >&2 echo -E - ""
- >&2 echo -E - "${(%):- - Disable instant prompt either by running %Bp10k configure%b or by manually}"
- >&2 echo -E - "${(%):- defining the following parameter:}"
- >&2 echo -E - ""
- >&2 echo -E - "${(%):- %3Ftypeset%f -g POWERLEVEL9K_INSTANT_PROMPT=off}"
- >&2 echo -E - ""
- >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}"
- >&2 echo -E - "${(%):- * Zsh will start %Bslowly%b.}"
- >&2 echo -E - ""
- >&2 echo -E - "${(%):- - Do nothing.}"
- >&2 echo -E - ""
- >&2 echo -E - "${(%):- * You %Bwill%b see this error message every time you start zsh.}"
- >&2 echo -E - "${(%):- * Zsh will start %Bslowly%b.}"
- >&2 echo -E - ""
+ {
+ >&2 echo -E - ""
+ >&2 echo -E - "${(%):-[%1FERROR%f]: When using instant prompt, Powerlevel10k must be loaded before the first prompt.}"
+ >&2 echo -E - ""
+ >&2 echo -E - "${(%):-You can:}"
+ >&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.}"
+ else
+ >&2 echo - "${(%):- See https://github.com/romkatv/powerlevel10k#installation.}"
+ fi
+ if (( $+zsh_defer_options )); then
+ >&2 echo -E - ""
+ >&2 echo -E - "${(%):- NOTE: Do not use %1Fzsh-defer%f to load %Upowerlevel10k.zsh-theme%u.}"
+ elif (( $+functions[zinit] )); then
+ >&2 echo -E - ""
+ >&2 echo -E - "${(%):- NOTE: If using %2Fzinit%f to load %3F'romkatv/powerlevel10k'%f, %Bdo not apply%b %1Fice wait%f.}"
+ elif (( $+functions[zplugin] )); then
+ >&2 echo -E - ""
+ >&2 echo -E - "${(%):- NOTE: If using %2Fzplugin%f to load %3F'romkatv/powerlevel10k'%f, %Bdo not apply%b %1Fice wait%f.}"
+ fi
+ >&2 echo -E - ""
+ >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}"
+ >&2 echo -E - "${(%):- * Zsh will start %Bquickly%b.}"
+ >&2 echo -E - ""
+ >&2 echo -E - "${(%):- - Disable instant prompt either by running %Bp10k configure%b or by manually}"
+ >&2 echo -E - "${(%):- defining the following parameter:}"
+ >&2 echo -E - ""
+ >&2 echo -E - "${(%):- %3Ftypeset%f -g POWERLEVEL9K_INSTANT_PROMPT=off}"
+ >&2 echo -E - ""
+ >&2 echo -E - "${(%):- * You %Bwill not%b see this error message again.}"
+ >&2 echo -E - "${(%):- * Zsh will start %Bslowly%b.}"
+ >&2 echo -E - ""
+ >&2 echo -E - "${(%):- - Do nothing.}"
+ >&2 echo -E - ""
+ >&2 echo -E - "${(%):- * You %Bwill%b see this error message every time you start zsh.}"
+ >&2 echo -E - "${(%):- * Zsh will start %Bslowly%b.}"
+ >&2 echo -E - ""
+ } 2>>$tty
fi
}
@@ -8011,10 +9065,21 @@ _p9k_deinit() {
(( $+functions[_p9k_preinit] )) && unfunction _p9k_preinit
(( $+functions[gitstatus_stop_p9k_] )) && gitstatus_stop_p9k_ POWERLEVEL9K
_p9k_worker_stop
- (( _p9k__state_dump_fd )) && exec {_p9k__state_dump_fd}>&-
+ if (( _p9k__state_dump_fd )); then
+ zle -F $_p9k__state_dump_fd
+ exec {_p9k__state_dump_fd}>&-
+ fi
+ if (( _p9k__restore_prompt_fd )); then
+ zle -F $_p9k__restore_prompt_fd
+ exec {_p9k__restore_prompt_fd}>&-
+ fi
+ if (( _p9k__redraw_fd )); then
+ zle -F $_p9k__redraw_fd
+ exec {_p9k__redraw_fd}>&-
+ 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_TTY)'
+ unset -m '(_POWERLEVEL9K_|P9K_|_p9k_)*~(P9K_SSH|_P9K_SSH_TTY|P9K_TOOLBOX_NAME|P9K_TTY|_P9K_TTY)'
[[ -n $__p9k_locale ]] || unset __p9k_locale
}
@@ -8023,7 +9088,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 is-at-least 5.4; then
+if [[ $ZSH_VERSION == (5.<4->*|<6->.*) ]]; then
typeset -gri __p9k_dumps_enabled=1
else
typeset -gri __p9k_dumps_enabled=0
@@ -8031,6 +9096,18 @@ 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
+ (( $+__p9k_use_osc133_c_cmdline )) || typeset -gri __p9k_use_osc133_c_cmdline=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
@@ -8043,7 +9120,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 $precmd_functions _p9k_precmd)
+ typeset -ga precmd_functions=(_p9k_do_nothing _p9k_precmd_first $precmd_functions _p9k_precmd)
}
prompt_powerlevel9k_setup() {
@@ -8162,13 +9239,17 @@ Perform the final stage of initialization. Must be called at the very end of zsh
typeset -gr __p9k_p10k_display_usage="Usage: %2Fp10k%f %Bdisplay%b part-pattern=state-list...
-Show, hide or toggle prompt parts. If called from zle, the current
-prompt is refreshed.
+ Show, hide or toggle prompt parts. If called from zle, the current
+ prompt is refreshed.
Usage: %2Fp10k%f %Bdisplay%b -a [part-pattern]...
-Populate array \`reply\` with states of prompt parts matching the patterns.
-If no patterns are supplied, assume \`*\`.
+ Populate array \`reply\` with states of prompt parts matching the patterns.
+ If no patterns are supplied, assume \`*\`.
+
+Usage: %2Fp10k%f %Bdisplay%b -r
+
+ Redisplay prompt.
Parts:
empty_line empty line (duh)
@@ -8269,7 +9350,7 @@ function p10k() {
fi
(( ref )) || icon=$'\1'$icon
typeset -i _p9k__has_upglob
- "_p9k_${_p9k__prompt_side}_prompt_segment" "prompt_${_p9k__segment_name}${state:+_${(U)state}}" \
+ "_p9k_${_p9k__prompt_side}_prompt_segment" "prompt_${_p9k__segment_name}${state:+_${${(U)state}//ฤฐ/I}}" \
"$bg" "${fg:-$_p9k_color1}" "$icon" "$expand" "$cond" "$text"
return 0
;;
@@ -8281,8 +9362,15 @@ function p10k() {
shift
local -i k dump
local opt prev new pair list name var
- while getopts ':ha' opt; do
+ while getopts ':har' opt; do
case $opt in
+ r)
+ if (( __p9k_reset_state > 0 )); then
+ __p9k_reset_state=2
+ else
+ __p9k_reset_state=-1
+ fi
+ ;;
a) dump=1;;
h) print -rP -- $__p9k_p10k_display_usage; return 0;;
?) print -rP -- $__p9k_p10k_display_usage >&2; return 1;;
@@ -8297,6 +9385,9 @@ function p10k() {
reply+=($_p9k__display_v[k,k+1])
done
done
+ if (( __p9k_reset_state == -1 )); then
+ _p9k_reset_prompt
+ fi
return 0
fi
local REPLY
@@ -8371,6 +9462,13 @@ function p10k() {
print -rP -- $__p9k_p10k_finalize_usage >&2
return 1
;;
+ clear-instant-prompt)
+ if (( $+__p9k_instant_prompt_active )); then
+ _p9k_clear_instant_prompt
+ unset __p9k_instant_prompt_active
+ fi
+ return 0
+ ;;
*)
print -rP -- $__p9k_p10k_usage >&2
return 1
@@ -8400,12 +9498,18 @@ zmodload -F zsh/net/socket b:zsocket
zmodload -F zsh/files b:zf_mv b:zf_rm
if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file && -n $__p9k_instant_prompt_dump_file ]]; then
- zf_rm -f -- $__p9k_instant_prompt_dump_file 2>/dev/null
+ _p9k_delete_instant_prompt
+ zf_rm -f -- $__p9k_dump_file{,.zwc} 2>/dev/null
+ zf_rm -f -- $__p9k_instant_prompt_dump_file{,.zwc} 2>/dev/null
fi
-if [[ $+__p9k_instant_prompt_sourced == 1 && $__p9k_instant_prompt_sourced != $__p9k_instant_prompt_version ]]; then
- _p9k_delete_instant_prompt
+typeset -g P9K_VERSION=1.20.15
+
+if [[ ${VSCODE_SHELL_INTEGRATION-} == <1-> && ${+__p9k_force_term_shell_integration} == 0 ]]; then
+ typeset -gri __p9k_force_term_shell_integration=1
fi
+unset VSCODE_SHELL_INTEGRATION
_p9k_init_ssh
+_p9k_init_toolbox
prompt_powerlevel9k_setup
diff --git a/internal/parser.zsh b/internal/parser.zsh
index dc2082de..2af06e1c 100644
--- a/internal/parser.zsh
+++ b/internal/parser.zsh
@@ -102,7 +102,7 @@ typeset -grA __p9k_pb_term_skip=(
# Usage: _p9k_parse_buffer [token-limit]
#
-# Parses the specified command line buffer and pupulates array P9K_COMMANDS
+# Parses the specified command line buffer and populates array P9K_COMMANDS
# with commands from it. Terminates early and returns 1 if there are more
# tokens than the specified limit.
#
@@ -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 cmd prev
+ local skip n s r state token cmd prev
local -a aln alp alf v
if [[ -o interactive_comments ]]; then
diff --git a/internal/wizard.zsh b/internal/wizard.zsh
old mode 100755
new mode 100644
index c33f6a11..5ae58002
--- a/internal/wizard.zsh
+++ b/internal/wizard.zsh
@@ -14,16 +14,10 @@ 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
-{ # always
+local -i success=0
local -ri force
@@ -105,20 +99,19 @@ local -ra rainbow_right=(
)
function prompt_length() {
- local COLUMNS=1024
+ local -i COLUMNS=1024
local -i x y=$#1 m
if (( y )); then
while (( ${${(%):-$1%$y(l.1.0)}[-1]} )); do
x=y
- (( y *= 2 ));
+ (( y *= 2 ))
done
- local xy
while (( y > x + 1 )); do
- m=$(( x + (y - x) / 2 ))
- typeset ${${(%):-$1%$m(l.x.y)}[-1]}=$m
+ (( m = x + (y - x) / 2 ))
+ (( ${${(%):-$1%$m(l.x.y)}[-1]} = m ))
done
fi
- REPLY=$x
+ typeset -g REPLY=$x
}
function print_prompt() {
@@ -229,12 +222,20 @@ function hide_cursor() {
}
function show_cursor() {
- echoti cnorm 2>/dev/null
+ local cnorm=${terminfo[cnorm]-}
+ if [[ $cnorm == *$'\e[?25h'(|'\e'*) ]]; then
+ print -n '\e[?25h'
+ else
+ print -n $cnorm
+ fi
}
function consume_input() {
local key
- while read -t0 key; do true; done
+ while true; do
+ [[ -t 2 ]]
+ read -t0 -k key || break
+ done 2>/dev/null
}
function quit() {
@@ -271,10 +272,14 @@ function quit() {
print -P " %2Fp10k%f %Bconfigure%b"
print -P ""
fi
+ function quit() {}
+ stty echo 2>/dev/null
+ show_cursor
exit 1
}
local screen_widgets=()
+local -i max_priority
local -i prompt_idx
local choice
@@ -283,6 +288,7 @@ function add_widget() {
shift
local render="${(j: :)${(@q)*}}"
screen_widgets+=("$priority" "$render")
+ (( priority <= max_priority )) || max_priority=priority
}
function render_screen_pass() {
@@ -304,7 +310,6 @@ functions -M get_columns 0 0
function render_screen() {
{
hide_cursor
- stty -echo 2>/dev/null
while true; do
while true; do
typeset -gi wizard_columns='get_columns()'
@@ -322,7 +327,7 @@ function render_screen() {
else
break
fi
- while (( (COLUMNS > 88 ? 88 : COLUMNS) == wizard_columns && LINES == wizard_lines )); do
+ while (( get_columns() == wizard_columns && LINES == wizard_lines )); do
sleep 1
done
done
@@ -351,12 +356,11 @@ function render_screen() {
flowing -c %1FNot enough vertical space.%f
print
flowing Make terminal window %Btaller%b or press %BCtrl-C%b to abort Powerlevel10k configuration wizard.
- while (( (COLUMNS > 88 ? 88 : COLUMNS) == wizard_columns && LINES == wizard_lines )); do
+ while (( get_columns() == wizard_columns && LINES == wizard_lines )); do
sleep 1
done
done
} always {
- stty echo 2>/dev/null
show_cursor
}
}
@@ -385,6 +389,7 @@ function ask() {
local -i lines columns wizard_lines wizard_columns
add_widget 0 print -P "(q) Quit and do nothing."
add_widget 0 print
+ add_widget $((max_priority + 1))
add_widget 0 print -P "%BChoice [${choices}q]: %b"
while true; do
=true
@@ -395,11 +400,13 @@ function ask() {
fi
typeset -g choice=
if read -t1 -k choice; then
+ choice=${(L)choice}
if [[ $choice == q ]]; then
quit
fi
if [[ $choices == *$choice* ]]; then
screen_widgets=()
+ max_priority=0
prompt_idx=0
return
fi
@@ -411,7 +418,11 @@ local -i greeting_printed=0
function print_greeting() {
(( greeting_printed )) && return
- if (( force )); then
+ if (( in_z4h_wizard )); then
+ flowing -c %3FZsh for Humans%f uses %4FPowerlevel10k%f to print command \
+ line prompt. This wizard will ask you a few questions and configure \
+ prompt for you.
+ elif (( force )); then
flowing -c This is %4FPowerlevel10k configuration wizard%f. \
It will ask you a few questions and configure your prompt.
else
@@ -497,41 +508,42 @@ function install_font() {
clear
case $terminal in
Termux)
- mkdir -p ~/.termux || quit -c
+ command mkdir -p -- ~/.termux || quit -c
run_command "Downloading %BMesloLGS NF Regular.ttf%b" \
curl -fsSL -o ~/.termux/font.ttf "$font_base_url/MesloLGS%20NF%20Regular.ttf"
run_command "Reloading %BTermux%b settings" termux-reload-settings
;;
iTerm2)
- mkdir -p ~/Library/Fonts || quit -c
+ command mkdir -p -- ~/Library/Fonts || quit -c
local style
for style in Regular Bold Italic 'Bold Italic'; do
local file="MesloLGS NF ${style}.ttf"
run_command "Downloading %B$file%b" \
curl -fsSL -o ~/Library/Fonts/$file.tmp "$font_base_url/${file// /%20}"
- zf_mv -f -- ~/Library/Fonts/$file{.tmp,} || quit -c
+ command mv -f -- ~/Library/Fonts/$file{.tmp,} || quit -c
done
print -nP -- "Changing %BiTerm2%b settings ..."
local size=$iterm2_font_size
[[ $size == 12 ]] && size=13
local k t v settings=(
- '"Normal Font"' string '"MesloLGS-NF-Regular '$size'"'
- '"Terminal Type"' string '"xterm-256color"'
- '"Horizontal Spacing"' real 1
- '"Vertical Spacing"' real 1
- '"Minimum Contrast"' real 0
- '"Use Bold Font"' bool 1
- '"Use Bright Bold"' bool 1
- '"Use Italic Font"' bool 1
- '"ASCII Anti Aliased"' bool 1
- '"Non-ASCII Anti Aliased"' bool 1
- '"Use Non-ASCII Font"' bool 0
- '"Ambiguous Double Width"' bool 0
- '"Draw Powerline Glyphs"' bool 1
+ '"Normal Font"' string '"MesloLGS-NF-Regular '$size'"'
+ '"Terminal Type"' string '"xterm-256color"'
+ '"Horizontal Spacing"' real 1
+ '"Vertical Spacing"' real 1
+ '"Minimum Contrast"' real 0
+ '"Use Bold Font"' bool 1
+ '"Use Bright Bold"' bool 1
+ '"Use Italic Font"' bool 1
+ '"ASCII Anti Aliased"' bool 1
+ '"Non-ASCII Anti Aliased"' bool 1
+ '"Use Non-ASCII Font"' bool 0
+ '"Ambiguous Double Width"' bool 0
+ '"Draw Powerline Glyphs"' bool 1
+ '"Only The Default BG Color Uses Transparency"' bool 1
)
for k t v in $settings; do
/usr/libexec/PlistBuddy -c "Set :\"New Bookmarks\":0:$k $v" \
- ~/Library/Preferences/com.googlecode.iterm2.plist && continue
+ ~/Library/Preferences/com.googlecode.iterm2.plist 2>/dev/null && continue
run_command "" /usr/libexec/PlistBuddy -c \
"Add :\"New Bookmarks\":0:$k $t $v" ~/Library/Preferences/com.googlecode.iterm2.plist
done
@@ -541,28 +553,31 @@ function install_font() {
sleep 3
print -P " %2FOK%f"
sleep 1
- restore_screen
+ clear
+ hide_cursor
print
flowing +c "%2FMeslo Nerd Font%f" successfully installed.
print -P ""
- flowing +c Please "%Brestart iTerm2%b" for the changes to take effect.
- print -P ""
- while true; do
+ () {
+ local out
+ out=$(/usr/bin/defaults read 'Apple Global Domain' NSQuitAlwaysKeepsWindows 2>/dev/null) || return
+ [[ $out == 1 ]] || return
+ out="$(iterm_get OpenNoWindowsAtStartup 2>/dev/null)" || return
+ [[ $out == false ]]
+ }
+ if (( $? )); then
+ flowing +c Please "%Brestart iTerm2%b" for the changes to take effect.
+ print -P ""
flowing +c -i 5 " 1. Click" "%BiTerm2 โ Quit iTerm2%b" or press "%Bโ Q%b."
flowing +c -i 5 " 2. Open %BiTerm2%b."
print -P ""
- local key=
- read -k key${(%):-"?%BWill you restart iTerm2 before proceeding? [yN]: %b"} || quit -c
- if [[ $key = (y|Y) ]]; then
- print -P ""
- print -P ""
- exit 69
- fi
- print -P ""
- print -P ""
- flowing +c "It's" important to "%Brestart iTerm2%b" for the changes to take effect.
- print -P ""
- done
+ flowing +c "It's" important to "%Brestart iTerm2%b" by following the instructions above. \
+ "It's" "%Bnot enough%b" to close iTerm2 by clicking on the red circle. You must \
+ click "%BiTerm2 โ Quit iTerm2%b" or press "%Bโ Q%b."
+ else
+ flowing +c Please "%Brestart your computer%b" for the changes to take effect.
+ fi
+ while true; do sleep 60 2>/dev/null; done
;;
esac
@@ -661,13 +676,13 @@ function ask_diamond() {
add_widget 0 print
add_widget 0 flowing -c -- "---> \uE0B2\uE0B0 <---"
add_widget 0 print
- add_widget 1
+ add_widget 3
add_widget 0 print -P "%B(y) Yes.%b"
add_widget 0 print
add_widget 1
add_widget 0 print -P "%B(n) No.%b"
add_widget 0 print
- add_widget 1
+ add_widget 2
if (( can_install_font )); then
extra+=r
add_widget 0 print -P "(r) Restart from the beginning."
@@ -689,10 +704,13 @@ function ask_lock() {
add_widget 0 print
add_widget 0 flowing -c -- "---> $1 <---"
add_widget 0 print
+ add_widget 3
add_widget 0 print -P "%B(y) Yes.%b"
add_widget 0 print
+ add_widget 1
add_widget 0 print -P "%B(n) No.%b"
add_widget 0 print
+ add_widget 2
add_widget 0 print -P "(r) Restart from the beginning."
ask ynr
case $choice in
@@ -704,16 +722,19 @@ function ask_lock() {
}
function ask_python() {
- add_widget 0 add_widget 0 flowing -c %BDoes this look like a "%b%2FPython logo%f%B?%b"
- add_widget 0 add_widget 0 flowing -c reference: "$(href https://fontawesome.com/icons/python)"
- add_widget 0 add_widget 0 print -P ""
- add_widget 0 add_widget 0 flowing -c -- "---> \uE63C <---"
- add_widget 0 add_widget 0 print -P ""
- add_widget 0 add_widget 0 print -P "%B(y) Yes.%b"
- add_widget 0 add_widget 0 print -P ""
- add_widget 0 add_widget 0 print -P "%B(n) No.%b"
- add_widget 0 add_widget 0 print -P ""
- add_widget 0 add_widget 0 print -P "(r) Restart from the beginning."
+ add_widget 0 flowing -c %BDoes this look like a "%b%2FPython logo%f%B?%b"
+ add_widget 0 flowing -c reference: "$(href https://fontawesome.com/icons/python)"
+ add_widget 0 print -P ""
+ add_widget 0 flowing -c -- "---> \uE63C <---"
+ 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;;
@@ -723,15 +744,47 @@ function ask_python() {
return 0
}
-function ask_arrow() {
+function ask_quotes() {
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 <---"
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_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
@@ -742,22 +795,35 @@ function ask_arrow() {
return 0
}
-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)"
+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"
add_widget 0 print -P ""
- add_widget 0 flowing -c -- "---> \uF306 <---"
+ 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 print -P ""
- add_widget 0 print -P "%B(y) Yes.%b"
+ add_widget 3
+ add_widget 0 print -P "%B(1) It is pointing at '1'.%b"
add_widget 0 print -P ""
- add_widget 0 print -P "%B(n) No.%b"
+ 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 ""
+ add_widget 2
add_widget 0 print -P "(r) Restart from the beginning."
- ask ynr
+ ask 123r
case $choice in
r) return 1;;
- y) cap_debian=1;;
- n) cap_debian=0;;
+ 1) cap_arrow=1;;
+ 2|3) cap_arrow=0;;
esac
return 0
}
@@ -782,10 +848,13 @@ function ask_icon_padding() {
add_widget 0 print -P ""
add_widget 0 flowing -c -- "---> $text <---"
add_widget 0 print -P ""
+ add_widget 3
add_widget 0 flowing +c -i 5 "%B(y) Yes." Icons are very close to the crosses but there is "%b%2Fno overlap%f%B.%b"
add_widget 0 print -P ""
+ add_widget 1
add_widget 0 flowing +c -i 5 "%B(n) No." Some icons "%b%2Foverlap%f%B" neighbouring crosses.%b
add_widget 0 print -P ""
+ add_widget 2
add_widget 0 print -P "(r) Restart from the beginning."
ask ynr
case $choice in
@@ -880,9 +949,9 @@ function ask_charset() {
POWERLEVEL9K_ICON_PADDING=none
cap_diamond=0
cap_python=0
- cap_debian=0
- cap_lock=0
cap_arrow=0
+ cap_lock=0
+ cap_quotes=0
;;
esac
return 0
@@ -954,10 +1023,19 @@ function ask_color() {
r) return 1;;
[1-4]) color=$choice;;
esac
- options+=${(L)color_name[color]}
+ options+=${${(L)color_name[color]}//ฤฑ/i}
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
@@ -965,10 +1043,17 @@ function ask_ornaments_color() {
[[ $gap_char != ' ' ]] && ornaments+=Connection
(( left_frame || right_frame )) && ornaments+=Frame
add_widget 0 flowing -c "%B${(j: & :)ornaments} Color%b"
- add_widget 0 print
- add_widget 1
- add_widget 0 print -P "%B(1) $color_name[1].%b"
- add_prompt color=1
+ 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 -P "%B(2) $color_name[2].%b"
add_prompt color=2
add_widget 0 print -P "%B(3) $color_name[3].%b"
@@ -981,7 +1066,7 @@ function ask_ornaments_color() {
r) return 1;;
[1-4]) color=$choice;;
esac
- options+=${(L)color_name[color]}-ornaments
+ options+=${${(L)color_name[color]}//ฤฑ/i}-ornaments
return 0
}
@@ -990,19 +1075,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(1) No.%b"
+ add_widget 0 print -P "%B(n) 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 123r
+ ask n12r
case $choice in
r) return 1;;
- 1) time=;;
+ n) time=;;
+ 1) time=$time_12h; options+='12h time';;
2) time=$time_24h; options+='24h time';;
- 3) time=$time_12h; options+='12h time';;
esac
return 0
}
@@ -1021,7 +1106,7 @@ function ask_use_rprompt() {
case $choice in
r) return 1;;
1) ;;
- 2) pure_use_rprompt=; options+=rpromt;;
+ 2) pure_use_rprompt=; options+=rprompt;;
esac
return 0
}
@@ -1034,23 +1119,33 @@ function os_icon_name() {
case $uname in
SunOS) echo SUNOS_ICON;;
Darwin) echo APPLE_ICON;;
- CYGWIN_NT-* | MSYS_NT-*) echo WINDOWS_ICON;;
+ CYGWIN_NT-*|MSYS_NT-*|MINGW64_NT-*|MINGW32_NT-*) echo WINDOWS_ICON;;
FreeBSD|OpenBSD|DragonFly) echo FREEBSD_ICON;;
Linux)
local os_release_id
if [[ -r /etc/os-release ]]; then
local lines=(${(f)"$(*|<6->.*) ]]; then
instant_prompt=off
+ options+=instant_prompt=auto-off
return 0
fi
+ if (( $+functions[z4h] )); then
+ instant_prompt=quiet
+ options+=instant_prompt=auto-quiet
+ return
+ fi
add_widget 0 flowing -c "%BInstant Prompt Mode%b"
add_widget 0 print_instant_prompt_link
add_widget 1
add_widget 0 print
add_widget 2
- add_widget 0 flowing +c -i 5 "%B(1) Off.%b" Disable instant prompt. Choose this if you\'ve \
- tried instant prompt and found it incompatible with your zsh configuration files.
+ add_widget 0 flowing +c -i 5 "%B(1) Verbose (recommended).%b"
add_widget 0 print
add_widget 1
- add_widget 0 flowing +c -i 5 "%B(2) Quiet.%b" Enable instant prompt and %Bdon\'t print \
- warnings%b when detecting console output during zsh initialization. Choose this if you\'ve \
- read and understood instant prompt documentation.
+ add_widget 0 flowing +c -i 5 "%B(2) Quiet.%b" Choose this if you\'ve read and understood \
+ instant prompt documentation.
add_widget 0 print
add_widget 1
- add_widget 0 flowing +c -i 5 "%B(3) Verbose.%b" Enable instant prompt and %Bprint a warning%b \
- when detecting console output during zsh initialization. %BChoose this if you\'ve never tried \
- instant prompt, haven\'t seen the warning, or if you are unsure what this all means%b.
+ add_widget 0 flowing +c -i 5 "%B(3) Off.%b" Choose this if you\'ve tried instant prompt \
+ and found it incompatible with your zsh configuration files.
add_widget 0 print
add_widget 2
add_widget 0 print -P "(r) Restart from the beginning."
ask 123r
case $choice in
r) return 1;;
- 1) instant_prompt=off; options+=instant_prompt=off;;
+ 1) instant_prompt=verbose; options+=instant_prompt=verbose;;
2) instant_prompt=quiet; options+=instant_prompt=quiet;;
- 3) instant_prompt=verbose; options+=instant_prompt=verbose;;
+ 3) instant_prompt=off; options+=instant_prompt=off;;
esac
return 0
}
@@ -1504,9 +1607,19 @@ function ask_config_overwrite() {
case $choice in
r) return 1;;
y)
- 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}
+ 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}
;;
esac
return 0
@@ -1523,44 +1636,22 @@ 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
-
- 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'
- if [[ -n ${(@M)lines:#(#b)[^#]#([^[:IDENT:]]|)source[[:space:]]##($f1|$f2|$f3|$f4|$g1|$h0|$h1|$h2|$h3|$h4|$h5|$h6|$h7|$h8|$h9)(|[[: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
+ (( zshrc_has_cfg && zshrc_has_instant_prompt )) && return
add_widget 0 flowing -c %BApply changes to "%b%2F${__p9k_zshrc_u//\\/\\\\}%f%B?%b"
add_widget 0 print -P ""
add_widget 1
local modifiable=y
- if [[ -e $__p9k_zshrc && ! -w $__p9k_zshrc ]]; then
+ if [[ ! -w $__p9k_zd ]]; then
+ modifiable=
+ add_widget 0 flowing -c %3FWARNING:%f %2F${__p9k_zd_u//\\/\\\\}%f %3Fis readonly.%f
+ add_widget 0 print -P ""
+ elif [[ -e $__p9k_zshrc && ! -w $__p9k_zshrc ]]; then
local -a stat
zstat -A stat +uid -- $__p9k_zshrc || quit -c
if (( stat[1] == EUID )); then
@@ -1589,16 +1680,26 @@ function ask_zshrc_edit() {
y)
write_zshrc=1
if [[ -n $zshrc_content ]]; then
- zshrc_backup="$(mktemp ${TMPDIR:-/tmp}/.zshrc.XXXXXXXXXX)" || quit -c
- cp -p $__p9k_zshrc $zshrc_backup || quit -c
+ 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
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:+\$TMPDIR}:-/tmp}/${(q-)zshrc_backup:t}
+ 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}
fi
;;
esac
@@ -1647,6 +1748,8 @@ 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'
@@ -1668,9 +1771,14 @@ function generate_config() {
sub PYTHON_ICON "'๐'"
fi
- if [[ $POWERLEVEL9K_MODE == nerdfont-complete ]]; then
- sub BATTERY_STAGES "'\uf58d\uf579\uf57a\uf57b\uf57c\uf57d\uf57e\uf57f\uf580\uf581\uf578'"
- 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 [[ $style == (classic|rainbow) ]]; then
if [[ $style == classic ]]; then
@@ -1719,6 +1827,7 @@ 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 '"
@@ -1726,6 +1835,7 @@ 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
@@ -1845,8 +1955,10 @@ function generate_config() {
header+=$line
header+=$'.\n# Type `p10k configure` to generate another config.\n#'
+ command mkdir -p -- ${__p9k_cfg_path:h} || return
+
if [[ -e $__p9k_cfg_path ]]; then
- unlink $__p9k_cfg_path || return
+ zf_rm -f -- $__p9k_cfg_path || return
fi
print -lr -- "$header" "$lines[@]" >$__p9k_cfg_path
}
@@ -1884,7 +1996,7 @@ fi" || return
[[ ! -f ${(%)__p9k_cfg_path_u} ]] || source ${(%)__p9k_cfg_path_u}" || return
fi
(( writable )) || chmod u-w -- $tmp || return
- zf_mv -f -- $tmp $__p9k_zshrc || return
+ command mv -f -- $tmp $__p9k_zshrc || return
} always {
zf_rm -f -- $tmp
}
@@ -1898,21 +2010,91 @@ 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 || return
-autoload -Uz is-at-least || return
+zmodload zsh/terminfo zsh/datetime || return
-if is-at-least 5.7.1 && [[ $COLORTERM == (24bit|truecolor) ]]; then
+if [[ $ZSH_VERSION == (5.7.<1->*|5.<8->*|<6->.*) && $COLORTERM == (24bit|truecolor) ]]; then
local -ir has_truecolor=1
else
local -ir has_truecolor=0
fi
+stty -echo 2>/dev/null
+
while true; do
local instant_prompt=verbose zshrc_content= zshrc_backup= zshrc_backup_u=
local -i zshrc_has_cfg=0 zshrc_has_instant_prompt=0 write_zshrc=0
@@ -1920,7 +2102,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_debian=0 cap_lock=0 cap_arrow=0
+ local -i cap_diamond=0 cap_python=0 cap_arrow=0 cap_lock=0 cap_quotes=0
local -a extra_icons=('' '' '')
local -a frame_color=(244 242 240 238)
local -a color_name=(Lightest Light Dark Darkest)
@@ -1934,7 +2116,7 @@ while true; do
unset pure_use_rprompt
- if [[ $langinfo[CODESET] == (utf|UTF)(-|)8 ]]; then
+ if [[ -o multibyte && $TERM != (dumb|linux) && $langinfo[CODESET] == (utf|UTF)(-|)8 ]]; then
ask_font || continue
ask_diamond || continue
if [[ $AWESOME_GLYPHS_LOADED == 1 ]]; then
@@ -1954,19 +2136,27 @@ while true; do
if (( cap_diamond )); then
POWERLEVEL9K_MODE=powerline
else
- ask_arrow || continue
- (( cap_arrow )) && POWERLEVEL9K_MODE=compatible || POWERLEVEL9K_MODE=ascii
+ ask_quotes || continue
+ (( cap_quotes )) && POWERLEVEL9K_MODE=compatible || POWERLEVEL9K_MODE=ascii
fi
fi
elif (( ! cap_diamond )); then
POWERLEVEL9K_MODE=awesome-fontconfig
else
- ask_debian || continue
- if (( cap_debian )); then
- POWERLEVEL9K_MODE=nerdfont-complete
+ ask_arrow '\UF0737' || continue
+ if (( cap_arrow )); then
+ ask_width || continue
+ fi
+ if (( cap_arrow )); then
+ POWERLEVEL9K_MODE=nerdfont-v3
else
- POWERLEVEL9K_MODE=awesome-fontconfig
- ask_python || continue
+ 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
fi
fi
fi
@@ -2034,24 +2224,32 @@ while true; do
done
restore_screen
-print
-flowing +c New config: "%B${__p9k_cfg_path_u//\\/\\\\}%b."
-if [[ -n $config_backup ]]; then
- flowing +c Backup of the old config: "%B${config_backup_u//\\/\\\\}%b."
-fi
-if [[ -n $zshrc_backup ]]; then
- flowing +c Backup of "%B${__p9k_zshrc_u//\\/\\\\}%b:" "%B${zshrc_backup_u//\\/\\\\}%b."
+if (( !in_z4h_wizard )); then
+ print
+
+ flowing +c New config: "%U${__p9k_cfg_path_u//\\/\\\\}%u."
+ if [[ -n $config_backup ]]; then
+ flowing +c Backup of the old config: "%U${config_backup_u//\\/\\\\}%u."
+ fi
+ if [[ -n $zshrc_backup ]]; then
+ flowing +c Backup of "%U${__p9k_zshrc_u//\\/\\\\}%u:" "%U${zshrc_backup_u//\\/\\\\}%u."
+ fi
fi
generate_config || return
change_zshrc || return
-print -rP ""
-flowing +c File feature requests and bug reports at "$(href https://github.com/romkatv/powerlevel10k/issues)"
-print -rP ""
+if (( !in_z4h_wizard )); then
+ print -rP ""
+ flowing +c File feature requests and bug reports at "$(href https://github.com/romkatv/powerlevel10k/issues)"
+ print -rP ""
+fi
+
+success=1
} always {
+ (( success )) || quit
consume_input
stty echo 2>/dev/null
show_cursor
diff --git a/internal/worker.zsh b/internal/worker.zsh
index 9e78bc15..269e8aad 100644
--- a/internal/worker.zsh
+++ b/internal/worker.zsh
@@ -89,12 +89,15 @@ function _p9k_worker_invoke() {
}
function _p9k_worker_cleanup() {
- eval "$__p9k_intro"
+ # __p9k_intro bugs out here in some cases for some reason.
+ emulate -L zsh
[[ $_p9k__worker_shell_pid == $sysparams[pid] ]] && _p9k_worker_stop
return 0
}
function _p9k_worker_stop() {
+ # See comments in _p9k_worker_cleanup.
+ emulate -L zsh
add-zsh-hook -D zshexit _p9k_worker_cleanup
[[ -n $_p9k__worker_resp_fd ]] && zle -F $_p9k__worker_resp_fd
[[ -n $_p9k__worker_resp_fd ]] && exec {_p9k__worker_resp_fd}>&-
@@ -178,7 +181,13 @@ function _p9k_worker_start() {
setopt monitor || return
{
[[ -n $_p9k__worker_resp_fd ]] && return
- _p9k__worker_file_prefix=${TMPDIR:-/tmp}/p10k.worker.$EUID.$sysparams[pid].$EPOCHSECONDS
+
+ 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
sysopen -r -o cloexec -u _p9k__worker_resp_fd <(
exec 0/dev/null && (( $+functions[_p9k_preinit] )); then
_p9k_preinit
fi
- typeset -gr __p9k_sourced=11
+ typeset -gr __p9k_sourced=13
if [[ $ZSH_VERSION == (5.<1->*|<6->.*) ]]; then
if [[ -w $__p9k_root_dir && -w $__p9k_root_dir/internal && -w $__p9k_root_dir/gitstatus ]]; then
local f
@@ -75,7 +74,7 @@ function _p9k_init_locale() {
done
fi
fi
- source $__p9k_root_dir/internal/p10k.zsh || true
+ builtin source $__p9k_root_dir/internal/p10k.zsh || true
}
(( $+__p9k_instant_prompt_active )) && unsetopt prompt_cr prompt_sp || setopt prompt_cr prompt_sp