How to seriously upgrade your Mac terminal (and even give it a Matrix theme)

A Blue Pill, a Red Pill and 3 Steps to Terminal Bliss

Marcus Gardiner
We’ve moved to freeCodeCamp.org/news
8 min readDec 23, 2017

--

Does your Mac Terminal currently look like this -> (in other words, it kinda sucks)?

Note to self: this does not make you feel like an all-powerful coding prodigy

Do you want it to look like this -> (or, ya know, badass)?

GIFs courtesy of Giphy images

Or more realistically -> (and actually more awesome)…like this?

The colour scheme is only one part of the awesomeness

Still looks badass, and it’s now usable and able to run a load of extra useful features that will save you time and make you feel like a next-level coder (whether or not you stick to the Matrix color scheme).

Now that I have your attention, let’s learn together.

My promise to you, dear reader, is that I will write in plain English as best I can to take you on this glorious fact-finding mission. I myself am at the beginning of my coding journey, but that does not mean we cannot accomplish great and important things (like avoiding actually learning how to code by working out how to make every damn thing look like the Matrix, and maybe accidentally learning something about code in the process).

For the uninitiated: what is Terminal on Mac?

Normally you clickity-click around your screen with a keyboard and mouse to do fun things on your computer. With Terminal (a normal application that comes with your Mac), you command your computer to do things instead using the power of typing on your keyboard.

These can be simple things like creating a new folder by typing “mkdir <foldername>”, up to all-powerful things like forcing your computer to make you a sandwich:

Disclaimer: your computer may not make you a sandwich.

Now that is cleared up, how do we make Terminal awesome?

The Blue Pill or the Red Pill…

As I am sure you expected in a blog post of loose and fast Matrix references, there are two choices. The blue pill is easy and you will be done lickety-split in less than three minutes. The red pill is more exciting, enthralling, and has a vastly higher ceiling — for which we will need to leverage far more of your precious neurons.

That red pill looks absolutely delicious, I bet it has a ton of Omega-3s

The Blue Pill

For the blue pill, here are some quick and easy steps to have your terminal make Neo proud:

[1] Open Terminal via the Spotlight search function
- Command ⌘ + Space, “Terminal”

[2] Open Terminal preferences: change profile to “Homebrew,” including on startup
- Terminal, Preferences, General -> New window with profile -> Homebrew
- Terminal, Preferences, Profiles -> Homebrew -> Click “Default” in the bottom left

[3] Restart Terminal

You should now have a niiiccceee Matrix-esque terminal, like the below:

Pretty sweet for almost no effort

That Blue Pill was delicious and easy. Now for the Red Pill.

The Red Pill

This is for the over-achievers, the crazy ones, the truth-seekers. After it, your terminal code won’t just look like the Matrix, it will do all-powerful things. You may never be the same coder again…

All it will take is three steps:
[1] Badassify your Terminal
[2] Make it Matrix
[3] Power-level your Terminal

Step 1 of 3: Badassify your terminal

First things first, we need to empower your terminal to do awesome things, including:

  • Installing iTerm: a better version of Terminal (check out the awesome features from splitting panes to intelligent search terminal searching by clicking here)
  • Changing shell from “bash” to the more flexible and powerful “zsh” (The shell is like the software your terminal application is running. It takes your keyboard commands in terminal and gives them to the computer to perform.)
  • Install “oh-my-zsh,” which will super-charge your zsh shell (that is, it is a community-driven framework for managing your zsh configuration)
  • Bonus powers: syntax highlighting (shows you whether your command will run before you run it) and z terminal navigation (makes navigating the terminal much faster by estimating the folder you want to switch to using “frecency”)

To empower your terminal with all the above, follow this excellent guide by Jilles Soeters: Baddassify your terminal and come back for Steps 2 and 3.

Glad to have you back

Now its time to take your newly-badassified terminal and fully ingest that Red Pill…

Step 2 of 3: Make it Matrix

Thankfully some kind soul (Robert Dempsey) has already exported a full Matrix color scheme for iTerm, so all we need to do is import it!

Of course if the Matrix color theme doesn’t take your fancy, feel free to use a default and skip to step 3!

