Zsh + Oh My Zsh: A Powerful and Beautiful Terminal

Ernesto Angulo
8 min readMay 1, 2021

--

In the previous post, you learned how to install WSL, which allows you to obtain all the power of the Linux terminal inside Windows. ๐Ÿ˜Ž However, when you open the terminal, you may think it looks boring and ugly. Well, you have nothing to worry about ๐Ÿ˜ต because I will teach you how to solve this problem easily.

Ubuntu default terminal

Hi! Iโ€™m Ernesto, and in this post, I am going to teach you how to install the zsh shell and oh-my-zsh, so you can make your terminal look beautiful ๐ŸŒˆ and give it more power ๐Ÿฆพ with some plugins.

What is Zsh?

Also called Z shell, it is a UNIX shell that is used as a command interpreter for shell scripting. This shell is an extended version of Bourne Shell with many improvements.

In simpler words, Zsh allows us to communicate with our computers through commands.

What is Oh My Zsh?

It is an open-source, community-driven framework for managing the Zsh configuration. Oh, My Zsh includes more than 275 plugins and 150 themes with which we can custom our terminal to make it powerful and beautiful.

Apart from the 150 themes included in Oh My Zsh, you can install other third party themes. The most popular is called PowerLevel10k.

Before you start, remember that I will use WSL and Ubuntu for this process. If you donโ€™t have them installed, you can read my previous post.

Now letโ€™s go to the fun part. ๐Ÿ˜

Install Zsh

Update Packages

Before you install Zsh, make sure you have all your packages up to date.

If you already have your packages up to date, you can skip this step.

Open Windows Terminal, select Ubuntu, and run the following command:

sudo apt update

This command will verify if there exists any update available for your packages.

Donโ€™t forget that when you use sudo, you will have to enter the password you created when installing Ubuntu or any other distro.

When the process finishes, it will list all packages that need to be updated. To upgrade them run this command.

sudo apt upgrade

This process may take several minutes to complete.

Install Zsh and Set It as the Default Shell

Run this command to install Zsh:

sudo apt install zsh

Once the process finishes, run this other command to set Zsh as the default shell. Remember to enter your sudo password.

chsh -s $(which zsh)

After that, close the terminal and reopen it. It will ask you to make the initial configuration; type 2 and press enter.

zsh default terminal

You will notice that the terminal has changed; this is because Zsh sets a default theme. In the next steps, you will learn how to customize it.

Now you have Zsh installed. Pretty easy, right? You can confirm if you installed it correctly running the following command; it should print /usr/bin/zsh.

echo $SHELL

Install Oh My Zsh

You have to run this command to install Oh My Zsh:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

When the process finishes, you will notice, once again, that the theme has changed. Oh, My Zsh set another default theme called robbyrussell.

oh-my-zsh installed

Install Visual Studio Code Extension for WSL

To follow the next steps, you must have an extension called Remote-WSL installed. This extension allows VS Code to work with WSL. If you have already installed it, continue with the next steps.

Remote-WSL extension

Edit the Configuration File

This file is the one that contains all the Zsh configuration, and itโ€™s the one you have to edit to enable the different themes and plugins that Oh My Zsh offers.

To edit this file, open it with VS Code by running the following command.

code ~/.zshrc

Customize Your Theme

Search for the ZSH_THEME configuration in the file you just opened (.zshrc). Edit this configuration with the name of the theme you prefer and save the file.

You can find all themes available with Oh My Zsh in this link.

If you are not sure what theme to choose, I recommend you write random. With this configuration, every time you open the terminal, it will have a different theme. If you find one you like, you can copy its name and place it in the "ZSH_THEME" configuration.

ZSH_THEME = "random"
Change theme

Add Plugins

Plugins give more functionality to the terminal and can be a powerful tool. Some of the more famous are autosuggestions which suggest and auto-completes commands, and syntax highlighting which highlights the commands depending on their type.

To install the plugins, run these commands:

# Autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
# Syntax Highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

Now you have the plugins installed, but you need to enable them too. Go to the .zshrc file, search for the "plugins" configuration, and add the plugins you just installed.

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

In this link, you will find all the plugins available to install.

Install Powerlevel10k

Oh, My Zsh comes bundled with a lot of themes we can choose from, but the most popular, and in my opinion, the best one, is Powerlevel10k, which you will learn to install now.

