1
0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-12-12 19:18:28 +02:00
powerlevel10k/README.md

305 lines
14 KiB
Markdown
Raw Normal View History

2019-03-01 22:45:36 +02:00
# Powerlevel10k
2016-02-05 17:43:36 +02:00
Powerlevel10k is a theme for ZSH. It's a backward-compatible reimplementation of
2019-03-01 22:45:36 +02:00
[Powerlevel9k](https://github.com/bhilburn/powerlevel9k) with lower latency and better
prompt responsiveness.
2019-03-02 16:59:43 +02:00
If you like the looks of Powerlevel9k but feeling frustrated by its slow prompt,
simply replace your `powerlevel9k` theme with `powerlevel10k` and enjoy responsive
shell like it's 80's again!
2015-06-08 22:47:39 +02:00
2019-03-01 22:45:36 +02:00
Powerlevel10k uses the same configuration options as Powerlevel9k and produces the
2019-03-14 15:03:04 +02:00
same results [[*]](#does-powerlevel10k-always-render-exactly-the-same-prompt-with-the-same-config).
2019-03-14 15:02:22 +02:00
It's simply faster.
2015-06-04 01:43:00 +02:00
## Table of Contents
2019-03-04 13:18:49 +02:00
1. [Installation and configuration](#installation-and-configuration)
2019-03-07 01:57:01 +02:00
1. [Manual installation](#manual-installation)
2. [Extra configuration](#extra-configuration)
2019-03-07 00:04:06 +02:00
2. [Try it out](#try-it-out)
2019-03-07 01:57:01 +02:00
1. [For Powerlevel9k users](#for-powerlevel9k-users)
2. [For new users](#for-new-users)
3. [Docker playground](#docker-playground)
3. [How fast is it?](#how-fast-is-it)
2019-03-14 14:28:27 +02:00
4. [FAQ](#faq)
2019-03-13 02:11:19 +02:00
1. [Why does Powerlevel10k spawn two extra processes?](#why-does-powerlevel10k-spawn-two-extra-processes)
2. [Does Powerlevel10k always render exactly the same prompt with the same config?](#does-powerlevel10k-always-render-exactly-the-same-prompt-with-the-same-config)
3. [Are changes getting up/down-streamed?](#are-changes-getting-updown-streamed)
4. [Is there an AUR package for Powerlevel10k?](#is-there-an-aur-package-for-powerlevel10k)
5. [How do I use Powerlevel10k with zplug, prezto, oh-my-zsh, antigen, somethingelse?](#how-do-i-use-powerlevel10k-with-zplug-prezto-oh-my-zsh-antigen-somethingelse)
2019-03-14 21:49:38 +02:00
6. [What is the minimum supported zsh version?](#what-is-the-minimum-supported-zsh-version)
2019-03-04 13:18:49 +02:00
## Installation and configuration
2015-10-12 23:53:17 +02:00
2019-03-02 16:59:43 +02:00
For installation and configuration instructions see
2019-03-01 22:45:36 +02:00
[Powerlevel9k](https://github.com/bhilburn/powerlevel9k). Everything in there applies to
2019-03-02 16:59:43 +02:00
Powerlevel10k as well. Follow the official installation guide, make sure everything works
and you like the way prompt looks. Then simply replace Powerlevel9k with Powerlevel10k. Once
you restart zsh, your prompt will be faster. No configuration changes are needed.
2019-03-07 01:57:01 +02:00
### Manual installation
```zsh
git clone https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>! ~/.zshrc
```
2019-03-13 02:08:16 +02:00
If you are using a framework / plugin manager and need help translating these instruction into its
2019-03-22 09:47:53 +02:00
configuration language, see
[FAQ](#how-do-i-use-powerlevel10k-with-zplug-prezto-oh-my-zsh-antigen-somethingelse).
2019-03-13 02:08:16 +02:00
2019-03-07 00:04:06 +02:00
Make sure to disable your current theme.
2019-03-07 01:57:01 +02:00
### Extra configuration
Powerlevel10k has a handful of configuration options that Powerlevel9k doesn't have. They
are still using the `POWERLEVEL9K` prefix though.
* `POWERLEVEL9K_VCS_MAX_SYNC_LATENCY_SECONDS (FLOAT) [default=0.05]`
If it takes longer than this to fetch git repo status, display the prompt with a greyed out
vcs segment and fix it asynchronously when the results come it.
* `POWERLEVEL9K_VCS_BACKENDS (ARRAY) [default=(git)]`
The list of VCS backends to use. Supported values are `git`, `svn` and `hg`. Note that adding
anything other than git will make prompt slower even when your current directory isn't a repo.
2019-03-07 02:00:52 +02:00
* `POWERLEVEL9K_GITSTATUS_DIR (STRING) [default=$POWERLEVEL9K_INSTALLATION_DIR/gitstatus]`
Directory with gitstatus plugin. By default uses a copy bundled with Powerlevel10k.
2019-03-07 01:57:01 +02:00
* `POWERLEVEL9K_DISABLE_GITSTATUS (STRING) [default="false"]`
If set to `"true"`, Powerlevel10k won't use its fast git backend and will fall back to
`vcs_info` like Powerlevel9k.
* `POWERLEVEL9K_MAX_CACHE_SIZE (INT) [default=10000]`
The maximum number of elements that can be stored in the cache. When the cache grows over this
limit, it gets cleared.
* `POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY (INT) [default=-1]`
Don't scan for dirty files in git repos with more files in the index than this. Instead, show
them with the "dirty" color (yellow by default) whether they are dirty or not. This makes git
prompt much faster on huge repositories.
2019-03-12 15:01:20 +02:00
* `POWERLEVEL9K_EXPERIMENTAL_TIME_REALTIME (STRING) [default="false"]`
2019-03-12 15:01:57 +02:00
If set to `"true"`, `time` segment will update every second, turning into a realtime clock.
This option triggers a
[bug in completion menu](https://www.zsh.org/mla/workers//2019/msg00161.html) in zsh, and
another
[bug in history](https://github.com/bhilburn/powerlevel9k/commit/fb1ef540228ec7b4394cf2f6860137074c5838a6#commitcomment-32779672).
You can pick up a fix for the latter from
[a fork of zsh](https://github.com/romkatv/zsh/tree/gentle-reset-prompt).
* When using gitstatus, there is an extra state called `LOADING` that is used by `vcs` prompt
segment when it's waiting for git status in the background. You can define styling for this
state the same way as for the other states -- `CLEAN`, `UNTRACKED` and `MODIFIED`. You can
also define the icon and the text that will be used when `LOADING` state is triggered for a
git repository for which no prior status is known. If both `POWERLEVEL9K_VCS_LOADING_ICON`
and `POWERLEVEL9K_VCS_LOADING_TEXT` are empty, `vcs` segment in such cases won't be shown.
* `POWERLEVEL9K_VCS_LOADING_ICON (STRING) [default=""]`
Icon shown while waiting for git status for a repo for the first time.
* `POWERLEVEL9K_VCS_LOADING_TEXT (STRING) [default="loading"]`
Text shown while waiting for git status for a repo for the first time.
* `POWERLEVEL9K_VCS_LOADING_BACKGROUND (STRING) [default="grey"]`
Background color for `LOADING` state.
* `POWERLEVEL9K_VCS_LOADING_FOREGROUND (STRING) [default="$DEFAULT_COLOR"]`
Foreground color for `LOADING` state.
* `POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR (STRING) [default=$POWERLEVEL9K_VCS_LOADING_FOREGROUND]`
Foreground color for `POWERLEVEL9K_VCS_LOADING_ICON`.
* When using gitstatus, components of `vcs` segment can be colored individually by setting
`POWERLEVEL9K_VCS_${STATE}_${COMPONENT}FORMAT_FOREGROUND`. `${STATE}` should be one of `CLEAN`,
`UNTRACKED`, `MODIFIED` or `LOADING`. `${COMPONENT}` should be one of `REMOTE_URL`, `COMMIT`,
`BRANCH`, `TAG`, `REMOTE_BRANCH`, `STAGED`, `UNSTAGED`, `UNTRACKED`, `OUTGOING_CHANGES`,
`INCOMING_CHANGES`, `STASH` or `ACTION`. If
`POWERLEVEL9K_VCS_${STATE}_${COMPONENT}FORMAT_FOREGROUND` isn't set for some combination of
`${STATE}` and `${COMPONENT}`, the component is colored with
`POWERLEVEL9K_VCS_${COMPONENT}FORMAT_FOREGROUND`. If that one isn't set either, the component is
colored with `POWERLEVEL9K_VCS_${STATE}_FOREGROUND`. The fallback logic is consistent with
Powerlevel9k, meaning that your `vcs` prompt will look the same in Powerlevel10k and
Powerlevel9k if you don't define any `POWERLEVEL9K_VCS_${STATE}_${COMPONENT}_FOREGROUND`
parameters. Note that both the icon and the text in each component always have the same color.
There is currently no `POWERLEVEL9K_VCS_${STATE}_${COMPONENT}FORMAT_VISUAL_IDENTIFIER_COLOR`,
although it's easy to implement if desired.
2019-03-12 15:01:20 +02:00
2019-03-07 00:04:06 +02:00
## Try it out
2019-03-07 00:04:06 +02:00
Try Powerlevel10k without making any changes to your setup. If you like it, see
[Installation and configuration](#installation-and-configuration) for how to make a permanent
switch.
2019-03-02 16:59:43 +02:00
2019-03-07 01:57:01 +02:00
### For Powerlevel9k users
2019-03-07 00:04:06 +02:00
If you are currently using Powerlevel9k, you can try Powerlevel10k in a temporary zsh shell. The
prompt will look exactly like what you are used to but it'll be faster.
2019-03-02 17:19:36 +02:00
2019-03-02 16:59:43 +02:00
```zsh
2019-03-07 00:04:06 +02:00
git clone https://github.com/romkatv/powerlevel10k.git /tmp/powerlevel10k
source /tmp/powerlevel10k/powerlevel10k.zsh-theme
```
When you are done playing, `rm -rf /tmp/powerlevel10k` and exit zsh.
### For new users
```zsh
git clone https://github.com/romkatv/powerlevel10k.git /tmp/powerlevel10k
echo "
# Your prompt configuration goes here.
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(root_indicator dir_writable dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status command_execution_time background_jobs time)
2019-03-07 02:35:27 +02:00
source /tmp/powerlevel10k/powerlevel10k.zsh-theme" >/tmp/powerlevel10k/.zshrc
2019-03-07 00:04:06 +02:00
ZDOTDIR=/tmp/powerlevel10k zsh
2019-03-02 16:59:43 +02:00
```
2015-07-19 21:42:00 +02:00
2019-03-07 00:04:06 +02:00
When you are done playing, `rm -rf /tmp/powerlevel10k` and exit zsh.
2019-03-07 01:57:01 +02:00
### Docker playground
2019-03-07 00:04:06 +02:00
2019-03-07 01:57:01 +02:00
You can try Powerlevel10k in Docker (Linux only). Once you exit zsh, the image is deleted.
2019-03-02 18:44:18 +02:00
```zsh
2019-03-14 16:38:12 +02:00
docker run -e LANG=C.UTF-8 -e LC_ALL=C.UTF-8 -e TERM=$TERM -it --rm ubuntu bash -uexc '
apt update && apt install -y zsh git
git clone https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
echo "
# Your prompt configuration goes here.
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(root_indicator dir_writable dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status command_execution_time background_jobs time)
2019-03-07 00:04:06 +02:00
source ~/powerlevel10k/powerlevel10k.zsh-theme" >~/.zshrc
2019-03-14 16:39:29 +02:00
cd ~/powerlevel10k
zsh -i'
```
2019-03-02 01:16:59 +02:00
## How fast is it?
2019-03-12 15:01:20 +02:00
Powerlevel10k renders prompt between 10 and 100 times faster than powerlevel9k.
2019-03-02 16:59:43 +02:00
2019-03-02 20:35:23 +02:00
Here are benchmark results obtained with
2019-03-02 16:59:43 +02:00
[zsh-prompt-benchmark](https://github.com/romkatv/zsh-prompt-benchmark) on Intel i9-7900X
running Ubuntu 18.04.
2019-03-12 15:02:39 +02:00
| Theme | / | ~/linux |
2019-03-12 15:01:20 +02:00
|---------------------|----------:| ---------:|
| powerlevel9k/master | 101 ms | 280 ms |
| powerlevel9k/next | 26 ms | 255 ms |
| **powerlevel10k** | **1 ms** | **22 ms** |
| naked zsh | 0.05 ms | 0.05 ms |
2019-03-02 16:59:43 +02:00
Columns define the current directory where the prompt was rendered.
* `/` -- root directory, not a git repo.
2019-03-12 15:03:20 +02:00
* `~/linux` -- [linux](https://github.com/torvalds/linux) git repo with 60k files. It was checked
out to an M.2 SSD.
2019-03-12 15:01:20 +02:00
powerlevel9k/master is the stable branch of powerlevel9k, the one that virtually everyone uses.
powerlevel9k/next is the development branch for the next release.
2019-03-02 16:59:43 +02:00
2019-03-07 13:46:26 +02:00
Here's how the prompt looked like during benchmarking.
![](https://raw.githubusercontent.com/romkatv/powerlevel10k/master/prompt.png)
It was identical in Powerlevel10k and Powerlevel9k. Even though Powerlevel10k can dynamically
2019-03-12 15:01:20 +02:00
switch to async prompts, it wasn't happening during the benchmark because latencies were low.
Prompts with both themes were essentially synchronous, with every prompt having up-to-date git info
(no greyed-out vcs/git segments).
2019-03-07 01:57:01 +02:00
Configuration that was used:
2019-03-02 16:59:43 +02:00
```zsh
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir_writable dir vcs)
2019-03-12 15:01:20 +02:00
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status time)
2019-03-02 16:59:43 +02:00
POWERLEVEL9K_MODE=nerdfont-complete
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
2019-03-12 15:01:20 +02:00
POWERLEVEL9K_ROOT_ICON=\\uF09C
POWERLEVEL9K_TIME_ICON=\\uF017
2019-03-02 16:59:43 +02:00
POWERLEVEL9K_TIME_BACKGROUND=magenta
POWERLEVEL9K_STATUS_OK_BACKGROUND=grey53
```
2019-03-02 01:16:59 +02:00
2019-03-12 15:01:20 +02:00
Powerlevel10k shows similar performance advantage over Powerlevel9k on Mac OS, FreeBSD, WSL, and
Raspberry Pie.
2019-03-07 13:46:26 +02:00
2019-03-13 02:08:16 +02:00
## FAQ
2019-03-02 01:16:59 +02:00
2019-03-14 15:26:41 +02:00
### Why does Powerlevel10k spawn extra processes?
2019-03-07 01:57:01 +02:00
2019-03-13 02:08:16 +02:00
Powerlevel10k uses [gitstatus](https://github.com/romkatv/gitstatus) as the backend behind `vcs`
2019-03-14 15:26:41 +02:00
prompt; gitstatus spawns `gitstatusd` and `zsh`. See
[gitstatus](https://github.com/romkatv/gitstatus) for details. Powerlevel10k spawns another `zsh`
if `POWERLEVEL9K_EXPERIMENTAL_TIME_REALTIME` is set to `true` or `background_jobs` segment is
enabled. This is used to trigger prompt refresh.
2019-03-07 01:57:01 +02:00
2019-03-13 02:08:16 +02:00
### Does Powerlevel10k always render exactly the same prompt with the same config?
This is the goal. You should be able to switch between Powerlevel9k and Powerlevel10k with no
visible changes except for performance. There are, however, several differences.
* By default only git vcs backend is enabled in Powerlevel10k. If you need svn and hg, you'll
need to set `POWERLEVEL9K_VCS_BACKENDS`. See [Extra configuration](#extra-configuration).
2019-03-07 01:57:01 +02:00
* Fewer configuration options can be changed after the theme is loaded. For example, if you
decide to change background color of some segment in the middle of an interactive session,
it may not work.
2019-03-08 17:11:06 +02:00
2019-03-13 20:03:31 +02:00
If you notice any other differences between prompts in Powerlevel9k and Powerlevel10k when running
with the same settings, please [open an issue](https://github.com/romkatv/powerlevel10k/issues).
2019-03-13 02:08:16 +02:00
### Are changes getting up/down-streamed?
2019-03-08 17:11:06 +02:00
2019-03-13 02:08:16 +02:00
Powerlevel10k regularly pulls changes from Powerlevel9k, so all bug fixes and new features that land
in Powerlevel9k will land here, too.
There is ongoing work on upstreaming some of the changes from Powerlevel10k to Powerlevel9k. E.g.,
issues [1170](https://github.com/bhilburn/powerlevel9k/issues/1170) and
[1185](https://github.com/bhilburn/powerlevel9k/issues/1185).
Improvements to [libgit2](https://github.com/libgit2/libgit2/issues/4230#issuecomment-471710359) are
being upstremed. There are 3 independent optimizations and it's not yet clear whether all of them
will make it but there is a good chance they will.
### Is there an AUR package for Powerlevel10k?
Yes, [zsh-theme-powerlevel10k-git](https://aur.archlinux.org/packages/zsh-theme-powerlevel10k-git/).
This package is owned by an unaffiliated volunteer.
### How do I use Powerlevel10k with zplug, prezto, oh-my-zsh, antigen, somethingelse?
If you have to ask, then the easiest way is to disable the current theme (so that you end up with
no theme) and then install Powerlevel10k the usual way.
1. Disable the current theme in your framework / plugin manager.
* **zplug:** Open `~/.zshrc` and remove the `zplug` command that refers to your current theme. For
example, if you are currently using Powerlevel9k, look for
`zplug bhilburn/powerlevel9k, use:powerlevel9k.zsh-theme`.
* **prezto:** Open `~/.zpreztorc` and put `zstyle :prezto:module:prompt theme off` in it. Remove
any other command that sets `theme` such as `zstyle :prezto:module:prompt theme powerlevel9k`.
* **oh-my-zsh:** Open `~/.zshrc` and remove the line that sets `ZSH_THEME`, such as
`ZSH_THEME=powerlevel9k/powerlevel9k`.
* **antigen:** Open `~/.zshrc` and remove the line that sets `antigen theme`, such as
`antigen theme bhilburn/powerlevel9k powerlevel9k`.
2. Install Powerlevel10k the usual way.
```zsh
git clone https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>! ~/.zshrc
```
2019-03-13 20:03:31 +02:00
2019-03-17 01:06:47 +02:00
If you've been using Powerlevel9k before, **do not remove the configuration options**. Powerlevel10k
will pick them up and provide you with the same prompt UI you are used to.
2019-03-13 20:03:31 +02:00
### What is the minimum supported zsh version?
Anything below 5.2 definitely won't work. 5.4 definitely will.