[1] Download the color scheme code from this link and move the folder to an easy place to access
-
Click: “Download Zip”
- Create a folder on your Desktop called “iTermThemes”
- Move the file “matrix_color_scheme_iterm2” to the iTermThemes folder (not the whole folder, only the file)

[2] Open Terminal and change to the directory where you moved the file
- Use the change directory (cd) command to change to the folder where you have the file
cd Desktop/iTermThemes

[3] Now that you are in the correct directory (folder) in Terminal, copy paste the following code into Terminal to run it:
for f in *; do
THEME=$(basename "$f")
defaults write -app iTerm 'Custom Color Presets' -dict-add "$THEME" "$(cat "$f")"
done

This code runs through each of the color codes in the file (using “for…”)
and saves the result as “matrix_color_scheme_2” in the Custom colors in iTerm
(Example of a color: ‘Selected Text Color’ = { ‘Blue Component’ = ‘1.000000’; ‘Green Component’ = ‘1.000000’; ‘Red Component’ = ‘1.000000’)

[4] Update iTerm preferences to use the new Matrix color scheme
- iTerm2, Preferences, Profiles, Colors, Color Presets, “matrix_color_scheme_iterm2”

The spelling ‘Colors’ upsets me deeply as a born and raised Brit

Your Terminal should now feel like this:

Step 3 of 3: Power-level your terminal

There is more?! Indeed there is more, you want your terminal to be the talk of the town, right?

The next step is to pimp your terminal with Powerlevel9k by Ben Hilburn, giving it fancy symbols and customisable gizmos with an out-of-the-box configuration. These visual cues are actually super useful in saving space and understanding your live environment, like what directory you are in, what Git branch you are on, and even how long your code took to run.

Before we begin, some background knowledge:
- “Powerlevel9k” is a theme for Oh-My-Zsh
- For the symbols to appear properly, you also need to install a “Powerline font (a font that includes a set of symbols, like how wingdings has symbols, but with actual letters too)

Install Powerlevel9k theme for Oh-My-ZSH

[1] Copy this code into your terminal, which will clone the Powerlevel9k repository into your Oh-My-Zsh custom themes directory.

[2] You then need to choose this theme in Oh-My-Zsh by editing the profile file
[i] Open the profile file in the text editor “nano” by typing the following into your terminal:
nano ~/.zshrc

[ii] Find the part of the file with
ZSH_THEME="<theme_name>"
…and replace it with (important: no spaces)
ZSH_THEME="powerlevel9k/powerlevel9k"

Note: You can navigate around the “nano” text editor using your arrow keys and type straight into it (much easier than VIM, if you have ever used that!).

[iii] To save the change and exit the Nano text editor:
- Ctrl-x (i.e. ^x)
- Y (this saves the change)

Now… the final step

Install and select Powerline fonts

Installing the standard Powerline fonts is thankfully very easy!

[1] By running the following code, you will clone the Powerline repository to your computer and install the fonts all in one easy step (you can keep the comments in).

[2] Select a Powerline font in iTerm preferences
- iTerm, Preferences, Profiles, Text, Change Font, *Select Meslo LG M for Powerline*

All that is left is to FEEL THE POWER of your new Terminal

What if I told you… that this is only the beginning

I highly recommend continuing to play around with the powers of iTerm, Oh-My-Zsh and Powerlevel9k. It is a great practical way to learn more about Terminal while super-charging it.

There are a ton of settings, customisation options, and plugins so you can get your Terminal looking and behaving exactly as you want it to with a bunch of awesome features.

An easy win I found was adding the following code to your zshrc file. Type it into Terminal nano ~/.zshrc) just before the “ ZSH_Theme” line. This shortens the file-paths shown on each line and saves some room for your code itself.

Of course, you can also choose alternative colour schemes for your Terminal if your grow tired of green. Just know, you may upset Morpheus.

I hope you enjoy your new Badass Matrix Terminal and, if you enjoyed this blog post, (my first ever!), feel free to click ‘Follow’ and give me a few Claps by clicking the beautiful Medium claps button below 👏

Click here for my next post: “How to become a code-learning super NINJA”

--

--