iTerm2
Last updated
Last updated
iTerm2 is an open source replacement for Apple's Terminal. It's highly customizable and comes with a lot of useful features.
You can get the app from iTerm2 downloads page. Once downloaded, drag and drop the iTermapplication file into your Applications folder.
Instead of downloading and installing iTerm2 manually, you can use Homebrew
brew cask install iterm2
We are going to setup spaceship-prompt
The final setup will be like this:
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.
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:
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 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
:
The installation script should set zsh
to your default shell, but if it doesn't you can do it manually:
Only for Linux:
We can get an error: chsh: /home/linuxbrew/.linuxbrew/bin/zsh is an invalid shell
To fix this error we need to add zsh in the list of the available shells in the system, so run:
Then we can set zsh as default shell with:
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:
Add plugins to your shell by adding the name of the plugin to the plugin
array in your .zshrc
.
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.
To use spaceship
we need to setup Powerline Fonts
. To do it open a new terminal and exec the following commands:
In Preferences > Profiles > Text and select the fonts:
Installing a patched font will mess up the integrated terminal in Visual Studio Code
unless you use the proper settings. You'll need to go to settings (CMD + ,
) and add or edit the following values:
for Source Code Pro: "terminal.integrated.fontFamily": "Source Code Pro for Powerline"
for Meslo: "terminal.integrated.fontFamily": "Meslo LG M for Powerline"
for other fonts you'll need to check the font name in Font Book.
You can also set the font size e.g.: "terminal.integrated.fontSize": 14
In the terminal run:
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/