Using Powerlevel10k to Customize Zsh
Tags: zsh, powerlevel10k, terminal, theme
Published: 2021-08-11 21:20:21

As someone who cares deeply for aesthetics, one of my first missions when I began using a terminal was to make it my own. That is to say that the stock theme of zsh is, well, less than what I would like it to be. It is boring to put it bluntly, and it dulls me just looking at it. It’s a functional shell, sure, but it is lacking in the beauty department. So, in order to make it my own I needed to figure out how to customize it. Luckily, it did not take me too long to find the answer in the form of Powerlevel10k.

**What is Powerlevel10k?**
To put it simply, Powerlevel10k is a theme that can be used with zsh to improve upon its looks. It emphasizes speed, flexibility, and most importantly, it's aesthetic. Using this theme will drastically improve your experience while working within the terminal. Let’s jump into it.

**Install zsh**
The first thing you are going to need to do is install zsh (if you are an OS X user, zsh should be preinstalled on your machine). Say goodbye to bash, or whatever other terminal you’re using. Your coding experience is about to get that much better. For the sake of length, and not having a deep understanding of other operating systems, I encourage you to check out the zsh documentation found [here](https://gist.github.com/derhuerst/12a1558a4b408b3b2b6e).
** if you are a windows user, setting up zsh might be a bit of an annoyance **

**Install Oh My Zsh**
After having installed and switching over to zsh, run the following line of code:
```
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
```
This will install the necessary open-sourced framework needed in order to use Powerlevel10k as your primary theme and manage your other configurations. For more information, check out their website.

**Install Powerlevel10k**
In order to install Powerlevel10k, you must clone down the following repo: 
```
git clone — depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
```
With this repo now on your machine, you’re going to need to follow a couple more steps here. First of which is opening your ~/.zshrc file. Copy this file and save it elsewhere in case of any hiccups incurred on this path. Next, you’re going to change the ZSH_THEME in your ~/.zshrc file.
![zsh file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ap6cs80r7wr4r5vfcjd9.png)

At this point, save the file and you should be ready to run p10k configure in your terminal — which should result in the following:
![p10k setup](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7qrzhbavkfmnxoydwur8.gif)

This is going to be an incredibly intuitive set-up experience that deals with themes and text truncation. When prompted, select the rainbow theme. If you want the full experience, this is the best theme offered in my opinion. You can really make it your own at this point.

**Further Customization**
At this point, your terminal is already looking so much better than the bland shell you’ve been working with all this time. However, let’s go a little bit deeper here and customize the colors. When you run p10k configure (no need to do it again at this point), your machine will have created a file which we will be opening now. Run ~/.p10k.zsh in your terminal. Making some quick edits here, scroll on down to line 205. You should see the following lines of code:
![background and foreground color location](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bc3whwesdjgfx77npk2h.png)

70 & 50 denote the colors used
Using the above values will alter your prompt to look like this:
![terminal example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n45ojrsey7ox0qoxo9ak.png)

Now, of course, this is all about how you want your terminal to look. Lets go ahead and run the following line of code in your terminal:
```
for i in {0..255}; do print -Pn “%K{$i} %k%F{$i}${(l:3::0:)i}%f “ ${${(M)$((i%6)):#3}:+$’\n’}; done
```
This will result in your terminal displaying a list of 255 colors that are available to use with P10k.
![255 Colors](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f13emoo0ai7iqk7l0xri.png)
255 available colors to choose from when creating a custom theme wtih P10k

Once you’ve got a decent idea of what color palette you would like to work with, head back into your ~/.p10k.zsh file and swap out the colors located on lines 206, 208, 345–349 (if you would like to change the colors of your VCS). If you want to go the extra mile, I would encourage you to also include an emoji on line 479. It really helps to add a little charm to your VCS included prompt.

When completed, you might end up with something that looks like this (one can only hope for that). Or, you might go down.a radically different path. But, that’s completely fine. The point of this blog post is to show you that you have the option to change something if you do not like it. In the case of the standard zsh theme, I find it a must to alter — otherwise I would hate to work with it.
![my_terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n8mvrqmx4tdnweapitgu.png)