Customise Your Terminal Using Zsh & powerlevel10k
Tags: tutorial, linux, productivity, bash
Published: 2021-05-20 05:55:11


##Transform your terminal from this to this !!
####Before
![Before Terminal Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dnii5tg1q09p1es13sxo.png) 
####After
![After Terminal Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2k6iczro9j8uzd6zozdn.png)
###What we will setup
####1.Zsh
ZSH, also called the Z shell, is an extended version of the Bourne Shell (sh), with plenty of new features, and support for plugins and themes. 
####2.Powerlevel 10k
Powerlevel10k is a theme for Zsh. It emphasizes speed, flexibility and out-of-the-box experience.
####3.Zsh-syntax-highlighting
This package provides syntax highlighting for the shell zsh. It enables highlighting of commands whilst they are typed at a zsh prompt into an interactive terminal. This helps in reviewing commands before running them, particularly in catching syntax errors.
Some examples:
Before: ![](https://github.com/zsh-users/zsh-syntax-highlighting/raw/master/images/before1-smaller.png)
After:  ![](https://github.com/zsh-users/zsh-syntax-highlighting/raw/master/images/after1-smaller.png)

####4.Zsh-autosuggestions
As you type commands, you will see a completion offered after the cursor in a muted gray color.
If you press the → key (forward-char widget) or End (end-of-line widget) with the cursor at the end of the buffer, it will accept the suggestion, replacing the contents of the command line buffer with the suggestion.

###1.Install Zsh
1)Installation
#####Ubuntu, Debian & derivatives
```
sudo apt install zsh
```
#####Arch Linux or Manjaro
```
pacman -S zsh
```
#####macOS
```
brew install zsh
```

2)Verify your installation by running `zsh --version`. Expected result: `zsh 5.0.8` or more recent.

3)Make it your default shell
```
chsh -s $(which zsh)
```
> Note that this will not work if Zsh is not in your authorized shells list `(/etc/shells)` or if you don't have permission to use `chsh`. If that's the case [you'll need to use a different procedure](https://www.google.com/search?q=zsh+default+without+chsh).

4)Log out and log back in again to use your new default shell.

5)Test that it worked with `echo $SHELL`. Expected result: `/bin/zsh` or similar.

* * *

###2.Install and Cofigure powerlevel10k
**1)Font** 
Powerlevel10k doesn't require custom fonts but can take advantage of them if they are available. It works well with [Nerd Fonts](https://github.com/ryanoasis/nerd-fonts), [Source Code Pro](https://github.com/adobe-fonts/source-code-pro), [Font Awesome](https://fontawesome.com/), [Powerline](https://github.com/powerline/fonts), and even the default system fonts. The full choice of style options is available only when using [Nerd Fonts](https://github.com/ryanoasis/nerd-fonts).
**Recommended font: Meslo Nerd Font patched for Powerlevel10k.**
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:
- **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`.
- **Apple Terminal**: Open *Terminal → Preferences → Profiles → Text*, click *Change* under *Font*
  and select `MesloLGS NF` family.
- **Microsoft Terminal**: Open *Settings* (`Ctrl+,`), search for `fontFace` and set
  value to `MesloLGS NF` for every profile.
*If you are using any other terminal [click here](https://github.com/romkatv/powerlevel10k/blob/master/font.md#:~:text=.%20Configure%20your%20terminal%20to%20use%20this%20font%3A) for the configuration.*

**2)Installation**
Clone the powerlevel10k repo
```
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
```
Source the powerlevel10k theme script in your .zshrc
```
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
```
After this `exit` and reopen your terminal.
Now you will see this message.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y9gnbfvwdh40owbtwqmx.png)

This is the Powerlevel10k cofiguration wizard select the options that you like and make your custom prompt !!
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ehmn1uwfutzhbm0bta9a.png)
Choose the propmt style that you like.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gepzmavk8cwwkzrjarx3.png)
Press Y and save your changes.

If you want to change your prompt again just run the follwing command.
```
p10k configure
```
This will take you the Powerlevel10k cofiguration wizard.

* * *

###3.Zsh-autosuggestions and Zsh-syntax-highlighting
**1)Zsh-autosuggestions**


Clone the Zsh-autosuggestions repo
```
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
```
Source the script in your .zshrc
```
echo 'source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh'>>~/.zshrc
```
Then `exit` and start a new terminal session.

**2)Zsh-syntax-highlighting** 

Clone the Zsh-syntax-highlighting repo
```
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
```
Source the script in your .zshrc
```
echo 'source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh'>>~/.zshrc 
```
>Note the source command must be at the end of ~/.zshrc.

Now `exit` and start a new terminal session.

And et voilà !
Your terminal is ready!
Thank you so much for reading this article and do let me know your thoughts in comments!

* * *
Reach me:
[Twitter](https://twitter.com/Pratik_kale135) | [Instagram](https://www.instagram.com/pratikkale.in/) | [Mail](mailto:ppvkale@gmail.com)

Repositories Mentioned:
{% github romkatv/powerlevel10k no-readme%}
{% github zsh-users/zsh-autosuggestions no-readme %}
{% github zsh-users/zsh-syntax-highlighting no-readme%}