Skip to content
Home » Install and customize iTerm2 – oh my zsh

Install and customize iTerm2 – oh my zsh

iTerm2 is a virtual terminal that can replace the default terminal in macOS, offering many advanced features and customizations to suit your preferences. For example, most macOS users use iTerm2 because it offers autocomplete, multi-tab and window management, themes and custom fonts, and a wide range of settings that can be adjusted to create an optimal working environment. In this article, we’ll take a look at how to install and customize iTerm2.

Install iTerm2

You can either download and install iTerm2 from the official site or install it using homebrew. I will install it using homebrew, if you don’t have homebrew, please install it first.

Install iTerm2 using homebrew. When the iTerm2 installation is complete, exit the default terminal and run iTerm.

# Install iTerm2
$ brew install iterm2

Install zsh & Oh My Zsh

Install zsh

zsh is an improved version of the bourne shell with lots of new features. It’s becoming more popular because it’s free, easy to use and has lots of plugins and themes. If you don’t have zsh installed, install it and then change your default shell to zsh : macOS Catalina uses zsh as the default shell.

# Check for installation
$ zsh --version

# If it is not installed, install zsh and change the default shell.
# install zsh
$ brew install zsh

# Change the default shell
$ chsh -s `which zsh`

Install Oh My Zsh

Oh My Zsh is a framework that makes using zsh more comfortable and offers a variety of plugins and themes. Install Oh My Zsh using curl.

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

Setting up themes and fonts

Setting up a theme

Let’s change the theme of iTerm2. There are many different themes available, and you can choose any of them to change. We’ll use the agnoster theme, which is the most bland and makes it easy to see the git branch.

The theme can be set by changing the ZSH_THEME variable in the ~/.zshrc file. In iTerm, type the command vi ~/.zshrc and enter the desired theme name into the ZSH_THEME variable, as shown below. When you’re done, enter the source ~/.zshrc command to reflect the changes.

Setting up the iTerm2 Theme

Change the font

Let’s change the iTerm2 font, I prefer Naver D2 coding font, so let’s change it to D2 coding font. Download the font from the site below and open the font manager to install the font.

Go to the iTerm2 Preferences screen. ( iTerm2 > Settings menu or keyboard shortcut ⌘ + , ) and then click the Profile > Text menu and in the Font item, change to the font you want (D2 coding).

iTerm2 Font Change Screen

Change the color theme

iTerm2 has many different color themes. Let’s change the colors to the GitHub Dark theme, as shown below. After selecting the desired theme from the site below, you can download the theme file by clicking on the name. If it doesn’t download and takes you to an XML page, you can right-click on the name to download the linked file.

iTerm2 Color Theme

Go to the iTerm2 Preferences screen ( iTerm2 > Settings menu or keyboard shortcut ⌘ + , ) and then click the Profile > Colors menu, add the theme file you downloaded from Import from Color Presets, and select the theme file. If the theme file has a .txt extension, remove the .txt extension and change it to the itermcolors extension.

change iTerm2 color theme

Installing major plugins

There are a number of plugins available to help make zsh easier to use. To add a plugin, simply add it to the plugin entry in your ~/.zshrc file.

iTerm2 plugins

Auto Suggestions

It remembers commands you’ve already entered and suggests them to you.

Auto Suggestions

After downloading the Auto Suggestions Repository, add zsh-autosuggestions to the plugin in the ~/.zshrc file.

$ git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

syntax highlighting

Syntax Highlighting is a plugin that makes it easy to highlight and preview commands. After you install Syntax Highlighting, add it to the bottom of your ~/.zshrc file like this.

# install syntax highlightin
$ brew install zsh-syntax-highlighting

# syntax highlighting - added to the bottom of ./zshrc
source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

auto jump

j <Folder> command to jump to that folder at once. You can only jump to a folder you’ve visited once.

auto jump

Other settings

Clear a host from the screen

The username@hostname format, as shown below, can be inconvenient because the name part is long. Let’s change this to only show the username.

Clear a host from the screen

Add a status bar

You can add a status bar to the bottom of iTerm2 to see a variety of information, as shown below.

Add a ststus bar

Shortcuts

Here are some keyboard shortcuts for commonly used windows.

  • Open a new tab: Press Command + T to open a new tab.
  • Open a new window: Press Command + N to open a new window.
  • Split the screen: Press Command + D to split the current tab horizontally, or Command + Shift + D to split it vertically.

Reference

Leave a Reply

Your email address will not be published. Required fields are marked *