iTerm2
iTerm2 is an open source replacement for Apple's Terminal. It's highly customizable and comes with a lot of useful features.
Installation
You can get the app from iTerm2 downloads page. Once downloaded, drag and drop the iTermapplication file into your Applications folder.
Customization
We are going to setup spaceship-prompt
The final setup will be like this:

Requirements
For correct work you will first need:
zsh
(v5.0.6 or recent) must be installed.Powerline Font must be installed and used in your terminal.
Install zsh
The Z shell (also known as zsh
) is a Unix shell that is built on top of bash
(the default shell for macOS) with additional features. It's recommended to use zsh
over bash
. It's also highly recommended to install a framework with zsh
as it makes dealing with configuration, plugins and themes a lot nicer.
We've also included an env.sh
file where we store our aliases, exports, path changes etc. We put this in a separate file to not pollute our main configuration file too much. This file is found in the bottom of this page.
Install zsh
using Homebrew:
$ brew install zsh
Now you should install a framework, we'll use Oh My Zsh.
The configuration file for zsh
is called .zshrc
and lives in your home folder (~/.zshrc
).
Oh My Zsh
Oh My Zsh is an open source, community-driven framework for managing your zsh
configuration. It comes with a bunch of features out of the box and improves your terminal experience.
Install Oh My Zsh
:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
The installation script should set zsh
to your default shell, but if it doesn't you can do it manually:
chsh -s $(which zsh)
Configuration
The out-of-the-box configuration is usable but you probably want to customise it to suit your needs. The Official Wiki contains a lot of useful information if you want to deep dive into what you can do with Oh My Zsh, but we'll cover the basics here.
To apply the changes you make you need to either start new shell instance or run:
source ~/.zshrc
Plugins
Add plugins to your shell by adding the name of the plugin to the plugin
array in your .zshrc
.
plugins=(git colored-man-pages colorize brew osx zsh-syntax-highlighting)
You'll find a list of all plugins on the Oh My Zsh Wiki. Note that adding plugins can cause your shell startup time to increase.
Font Setup
To use spaceship
we need to setup Powerline Fonts
. To do it open a new terminal and exec the following commands:
# clone poweline fonts repo
git clone https://github.com/powerline/fonts.git --depth=1
# install it
cd fonts/
./install.sh
# clean-up a bit
cd ..
rm -rf fonts/
Setting fonts in iTerm2
In Preferences > Profiles > Text and select the fonts:


We can finally install Spaceship
In the terminal run:
# clone spaceship repo in the themes folder of zsh
git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt"
# link the folder
ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"
Now open ~/.zshrc and replace ZSH_THEME="robbyrussell" with ZSH_THEME="spaceship"
Restart iTerm2 and at this point you should have a result like this:

You can find the official spaceshipt-prompt documentation on Gitbook here: https://denysdovhan.com/spaceship-prompt/
Last updated