MacOS: Revamp your Zsh terminal

Aditya Samant
4 min readMar 19, 2024

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.

Photo by Gabriel Heinzer on Unsplash

Oh My Zsh

Oh My Zsh ( 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.

Install Oh My Zsh

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.

source ~/.zshrc

Powerlevel10k

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.

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.

Install Powerlevel10k using the command below:

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:

ZSH_THEME="powerlevel10k/powerlevel10k"

After installation, restart Zsh using the following command:

This will open the Powerlevel10k configuration wizard.

Here are the options that worked best for me:

Try a command such as

You will see the an immediate change:

zsh-autosuggestions

zsh-autosuggestions suggests commands as you type based on history and completions.

Install the zsh-autosuggestions plugin using the following command:

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)

plugins=(git zsh-autosuggestions)

Source the .zshrc using the following command:

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.

zsh-syntax-highlighting

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:

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)

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

Source the .zshrc using the following command:

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

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.

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.

Wow, now that’s an awesome upgrade!

Happy coding!

Originally published at https://blog.adityasamant.dev on March 19, 2024.

--

--

Aditya Samant

A passionate software professional with a knack for exploring and sharing my insights in the tech world.