# MacOS: Revamp your Zsh terminal

As software professionals, we love to make things look cool, don't we? Imagine you are presenting a demo to a large audience and all they are seeing is a black and white terminal. Well, that would be hard to follow and many would lose interest. Instead, if you could present a terminal filled with colours, autocompletion and some syntax highlighting, wouldn't that be great?

Well, what are we waiting for? Let's go ahead and revamp our Zsh terminal.

## Oh My Zsh

[Oh My Zsh](https://github.com/ohmyzsh/ohmyzsh) (*pronounced oh my zee shell*) is an open source, community-driven framework for managing your zsh configuration.

> Oh My Zsh will not make you a 10x developer...but you may feel like one.

<div data-node-type="callout">
<div data-node-type="callout-emoji">❗</div>
<div data-node-type="callout-text">Make a backup of your existing .zshrc file before executing any step in this lab.</div>
</div>

Install `Oh My Zsh`

```bash
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
```

As soon as the installation is complete, you will see a hint of colour on your terminal.

`Oh My Zsh` creates a new `.zshrc` file. Copy the custom alias, paths and secrets from your backup `.zshrc` file and paste it at the end of the new file.

Save the file and source it.

```bash
source ~/.zshrc
```

## Powerlevel10k

[Powerlevel10k](https://github.com/romkatv/powerlevel10k) is a theme for Zsh. It emphasizes speed, flexibility and out-of-the-box experience. It boosts the terminal with a nice new font and enables a fully customizable look and feel.

Install the `Meslo Nerd Font` by following the instructions mentioned [here](https://github.com/romkatv/powerlevel10k?tab=readme-ov-file#manual-font-installation).

After installing the Font, Open *Terminal → Settings → Profiles → Text*, click *Change* under *Font* and select `MesloLGS NF` family. If you're unable to spot the Font, ensure you select "All Fonts" under the "Collection" option. *Refer to the picture below.*

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1710843340338/95c7d4b1-c71f-46cc-8a52-99ccaf2faf11.png align="center")

Install `Powerlevel10k` using the command below:

```bash
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
```

Next step is to use the `Powerlevel10k` these for `Oh My Zsh`. To do that, open the `~/.zshrc` file and edit the value of the existing field `ZSH_THEME` from `robbyrussell` to `powerlevel10k/powerlevel10k` as follows:

```bash
ZSH_THEME="powerlevel10k/powerlevel10k"
```

After installation, restart `Zsh` using the following command:

```bash
exec zsh
```

This will open the `Powerlevel10k` configuration wizard.

Here are the options that worked best for me:

| Prompt | Answer (Option entered) |
| --- | --- |
| Does this look like a diamond (rotated square)? | Yes (y) |
| Does this look like a lock? | Yes (y) |
| Does this look like an upward arrow? | Yes (y) |
| Do all these icons fit between the crosses? | Yes (y) |
| Prompt Style | Lean (1) |
| Character Set | ASCII (2) |
| Prompt Colors | 256 (1) |
| Show current time? | No (n) |
| Prompt Height | One line (1) |
| Prompt Spacing | Compact (1) |
| Prompt Flow | Fluent (2) |
| Enable Transient Prompt | No (n) |
| Instant Prompt Mode | Verbose (1) |
| Apply changes to ~/.zshrc | Yes (y) |

Try a command such as

```bash
cd ~/Documents
```

You will see the an immediate change:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1710845418620/c56760db-c95d-4b04-bc18-a6a674f6d44b.png align="center")

## zsh-autosuggestions

[zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions) suggests commands as you type based on history and completions.

Install the `zsh-autosuggestions` plugin using the following command:

```bash
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
```

Add the plugin to the list of existing plugins for `Oh My Zsh` to load (inside `~/.zshrc`)

```bash
plugins=(git zsh-autosuggestions)
```

Source the `.zshrc` using the following command:

```bash
source ~/.zshrc
```

Try to type some commands you have used before and you will see that the terminal suggests an auto-completion. To choose the suggested option, simply click the right arrow key.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1710845344001/34d44d7f-0074-4d2e-931b-ebe621c6810a.png align="center")

## zsh-syntax-highlighting

[zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting) provides syntax highlighting for `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.

Install the `zsh-syntax-highlighting` plugin using the following command:

```bash
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
```

Add the plugin to the list of existing plugins for `Oh My Zsh` to load (inside `~/.zshrc`)

```bash
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
```

Source the `.zshrc` using the following command:

```bash
source ~/.zshrc
```

Try to type some commands. You will find that the terminal highlights valid commands in green and invalid commands in red.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1710845454420/9324a672-7d08-440b-91d9-845cf0213f4c.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1710845486105/18ee8443-a3a6-4c4d-b858-e5fa11ed9c32.png align="center")

## Kubernetes Joy

For Kubernetes users, as soon as you type `kubectl` , the active context from the `kubeconfig` file is shown at the right of the terminal.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1710845761623/d3966a66-0b5f-47bb-8582-7bcaf2c93cb7.png align="center")

If the current namespace is anything other than default, it shows the custom namespace as well. In the below example, the context name is `istio` and the namespace is `temp`.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1710845917713/2cda427d-7754-4f2c-8f88-b6832c7f46e3.png align="center")

Wow, now that's an awesome upgrade!

Happy coding!
