JB

Customizing the terminal the way I like it: Terminal on MacOS with Oh My Zsh, Powerlevel10k, iTerm2, Dracula, Plugins and more

terminaldraculaoh my zshiterm2
Jan 26, 2022
7 min

Some time ago, I started a new chapter in my career as a developer, working for a major company, IBM. Along with it, I received a new machine, a 16-inch MacBook Pro from 2019, my first time using macOS! I was excited to dive into the new operating system and build my own experiences and opinions around it.

Since starting this new journey, my workload has been pretty intense, and until now, I had not taken the time to customize the machine the way I like it. So today, I am setting up the terminal and sharing some tools that I find interesting for working with macOS, most of which also apply to any Unix-based system.

If you are looking for tips on setting up Visual Studio Code (VSCode), browsers, and quick configurations for Windows, you can check out my other article where I cover setting up a Windows machine. The big difference here is that on macOS I am using Homebrew as the package manager, similar to APT on Linux or Chocolatey on Windows.

To install Homebrew, use the following command:

/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Assuming you have already checked out the other article and have Git, VSCode, Homebrew, or APT installed, it is time to start making this terminal shine!

Installing ZSH

ZSH is a tool that interprets shell scripting commands, designed to make the terminal experience easier and more flexible. It allows a wide range of customizations related to the interface, productivity plugins, terminal optimizations, and more.

Since I am using macOS Big Sur, which already comes with ZSH pre-installed, I will just explain how you can install it on your Unix system if needed. You can use Homebrew, which you should have just installed, with the following command:

brew install zsh

After installing ZSH, you can check the installed version by running:

zsh — version

You should see something like the example shown in the image below.

Versão do ZSH: zsh 5.8 (x86_64-apple-darwin20.0)

If you encounter any issues with ZSH installation, you can refer to the complete guide they provide here: https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH.

Installing Oh My ZSH

Oh My ZSH will allow you to configure themes for your terminal, along with several other useful features.

To install Oh My ZSH, just run the following command:

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

You will probably see a screen similar to this:

Output da instalação do ZSH

Notice that I am inside a Git repository, and besides changing the layout of the information in the terminal, some colors were added to make it easier to read and organize the content.

If the colors in your terminal do not change right away, try closing and reopening the terminal, or run the following command:

source ~/.zshrc

You can also restart just the ZSH session by running:

exec zsh

Now that you have both ZSH and Oh My ZSH installed, whenever you need to add environment variables or configure your terminal, it is best to use the ~/.zshrc file instead of ~/.bash_profile or similar files.

If you encounter any issues with this step, you can refer to the official installation guide: https://github.com/ohmyzsh/ohmyzsh/.

Changing the Theme to PowerLevel10K

There are countless ZSH themes available that change the layout and the amount of information shown in your terminal. I personally use the PowerLevel10K theme because it keeps the interface clean while showing a useful amount of information, like folder paths, Git status, and the current time.

There are two ways to install this theme. The first one is by running the following command:

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >> ~/.zshrc

After that, PowerLevel10K will guide you through a series of setup questions to configure the theme the way you like.

CLI de configuração do tema powerlevel10k

If you ever want to reconfigure it later, you can simply run the following command:

p10k configure

The second method, which I personally prefer, is to manually clone the PowerLevel10K repository directly into your ZSH themes folder by running:

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

And then update the ZSH_THEME variable in your configuration file ~/.zshrc

ZSH_THEME=”powerlevel10k/powerlevel10k”

After that, just restart ZSH and reconfigure the theme however you prefer.

If you encounter any issues during the theme setup, I recommend checking the official guide created by the developers: https://github.com/romkatv/powerlevel10k

Dracula Theme on macOS Default Terminal

Dracula is a theme based on a color palette that I find really pleasant. It is available for many terminals, and you can check them all here: https://draculatheme.com under the Terminal section.

