How to Customize Your ZSH Terminal

Juhi Shah
3 min readJun 20, 2020

It’s important to know that starting with macOS Catalina, your Mac uses zsh as the default login and interactive shell. Eventually, Apple plans on completely phasing out bash. So if you haven’t already switched from bash to zsh, now is the time to do so! You can switch shells easily using the Apple guide here.

As developers, our terminals are always open in some form or the other…whether we’re running scripts, building our code, or making those git commits, we find ourselves heavily relying on our CLI.

So why, then, is it so hard to customize the zsh terminal while maintaining a balance of design and simplicity? On one hand, the built-in customization preferences of the terminal are too basic and it remains difficult to distinguish between the prompt, command, and the output. On the other hand, the frequently used oh-my-zsh framework comes with outlandish themes that aren’t as intuitive or simplistic.

In my opinion, it is therefore best to customize the zsh terminal yourself using a combination of the built-in terminal preferences and the very handy .zshrc file which I will talk about soon. To start off with, go into your terminal preferences and choose for the following…

1. background color
2. font size and color
3. cursor detail and color
4. window size
5. character and line spacing

After you’ve made the above baseline specifications for your terminal, you might end up with an interface such as this. I’ve changed the background to black, made the font size bigger, changed the color of the text and cursor, as well as increased line spacing and window size. Although this is much better than the standard white and black terminal, it is still really hard to discern between the username/hostname, current directory, and the commands I enter…everything just looks like a big blob of text. So let’s fix this!

This is where the .zshrc file comes into play; you should create it in the home directory. This file is the first thing the shell runs, so any custom configurations written here will execute as soon as you open the zsh terminal. Input this one-line configuration, save, quit, and then restart the terminal PROMPT='%F{033}%n%f %F{142}%1~%f ' . Now your terminal will look something like below! The username, current directory, and command you type in will all be different colors. Additionally, only your username will show up at the beginning of the prompt instead of the default which includes both the username and hostname.

So you might be wondering how all these seemingly scrambled letters, numbers, and symbols come together to create a simplistic and readable interface for your terminal. Let’s get into the specifics…

The %F and %f act as the respective opener and closer for the block of text you want colored. To specify the color, you can put the value in the brackets{} ; as you can see, I’ve set my username to blue and current directory to yellow using the 256 color chart here. The %n will print out your username and you can run the whoami command in the terminal to check what this is. Your current working directory is displayed with %~ but you can add an integer before the tilde like this %1~ if you only want the current directory to be shown (if you wanted to have the path of the previous directory as well, you could write %2~). My preference is keeping it at 1 since I only care about the directory I am currently in at the moment.

Now that you have this configuration set in the.zshrc file along with your terminal preferences set, it is much easier to work from your terminal with increased productivity as a result! For more information about other configurations you can add to the zsh terminal, check out the manual here.

--

--