Customising The Macbook Terminal


Why Even Bother customising your terminal

There is a alot of reasons for why you would want to customise your terminal. I think most often people will customise it to make it look a bit more cooler, or to set a personal touch on the tool, and i think it is a good idea to do it.

I think of it as when, you build your own computer, fix your own car, or renovate a room in your house. The way you relate to the projected you have committed to, studied on and completed is on a hole other level than, if you just bought a new computer or if you had a mechanic fix your car.

This releation can also be a key component for wanting to use this thing, you customised or created your self, much more.

One of my goals in my job as a sysadmin is to be able to manage almost all of my daily tasks through the terminal. The best way to do this is of course by using the terminal, and by making it sexy, and something i have configured and customised my self, i know i will be much more likely to use it and learn more about it, than if it was just the standard terminal.

Then there are of course also the tools which we will install, such as Homebrew(package manager), Autosuggestions(terminal intellisense) and Syntax Highlighting which will make you faster and better at using the terminal.

Installing Homebrew

Why you need Homebrew??

Hombrew is more or less the standard package manager for MacOS like you have APT on Ubuntu and Chocolatey on Windows. And we need a package from Homebrew later on to customise the terminal. Homebrew is also a great package manager for downloading tools and apps to your Mac.

To install Homebrew on MacOS go to the following site: https://brew.sh/
There you wil be prompted with a one-line script which will run through the entire process of installing Homebrew.

Copy the line:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

And paste it into your Terminal.

You will be prompted to enter your administrator password for the Macbook. Once you enter your password, the script will start the installation process. This can take a couple of minutes.

Once you see “Installation successfull” you are ready to use Homebrew.

Homebrew installation

Installing Iterm2

Iterm2 is a great terminal emulator for MacOS. Unlike the standard terminal you will be able to split the terminal fast and easy with some keyboard shortcuts, just like Terminator on Linux or the Windows Terminal.

To install Iterm2 you can either go to the following link: https://iterm2.com/ and press on the big “Download” button. Or you can utillize Homebrew we just installed.

To use Hombrew run the following command in a terminal:

brew install --cask iterm2

Now because i am on a M1 Macbook i will force the Iterm2 application to open with Rosetta 2. If you are on an Intel Macbook, you don’t need to do the following step

Force Iterm2 to open with Rosetta 2:

  • find the app in you applications folder and right click on it.
  • Click on “Get Info”
  • Check on “Open with Rosetta”
Setting Rosetta 2 as default

Installing Oh My Zsh

Oh My Zsh is a community-driven open source framework for managing your zsh configurations. This will be the framework we use to chose which theme and font the Terminal should have. You can read more about the project on: https://ohmyz.sh/

To Install the framework we can utillize a one-line curl command, which you can copy and paste into your Iterm2.

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

The command just takes a few seconds to run, and once it has finished the framework will be installed.

You should see the following screen in your terminal:

Oh My Zsh

Now if you ever want to Uninstall Oh My Zsh you can just run the following command from your home directory

uninstall_oh_my_zsh

Once Oh My Zsh is installed, it should have create the file .zshrc which is the config file for how your zsh shell will act and behave. Here you can configure things like specific themes or alias commands and, much more.

Installing and configuring Powerlevel10k theme for Oh My Zsh

first we need to dowload the Powerlevel10k. We can find the instructions and alot of info on the Theme by going to the Github page: https://github.com/romkatv/powerlevel10k#oh-my-zsh

But we only need to enter a one-line command into the terminal

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH\_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

This command will git clone the theme into your custom themes folder for Oh My Zsh:
~/.oh-my-zsh/custom/themes/powerlevel10k

Now before we set the theme we want to download the fonts and we are going with powerline fonts. The font i am installing here is called “Source Code Pro for Powerline”

To install the fonts go to the following link: https://github.com/powerline/fonts/blob/master/SourceCodePro/Source%20Code%20Pro%20for%20Powerline.otf and press the “Download” button.

Once downloaded open the .otf file and press “Install font”

Powerline Fonts

Now we just need to open the Iterm2 Preferences –> Profiles –> Font –> And chose “Source Code Pro for Powerline”

Iterm2 Fonts

Now we are ready to set the default theme.
We need to open and edit the .zshrc file. You can open it in any text editor. I am going to open it in Vim.

If you want to download and install Vim, you can use Homebrew:

brew install vim

Now in your .zshrc file find the line: “ZSH_THEME”

and enter the following: ZSH_THEME=”powerlevel10k/powerlevel10k”

Oh my zsh

Once you have modified the file. Save it, and completely close out of the Iterm2 application, and start it again.

When you open Iterm2 again you should be prompted with a powerlevel10k configurator wizzard

If you are not prompted with the wizzard you can run the following command:

p10k configure

The Powerlevel10k configurations wizzard is quiet easy to follow and it will be mostly up to your self how you want your terminal to look and feel. The most important thing is just that in the beginning og the wizzard it will show you som icons and ask you if the icons looks like a specific shape. If you don’t see any icons but instead just see a question mark, this means that you font’s has not been installed correct.

Go back in the guide and try installing the fonts again and be sure to completely restart the terminal before starting the “p10k configure” wizzard.

powerlevel10k configuration

Changing the Iterm Color Scheme

I like my terminal and editor and actually most UI’s to be in a flat color scheme. Quintin Watt has made a great flat color scheme for Iterm2. He also has a great tutorial on how to setup your terminal with Powerlevel10k: https://www.youtube.com/watch?v=D2PSsnqgBiw&t=1s

You can find his flat color iterm2 theme on his Github page: https://github.com/QuentinWatt/dark-flat-iterm-colors

iterm-flat colors

Now to download the file you can run the following command:

curl -o ~/Downloads/flat-colors.itermcolors https://raw.githubusercontent.com/QuentinWatt/dark-flat-iterm-colors/master/flat-colors.itermcolors

Once downloaded you just need to import the color scheme into Iterm.
Open Iterm –> Preferences –> Profiles –> colors –> color presets –> import the file.

iterm-flat colors

Installing zsh plugin: Autosuggestions and Syntax Highlighting

Two plugins i find very usefull is Autosuggestion which will create an intellisence-like experience in the terminal, and display suggestions for possible commands. The other plugin is Syntax Highlighting, which will colorise the commands to show you if it is a valid command or if the command will fail.

Autosuggestions:

Autosuggestions

Syntax Highlighting:

Syntax highlighting

Installing Autosuggestion

run the following command:

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

The we need to add the plugin in the .zshrc file

find the line: “plugins=()”, and add the following: plugins=(zsh-autosuggestions)

Restart the Iterm2 application.

Installing Syntax Highlighting

Syntax highlighting can be installed through Homebrew. Run the following command to Install:

brew install zsh-syntax-highlighting

Then we just need to add the following line at the end of the .zshrc file:

source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

now to active the plugin just run the following command in ther terminal:

source ~/.zshrc

this will re-activate the .zshrc configuration.

The final touch!

The last thing is purely for some terminal swag.

Macbook terminal

You can install a small application named neofetch, this application we can define in our .zshrc file to be called when ever you open a new terminal.

Start by downloading neofetch, by running the following command:

brew install neofetch

Then insert the line: neofetch in the .zshrc file. I entered the line, right below # User configurations

Now whenever you open the terminal, it will display the cool Apple logo.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies. By continuing to use this site, you accept our use of cookies.