[HowTo] P10k, Powerline and zsh 101

Difficulty: ★☆☆☆☆

Intro

As manjaro nowadays ships with the powerlevel10k powerline like statusline for zsh this tutorial will guide you through the correct steps to activate this feature. First, locate p10k:

❯ locate p10k
...
/usr/share/zsh/p10k.zsh
/usr/share/zsh-theme-powerlevel10k/config/p10k-classic.zsh
/usr/share/zsh-theme-powerlevel10k/config/p10k-lean-8colors.zsh
/usr/share/zsh-theme-powerlevel10k/config/p10k-lean.zsh
/usr/share/zsh-theme-powerlevel10k/config/p10k-pure.zsh
/usr/share/zsh-theme-powerlevel10k/config/p10k-rainbow.zsh
/usr/share/zsh-theme-powerlevel10k/config/p10k-robbyrussell.zsh
/usr/share/zsh-theme-powerlevel10k/internal/p10k.zsh
/usr/share/zsh-theme-powerlevel10k/internal/p10k.zsh.zwc

:warning: Warning: the > above is actually is a prompt indicator from p10k, not a $ or # prompt. :sunglasses:.

Powerlevel10k - Manjaro Vanilla Configuration

❯ vim .zshrc
# ---
# Use powerline
USE_POWERLINE="true"

So that’s it?

In short: yes and no. You might want to take a look at the first announcement here in this forum thread.

Also, you might want to dive in deeper. See the detour section below or use the force

… But p10k, that’s not powerline…

Why powerline, still?

Well, if you are only searching for zsh this would be it already. But, powerline is integrating more tools and seems to be under active development. The project seems to be “ancient” as you might note, as it started on GitHub in 2013 and might be older still. Still being maintained meaning: this is here to stay for the foreseeable future.

I actually use vim and tmux on a frequent basis, so why not continue then…
Well, first there are other implementations, namely 2 written in go and rust which also carry on the name. Both carry the same “powerline” prefix to be precise and at least one of the two is still active. So, before I stuck to powerline, a quick glance did happen. For both the goal obviously is responsiveness, keeping small footprints and usage of modern languages, as they come in (pre-) compiled binaries that should be easy to install via pamac. Quick info’s in the “Detour” secions below. Depending on your needs and preferences, they could both be worthy to try out.

Installation

❯ pamac install powerline

… or use the gui. You will end up with 3 packages from the community repository:

  • python-powerline
  • powerline-common
  • powerline

If you did not catch it until now: this is a python based project. As the project’s README clearly states:

But I hate Python / I don’t need shell prompts / this is just too much hassle for me / what happened to the original vim-powerline project / …

You might already stop reading and carry on.
Still there? OK.

Basic Configuration

As arch is a good reference, mostly my base configuration relies on that documentation.

vim

❯ vim .vimrc
"---
"powerline
"see https://wiki.archlinux.org/index.php/Powerline#Vim
"let g:powerline_pycmd="py"
set rtp+=/usr/share/powerline/bindings/vim
set laststatus=2

That should do it. Vim should, after opening any file, show you this statusline as a
Test:

Check: works.

tmux

❯ vim .tmux.conf
#see https://wiki.archlinux.org/index.php/Powerline#Tmux
source /usr/share/powerline/bindings/tmux/powerline.con

Test:

❯ tmux


Remark: tmux inception on a Yakuake Terminal :slight_smile: . Tmux powered by: powerline. zsh within powered by p10k.

Check: works

zsh

now that I have it, why not use it for zsh as well?

❯ vim .zshrc
# ---
## Use powerline
#USE_POWERLINE="true"
# Source manjaro-zsh-configuration
#if [[ -e /usr/share/zsh/manjaro-zsh-config ]]; then
#  source /usr/share/zsh/manjaro-zsh-config
#fi
## Use manjaro zsh prompt
#if [[ -e /usr/share/zsh/manjaro-zsh-prompt ]]; then
#  source /usr/share/zsh/manjaro-zsh-prompt
#fi
## To customize prompt, run `p10k configure` or edit /usr/share/zsh/p10k.zsh.
#[[ ! -f /usr/share/zsh/p10k.zsh ]] || source /usr/share/zsh/p10k.zsh

# ---
# Use "the genuine" powerline
# See https://wiki.archlinux.org/index.php/Powerline#Zsh
#prompt off
powerline-daemon -q
. /usr/share/powerline/bindings/zsh/powerline.zsh

Now, as I checked this configuration, i quickly realized the differences. At least in the “basic” configuration, the zsh prompt + powerlevel10k do really have more to offer than “vanilla powerline” configuration.
This is of course an unfair comparison, as this “manjaro crafted +p10k” zsh setup was developed and CI’d to start with and already adjusted to my personal preferences.
On the other hand the “vanilla powerline” configuration also does the job highlighting some information, at least initially missing some information and displaying things differently.

Test:


line 1, 4, 5: zsh session with “manjaro crafted +p10k” done once
line 2, 3: zsh session with “vanilla powerline”

Check: works.

and now?

powerline.readthedocs.io is the place to continue. I would also recommend information from other sources. With the basic info gathered here, you should be good to go.
To start with, also take a look at the detours I noted down.

Detours

Detour 1: powerlevel10k

Project p10k is already used in manjaro, simple to use and straight and to the point as far as I tested.

If you like config wizards you can start changing the look and feel of your powerlevel10k prompt directly with

❯ sudo p10k configure

This will, depending on your choices, give you options how your zsh prompt will look like. No screenshots here, go figure it out yourself :wink: .

The config wizard will finally after some questions and choices leave you with an updated config. You only just have to make sure your .zshrc contains some lines like these:

# Use powerline
USE_POWERLINE="true"
# Source manjaro-zsh-configuration
if [[ -e /usr/share/zsh/manjaro-zsh-config ]]; then
  source /usr/share/zsh/manjaro-zsh-config
fi
# Use manjaro zsh prompt
if [[ -e /usr/share/zsh/manjaro-zsh-prompt ]]; then
  source /usr/share/zsh/manjaro-zsh-prompt
fi
# To customize prompt, run `p10k configure` or edit /usr/share/zsh/p10k.zsh.
[[ ! -f /usr/share/zsh/p10k.zsh ]] || source /usr/share/zsh/p10k.zsh

Detour 2: powerline-go

This one is obviously written in go and focuses on shell prompts, possibly even powershell on MS W10… Wich I won’t find out as this 1o1 is about manjaro only and I want to get other tools “enhanced” by powerline.

Detour 3: powerline-rust

“alternative to powerline-shell”, “blazing fast” and so also out of focus for me as this will “only” enhance shell prompts… Also the project seems to lack behind (2021-04) in “still happening development”.

Detour 4: additional powerline plugins from the manjaro community

PS: Celebrating the 10th edit after creation :champagne:

In addition to the base community packages, there are also 2 other optional packages you might want to use if you want to enhance the “powerline experience”:

  • powerline-vim
  • powerline-fonts

Tags: powerline, p10k, tmux, vim, zsh

10 Likes

Great guide!

Though, it’s worth to mention that currently p10k configure is not working out of the box on Manjaro. It outputs:
[ERROR] p10k configure: cannot create /usr/share/zsh/p10k.zsh because /usr/share/zsh is readonly

And sudo p10k configure outputs:
sudo: p10k: command not found

This is discussed in these 2 threads:

With the solution being:

3 Likes