The definitive iTerm2 & Oh-my-ZSH Setup on macOS
Tags: tutorial, codenewbie, webdev, beginners
Published: 2020-12-16 06:17:07

*This post was first published on my [blog](https://blog.larsbehrenberg.com).

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

> Once installed, your terminal shell will become the talk of the town or your money back! With each keystroke in your command prompt, you'll take advantage of the hundreds of powerful plugins and beautiful themes. Strangers will come up to you in cafés and ask you, "that is amazing! are you some sort of genius?"

**Are you sold yet? I am for sure. So, let's get started!**

## Table Of Contents

-  [Installation](#installation) 
-  [Styling](#styling) 
    -  [Set your Color Scheme](#set-your-color-scheme) 
    -  [Oh-my-ZSH Themes](#choose-your-ohmyzsh-theme) 
-  [Functionality](#functionality) 
    -  [Get some plugins](#plugins) 
    -  [Set up your shortcuts](#set-up-some-shortcuts-%E2%8C%98%E2%86%90-%E2%8C%98%E2%86%92-and-%E2%8C%A5%E2%86%90-%E2%8C%A5%E2%86%92) 

## **Installation**

To get started, we have to install a few things first. Starting with iTerm.

**You can simply download iTerm from [its website](https://iterm2.com/downloads.html)**, but since you are I assume a terminal user, I highly recommend you to use **Homebrew**. Think of HomeBrew as a package manager to install and manage software on macOS. We will be using it to download iTerm, but you can use it to download lots of other packages as well.

First, if you don't have already, let's download and install [Homebrew](http://sourabhbajaj.com/mac-setup/Homebrew/).


<pre>

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

</pre>


Then let's use [Homebrew](http://sourabhbajaj.com/mac-setup/Homebrew/) to download and install iTerm 2:

<pre>

brew cask install iterm2

</pre>

**Install zsh and oh-my-zsh**

1. Once this is done, we will open up our new iTerm application to **install zsh and oh-my-zsh**.

<pre>

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

</pre>

![Oh my ZSH](https://dev-to-uploads.s3.amazonaws.com/i/0d32a2z80c5f6iba3kb8.png)

**The oh-my-zsh install will replace your default terminal with zsh automatically when installed. **

Now, that we have the basic installation out of the way, let's make sure everything looks nice before we get to set up more functionality. Let's get to style our terminal.

# Styling

## Set your Color Scheme

iTerm already provides different color schemes out of the box, but there are also many on the internet, **free for you to download**. And of course, feel free to go with a different one than the one I go with below! Here is a list of lots of different themes to download: 

[iTerm 2 Color Schemes](https://iterm2colorschemes.com/)

My current personal favorite is the [iTerm Material Design](https://github.com/MartinSeeler/iterm2-material-design) based on Google's popular Material UI colors. However, I manually set a darker background color, to match my dark mode UI better. Somewhere around **#121415**.

To download the color theme, simply copy the code below into your terminal:

<pre>

cd Downloads && curl -O https://raw.githubusercontent.com/MartinSeeler/iterm2-material-design/master/material-design-colors.itermcolors

</pre>

This will direct you into your Downloads folder and **download the color preset to that directory for you**.

Following this, we need to tell iTerm to use the preset we just download. For this, you open iTerm 2 and press **"CMD + , "** which will **open up your iTerms preferences**.

Select the **Profile tab and Colors Tab**. Right there at the bottom right, you can find the color preset option.

![Add a color theme](https://dev-to-uploads.s3.amazonaws.com/i/dfswx3fftx81r1bhhcf7.png)

**Press the Color Presets select and choose "Import"**, to import your previously downloaded color preset from the Downloads folder.

Now, don't forget to also select the preset once you have imported it. It will show up in the list just like this:

![Color theme list](https://dev-to-uploads.s3.amazonaws.com/i/lkmt9pkyrj0oawa97vvc.png)

One last step for me, is to **change the background color** here, to get the "darker" mode:

![Add a darker background](https://dev-to-uploads.s3.amazonaws.com/i/7h7lzrasr4riahzuhm6a.png)

## Choose your Oh-my-ZSH Theme

Beyond figuring out your color scheme, you might want to add an **oh-my-zsh theme** that changes up the way your commands or current directory line might look and even can give **additional functionality like timestamps and more**.

Here is a list of popular themes.

[Slant - What's the best theme for Oh My Zsh?](https://www.slant.co/topics/7553/~theme-for-oh-my-zsh)

My personal favourite here is "Powerlevel10k":

[romkatv/powerlevel10k](https://github.com/romkatv/powerlevel10k)

Here an image of the different theme styles you can configure with it.

![Powerlevel10k theme styles](https://dev-to-uploads.s3.amazonaws.com/i/d3z79e7qj5kneh6brvtn.png)

In this example, we will go through how to download the **"Powerlevel10k" theme**, but this is similar for all other themes too. It comes down to two steps:

1 . **We will have to download the theme into the oh-my-zsh custom theme directory.** In this example, we use the git clone command for this.

<pre>

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

</pre>

2 . Next up is **changing the theme setting in our `~/.zshrc` **

For VI or VIM users simply type:

<pre>

vi ~/.zshrc

</pre>

For people that are not familiar with the vim commands or just prefer a simple text editor, type:

<pre>

open ~/.zshrc

</pre>

In our `~/.zshrc`, you will find **a paragraph that looks like this** (usually third paragraph from the top):

<pre>

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="robbyrussell"

</pre>

Simply **change this last line** to your theme name:

<pre>

ZSH_THEME="powerlevel10k/powerlevel10k"

</pre>

**Save the file and restart iTerm and you are done!**

With the **"Powerlevel10k" theme** you will now be prompted with a quick setup tutorial that runs you through the different options for the theme, but then you are set!

**You now have a sleek looking terminal!**

# Functionality

Having a pretty looking terminal is nice and all, but maybe we want to **add some more functionality** in there too! This is where **plugins and shortcuts** come in.

## Plugins

With **"Oh-my-ZSH"** we already get out of the box tons of different features that will enhance your workflow like auto-completion and others. But we want more. This is where plugins come in handy.

Depending on your setup and what languages you code in, your plugins might vary, so here is the official oh-my-zsh plugin wiki with a list of all the default plugins available..

[ohmyzsh/ohmyzsh-plugins](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins)

To install plugins for VI or VIM users simply type:

<pre>

vi ~/.zshrc

</pre>

For people that are not familiar with the vim commands or just prefer a text editor, type:

<pre>

open ~/.zshrc

</pre>

In there you will find a place to **add your list of plugins** that you would like to install, like this:

<pre>

plugins=(
	git
	brew
	heroku
	gatsby
	yarn
)

</pre>

***An important note here:***
For the plugins to load in, **you will have to restart iTerm!**

## Set up some shortcuts: **⌘←, ⌘→ and ⌥←, ⌥→**

One really useful productivity shortcut I found was **how to skip a word** with ⌥+←or→  or **go to start/end of the line** with ⌘+←or→.

iTerm does not support this out of the box, but with a few quick shortcuts added in the settings, this is quickly done. Here's how you set them up:

Open up iTerm2 preferences (⌘ + ,) -> Go to Profiles -> Keys -> Click on `+` icon (add new Keyboard shortcut).

![Add a keyboard shortcut](https://dev-to-uploads.s3.amazonaws.com/i/vzwurbnsaxyx0qgyjbu5.png)

Here, you **select the "Action" as "Send Escape Sequence" **with following commands for **"ESC+"**:
![Setting the shortcuts](https://dev-to-uploads.s3.amazonaws.com/i/wxqvd46th76pk6qit76h.png)



## That’s pretty much it!

Thanks so much for reading this far and with this, you are ready to go with your new fancy looking terminal! Feel free to reach out to me anytime, on [my website](https://larsbehrenberg.com/) or on [Twitter](https://twitter.com/codetraveling)