1. 53

Powerlevel10k has reached v1.0. The latest addition is proper documentation. I encourage you to scroll though features even if you’ve seen Powerlevel10k before and even if you are already using it.

  1. 7

    I’ve been using this for a few months now and the performance between this and 9k is like night and day, I work in huge git monorepos, this was a drop in replacement and makes my promos so much more responsive

    1. 5

      Thanks :-)

      Make sure to update powerlevel10k if you haven’t for some time. Powerlevel10k guarantees backward compatibility with all configs, so your prompt will keep looking just like before. It will get faster over time though as I’m constantly optimizing code.

      1. 1

        The performance difference is especially pronounced if you use instant-prompt mode.

      2. 6

        Holy moly. I spent some time tweaking my zsh prompt by customizing a Python script that generates my prompt, covering shortened paths, git branch, sudo mode, error codes, virtualenv, pyenv, and node. Code for that is here. I did it mostly for fun and to make sure I fully understood how my zsh shell prompt works. But this theme has all my script’s features, and then some, and I’m really curious how it handles the prompt performance issue as described in the README.

        1. 6

          Indeed, it’s a bane of sophisticated prompts that they are slow. Reducing prompt latency below the humanly perceptible threshold requires coding style specific to the shell you are targeting. Straightforward port of pseudo code (or Python code) to Zsh will have terrible performance.

          1. 7

            I just want to say, I tried this out on my home development server, and it’s really impressive. Was super easy for me to set up with the wizard. I love the “transient prompt” mode and the speed. Using the “lean”, “abbreviated”, and “2-line” prompt version pretty much matched my own custom prompt setup that I had written in Python. Really cool. It picked up my git/pyenv/virtualenv setup automatically and even uses a cute Python icon. Took me a second to grok the various abbreviations for git dirty states, but they made sense once I did. Really nice work on this, @romka!

            Here are a couple of public screenshots of how the prompt looks in a Python/node/git project.


            (look at the left-hand-side terminal window)

            1. 2

              Do you know any good guides to writing performant shell?

              1. 9

                I don’t think there are any. This is a very niche topic.

                If your goal is writing shell scripts, then “avoid forks” and “be mindful of big-O” is all the performance advice you need. If a shell script has no forks and close-to-optimal algorithmic time complexity and is still not fast enough for practical purposes, it’s usually better to switch to a different programming language than to attempt to optimize.

                High-performance shell code is only necessary when writing interactive shell extensions as they cannot be written in a different programming language. Things like prompt or syntax highlighting. In Zsh, syntax highlighting for the commands you type is not built-in. It’s a separate Zsh script that you source. This script parses the command line on every keystroke. This is the kind of problem where it’s necessary to hand-optimize shell code.

                Zsh is really quite awful as a programming language (it’s a fantastic interactive shell though). The lack of staple containers really hurts. There is no deque, linked list or priority queue in Zsh. In fact, there are only three data types: scalar, array and associative array. They don’t compose. Elements of arrays and associative arrays can only be scalars. You cannot create an array of arrays. There are no tuples, structs, objects, pointers or references. This impoverished landscape makes it difficult to implement efficient algorithms. To make matters worse, access into arrays and strings is not constant time. x=a[i] and a[i]=x are 2000 times faster if a has length 10 than if it has length 10 million.

            2. 1

              Interesting. Got any screenshots? Here’s mine.

            3. 6

              Related, I just started using this cross-shell prompt: https://starship.rs/

              1. 6

                I know this project. Starship is a good choice for Bash and Fish as these shells are somewhat behind Zsh when it comes to theme choice. Being cross-platforms means it’s difficult for Starship to compete with Zsh-specific prompts that take advantage of many advanced interactive facilities not available anywhere else.

                Virtually all major powerlevel10k features are out of reach for Starship, including performance. Perhaps counter-intuitively, being implemented in Rust implies large performance penalty compared to native Zsh themes. This is due to the necessity to fork and marshal data between processes, and to having no shared state between consecutive prompts.

                1. 5

                  I have been using starship for a few months now on zsh (and honestly haven’t experienced any perf issues AFAIK..), but I’m going to give powerlevel10k a try right now.

                  1. 5

                    Starship is pretty fast in most cases. Given the constraints, it performs very well. Starship has several talented dedicated devs working on it.

                    Starship’s performance sags when you cd into a Git repo of non-trivial size. A larger repo (e.g., chromium), makes prompt unusable. Similar issues with directories that have many files. Starship devs are aware of these issues and are making progress fixing them. It’s not an easy task given the architecture of Starship but there is still low-hanging fruit in terms of optimization opportunities.

                    1. 6

                      I just got p10k set up and, wow.. the configuration process was really nice, and I’m really digging the transient prompt feature! You did a really great job!

                      1. 4

                        Thank you :-D

              2. 5

                Scrolling through the features + feeling how snappy the prompts are just got me to change my default shell on my laptop to zsh for a couple of weeks to see how I like it.

                I have installed it several times in the past. But I’ve never felt like making it my default. The wizard here gives me a prompt that I like better than the powerline (for bash) prompt I’ve spent hours tweaking. And that prompt from the wizard (displaying more info than my old one) is snappier than my powerline prompt, even after I spent time converting my powerline config to use the daemon a while back.

                If zsh doesn’t break my muscle memory (or collection of aliases) too badly, I’ll be switching just for this theme. Very nice job.

                1. 5

                  Thank you for the kind words!

                  The config produced by the configuration wizard enables between 36 and 38 prompt segments depending on your choices. This is a huge number, but these segments are carefully tuned to not clutter prompt. When prompt shows something, it’s virtually always useful. There are a few more segments that are very useful to some users but not enabled by default as they would seem spammy to others. For example, an indicator when you are connected to VPN, or your public IP address, or current rustc version (especially useful when you are using rustup with per-directory overrides). All of these are free in terms of prompt latency but not in terms of prompt space. I encourage you to open ~/.p10k.zsh and try uncommenting some prompt segments at the top to see what they do. Another simple customization step that can have large personal usability benefits is to move prompt segments around (between left and right prompt, or between different prompt lines).

                  1. 4

                    Thank you for making this. The transient prompt is great and addresses the main thing I disliked about my powerline setup. With two lines, prompt space is not such an issue. And with the transient prompt, two lines doesn’t eat nearly the real estate it used to for me.

                    Unless I discover some annoying surprise I can’t work around, zsh is probably going to stick as my default on my most-used systems. This is really, really nice to use. And so far it’s not breaking my muscle memory at all.

                2. 5

                  Really impressed by this zsh theme! It is INSANELY FAST to load. I used the ultra minimal and effective pure prompt before so it’s nice that it supports this style out of the box.

                  Seriously everyone should check out the instant prompt feature. That feature alone makes it worth installing.

                  1. 5

                    This is really very, very good. I wish @romka had a Pateron I could give a coffee to!

                    I am a Fish user in general. Here is what I did:

                    1. Install Oh-my-zsh, not because I like it, but because it’s the standard for installing the other plugins.
                    2. Install Powerlevel with the Oh-my-zsh instructions.
                    3. Download and use the following plugins in your .zshrc: plugins=(git zsh-autosuggestions history-substring-search zsh-completions).

                    You now have something very Fish-like but much, much faster.

                    1. 6

                      Thanks :-D

                      One more must-have plugin: zsh-syntax-highlighting. And you should probably remove git unless you really need all those aliases.

                    2. 5

                      How do instant prompts work?

                      1. 8

                        To enable instant prompt, you put the following preamble at the top of ~/.zshrc.

                        if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
                          source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"

                        When this code evaluates, it prints prompt. It’s not a real Zsh prompt, it just looks like one. When the whole ~/.zshrc is evaluated, the real prompt is printed over the instant prompt. On a decent terminals you don’t notice it. On a sub-par terminal it can produce a flicker.

                        This is the basic idea. There are many details and optimization tricks that I’m omitting here. Overall, this is the most complex feature in powerlevel10k.

                        You can catch real prompt in the act of replacing instant prompt.

                        1. Add sleep 1 after the instant prompt preamble.
                        2. Manually change something in ~/.p10k.zsh. For example, add typeset -g POWERLEVEL9K_BACKGROUND=55 at the very end.
                        3. Restart Zsh.

                        You’ll notice that at first your regular prompt appears. After two seconds the background changes to purple. If you restart Zsh again, instant prompt will have purple background. It always uses the latest config ingested by Powerlevel10k.

                        1. 1

                          Many thanks for your work on this, I had swore off prompts and shell theming in general due to the slowness, and I’ve been having fun trying p10k out.

                          I do get the flicker when using instant prompt on alacritty, is this something that should be reported as a bug?

                          1. 1

                            If you are on Linux, I highly recommend a terminal based on VTE, such as GNOME Terminal or Tilix. These terminals are the most reliable (or, to put it differently, the least buggy), produce the smoothest rendering, and fairly fast. On macOS I recommend iTerm2.

                            is this something that should be reported as a bug?

                            I don’t consider this a bug in Powerlevel10k. Whether it’s considered a bug in Alacritty I canot tell.

                            1. 1

                              Yeah, I was asking about reporting to Alacritty.

                              I’m comfortable enough with no instant prompt (I don’t really run too many plugins), and not a big fan of GNOME terminal or Tilix, so I’ll keep my setup. Thanks!

                              1. 1

                                If you don’t get much from instant prompt, it makes perfect sense to keep it disabled.

                                If I may ask, what do you like about Alacritty compared to GNOME Terminal?

                      2. 4

                        It is interesting you mention NVM as a cause of a slow prompt. I had just added NVM to my .zshrc yesterday but had to remove it because of how slow it is. From my limited look into the front end dev world I have found a lot of tools behaving similarly. Does anyone know if that is the norm?

                        Anyways, I will have to try NVM plus your instant prompt feature!

                        1. 2

                          I was looking into this as well. There’s a long thread about this: https://github.com/nvm-sh/nvm/issues/1277

                          Apparently, you can append --no-use to the source-line, and it’ll still load nvm, but not activate your default Node.js version, which is the cause of the slowdown in my case. I’m usually on the latest Node.js any way, so I’m going to try use nvm only for older versions the few times I need them, and otherwise rely on the install from my regular package manager (Homebrew).

                          1. 1

                            Good find! Thanks!

                        2. 2

                          This is exciting! I’ve been using Powerlevel10k for several months now and couldn’t be happier. Great work!!

                          Stories with similar links:

                          1. A fast reimplementation of Powerlevel9k ZSH theme via knl 2 years ago | 3 points | 2 comments