Install NerdFonts

For Powerlevel10k to work, a font from NerdFonts is required. There are many different fonts you can choose from, and in this link, you can find them all. However, the font I recommend you install is FuraMono, which you can download here.

After you download the file, open it, and install it.

Clone GitHub Repository

Run this command.

git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k

If you want to see the repository, you can find it here.

Set Powerlevel10k as the Default Theme

Go to the .zshrc file and change the "ZSH_THEME" configuration like this:

ZSH_THEME="powerlevel10k/powerlevel10k"

Also, in the next line, add the following configuration to enable the font you just installed.

POWERLEVEL9K_MODE="nerdfont-complete"
Change zsh theme

Save and close the file.

Now, in the terminal, you will see the initial configuration of the Powerlevel10k theme.

To complete this configuration, you must read the instructions and choose the options you like the most.

PowerLevel 10K configuration

But wait! Do not do anything yet. If you read the instructions, youโ€™ll notice that it says that you should see a diamond ๐Ÿ”ท, but what you see is a square. This happens because you have not enabled the font FuraMono for Windows Terminal yet.

No diamond

Configure Windows Terminal

Enable Font

In Windows Terminal, click the dropdown menu and select settings to open the configuration file of Windows Terminal in VS Code.

Do not confuse the configuration file of Zsh (.zshrc) with the one of Windows Terminal (settings.json). They are very different.

In the settings.json file, search for the configuration group of the Ubuntu terminal and add the following line.

"fontFace": "FuraMono Nerd Font"
Change font

Go back to the terminal, and you should see that diamond ๐Ÿ”ท that the instructions say. Now you can start the initial configuration of Powerlevel10k.

Diamond found

Change Theme (optional)

Once you finish the configuration, your terminal should look something like this (it may vary depending on what you chose).

Default Windows Terminal theme

In Windows Terminal, you can also change its theme and customize its colors like in Zsh.

There are a lot of themes on the web. In this link, you can find some of the best ones. The theme I like the most is Aurelia. To add it, go to the settings.json file, search for "schemes", and add the following lines.

{
//Color Scheme: Aurelia
"name": "Aurelia",
"background": "#1a1a1a",
"black": "#000000",
"blue": "#579BD5",
"brightBlack": "#797979",
"brightBlue": "#9CDCFE",
"brightCyan": "#2BC4E2",
"brightGreen": "#1AD69C",
"brightPurple": "#975EAB",
"brightRed": "#EB2A88",
"brightWhite": "#EAEAEA",
"brightYellow": "#e9ad95",
"cyan": "#00B6D6",
"foreground": "#EA549F",
"green": "#4EC9B0",
"purple": "#714896",
"red": "#E92888",
"white": "#EAEAEA",
"yellow": "#CE9178"
}

You can add as many themes as you want inside the scheme array.

Now in the configuration group of the Ubuntu terminal, add this line.

"colorScheme": "Aurelia"
Change Windows Terminal theme

Edit the Font for the Visual Studio Code Integrated Terminal

Open VS Code and open the settings. Search for "terminal font", and write this: "FuraMono Nerd Font".

Change VS Code integrated terminal font

And that is it. ๐Ÿฅณ ๐Ÿฅณ ๐Ÿฅณ

Conclusions

You went from a terminal that looked like this:

Ugly terminal

To a terminal that looks like this:

Awesome terminal

The difference is enormous, right? ๐Ÿ˜… Thanks to WSL, Zsh, Oh My Zsh, and Windows Terminal you have now a beautiful and powerful terminal. ๐Ÿ˜Ž

In the next post, I will teach you to install in WSL some mandatory tools for any developer. Iโ€™ll see you there. ๐Ÿ˜‰

Thanks for reading! ๐Ÿ“– If this post helped you, please give it a clap. ๐Ÿ– And let me know if you have any contribution, comment, doubt, or recommendation. It helps me a lot to improve my content. ๐Ÿ˜ƒ

See you in the next post. ๐Ÿ‘‹

Originally published at https://ernestoangulo.hashnode.dev.

--

--

Ernesto Angulo

Just someone who likes design ๐ŸŽจ and code ๐Ÿ’ป. Systems Engineering student. https://dribbble.com/netosym