Photo by Markus Spiske on Unsplash

Making a Snazzy Terminal on macOS with Git Support

I’ve found myself using the command line a lot more as part of my day-to-day development process and stumbled across a few neat tools that make life in the terminal a lot more pleasant, which I wanted to share.

The end results looks like this — note the colourisation in the console, the Git status (showing branch name and remote status) and the status bar components (bottom) showing resource usage (Battery, CPU, RAM and Network)

The above is my preference, but it’s all super configurable, and the process to get this setup is pretty simple. You can dive right into the links above, or read on for the details.

Install iTerm

The Console app on macOS is ok, but once you dig into what iTerm is capable of, there’s no going back.

If you don’t believe me, this is from the iTerm website :)

iTerm2 is a replacement for Terminal and the successor to iTerm. It works on Macs with macOS 10.12 or newer. iTerm2 brings the terminal into the modern age with features you never knew you always wanted.

Download and install instructions available here http://iterm.com

There are other alternatives as well (eg, Hyper), and a lot of the packages and utils mentioned here have ports for all the popular consoles, so don’t despair if iTerm isn’t for you.

Install Oh My Zsh

With iTerm installed, you have a working Zsh, but to fully exploit the command line, you need to get Oh My Zsh. Install instructions are here https://github.com/ohmyzsh/ohmyzsh

Again, from the website —

A delightful community-driven (with 1500+ contributors) framework for managing your zsh configuration. Includes 200+ optional plugins (rails, git, OSX, hub, capistrano, brew, ant, php, python, etc), over 140 themes to spice up your morning, and an auto-update tool so that makes it easy to keep up with the latest updates from the community.

Why would you not want it! Just don’t go crazy on the plugins, they can definitely impact performance.

Install Zsh Syntax Highlighting

One plugin you probably do want to install is Zsh Syntax Highlighting, which you can get from https://github.com/zsh-users/zsh-syntax-highlighting

From the website —

This package provides syntax highlighting for the shell zsh. It enables highlighting of commands whilst they are typed at a zsh prompt into an interactive terminal. This helps in reviewing commands before running them, particularly in catching syntax errors.

This package provides instant syntax highlighting in the console. As an example, you get instant feedback on whether the command you are typing is valid —

Zsh syntax highlighting in action

One feature of Oh My Zsh is the theme support. There are a lot. Like A LOT. Many of them include some form of support for Git status. Personally, I didn’t find one I liked, so I switched to the Pure terminal prompt. It’s fast, light weight and (I think) very easy on the eyes.

To install, follow the install instructions on the GitHub site, paying particular attention to the section on using Pure with Oh My Zsh.

The tl;dr —

  1. Install the Pure prompt with npm install — global pure-prompt
  2. Open your .zshrc and set ZSH_THEME="". This is important to allow the Pure prompt to work its magic.
  3. Still in your .zshrc , but somewhere after the source $ZSH/oh-my-zsh.sh line, include
autoload -U promptinit; promptinit
prompt pure

Pure prompt should be good to go as the default now.

Configure iTerm Colours and Fonts

If you’ve been following along and open an iTerm window, you’ll see that the colours aren’t great. To get the most out of the Pure prompt, get the Snazzy iTerm colours from https://github.com/sindresorhus/iterm2-snazzy and use the Colour Presets setting to load them.

Import colour preset into iTerm

Next, change the font to Menlo.

Change the default iTerm font to Menlo

If you open a terminal, things should be looking a lot nicer. But we’re not done! Now for the status bar.

Configure iTerm Status Bar

Before configuring the iTerm Status Bar components, make sure it’s enabled —

Enable iTerm’s Status Bar

Now configure the components you would like to see in the iTerm Status Bar. You can customise the colour (or choose Rainbow!) for each component.

Customise the iTerm Status Bar

That’s it! iTerm, Oh My Zsh and Pure all have a host of configuration options and plugins to try, so I’d encourage you to go look at their websites for more info and make that console experience your own!

Principal Consultant at Telstra Purple | PhD (Comp Sci) — Helping product teams solve real problems, building meaningful software supporting real business needs