In this part, I will be setting up Dracula on the default macOS Terminal, so I will be using this version: https://draculatheme.com/terminal.

If you are on Windows using Windows Terminal, you can find it here: https://draculatheme.com/windows-terminal.

If you are using Linux with a Gnome-based distribution, you can use this guide: https://github.com/dracula/gnome-terminal.

To install the Dracula theme on the default macOS Terminal, just clone the repository with:

git clone https://github.com/dracula/terminal-app.git ~/Documents/themes/terminal

I chose to clone it into my Documents/themes/terminal folder, but you can place it wherever you prefer.

After that, you just need to import the color scheme into the Terminal:

Menu de importar paleta de cores do Terminal default do MacOS

Then, select it as the default terminal theme by clicking on the new theme that appears and setting it as default. While I am on this screen, I am also going to change the cursor style to a vertical bar with the color #50fa7b, and set the font size to 18, using a font I manually installed. Below is an image showing these settings:

Menu de perfis do terminal com quadrados azuis ao redor das configurações citadas.

Installing iTerm2 with the Dracula Theme

Even though I have customized the default macOS Terminal, I also want to try iTerm2, a very popular alternative.

Another interesting option to consider besides iTerm2 is Hyper.

To install iTerm2, run:

brew install iterm2 — cask

Now, let's download the Dracula theme for iTerm2. I will save it in the same folder where I placed the theme for the Apple Terminal:

git clone https://github.com/dracula/iterm.git ~/Documents/themes/iterm

The last step is to open iTerm2 and go to iTerm2 > Preferences > Profiles > Colors Tab, then import the color scheme by selecting the Dracula.itermcolors file from the folder we just downloaded.

Here’s a screenshot showing the import menu:

Menu de importar paleta de cores do iTerm2

Now just select the Dracula color profile, and in the "Text" tab, adjust the cursor and the font the same way we did earlier for the default macOS Terminal.

ZSH plugins

I only use two ZSH plugins, which are:

  • zsh-users/zsh-autosuggestions: Suggests commands based on your command history.
  • zdharma-continuum/fast-syntax-highlighting: Adds syntax highlighting to your terminal.

To install these plugins, I will first install a ZSH plugin manager called Zinit with the following command:

# instala zinit
sh -c "$(curl -fsSL https://git.io/zinit-install)"# reinicia zsh
exec zsh# atualiza zinit
zinit self-update

Now, I will open the ~/.zshrc file and, right after the lines that say "### End of Zinit’s installer chunk," I will add the following:

zinit wait lucid light-mode for \
  atinit"zicompinit; zicdreplay" \
      zdharma-continuum/fast-syntax-highlighting \
  atload"_zsh_autosuggest_start" \
      zsh-users/zsh-autosuggestions \
  blockf atpull'zinit creinstall -q .' \
      zsh-users/zsh-completions

And that’s it. Now we have syntax highlighting and command auto-suggestions based on previously executed commands.

Demonstração de auto complete

Integrated Terminal in VSCode

If you use VSCode, you can add the following setting to your settings.json file to use Oh My Zsh in the integrated terminal:

"terminal.integrated.shell.osx": "/bin/zsh"

Extra Recommendations

There are a few tools that I personally use and highly recommend you try:

  • Insomnia, An API client for REST, GraphQL, gRPC, and OpenAPI modeling, designed specifically for developers.
  • Beekeeper Studio, A powerful SQL client for MySQL, Postgres, SQLite, SQL Server, and other databases.
  • iStat Menus, A handy tool for monitoring hardware usage on macOS in real time.

Conclusion

I have finished setting up my terminal, and for now, this is the approach I am using. I will probably discover new tools along the way, and when I update my setup in the future, I will share new posts about those updates. With this walkthrough, I hope you got at least a few ideas on how to customize your own terminal, adding new plugins and your favorite color palettes.

I truly believe it is worth investing time in making your terminal feel good to you. After all, we spend a lot of time using this tool every day.

Sapere aude.