The Best Setup for Your macOS Terminal, Ever.

Luckyboi
7 min readSep 25, 2021

--

Well, that’s a bold claim, but don’t believe me until you try it for yourself.

Final Result

Caveats

To be honest with you, I can’t say that I’m the specialist in this kind of topic, but with my direct experience using terminal every single day, and a kind of try-guy I am, I will share what I’m currently using with you.

Introduction

For this article, I’ll blindly assume that you are new to this, and I’ll walk you through every single installation and setup step, but if you are a veteran and just curious about what my best setup is, you can just skip to the end.

Homebrew

Homebrew (https://brew.sh)

For those of you who don’t know, Homebrew is a package manager for macOS, and as the name suggests, it allows you to install packages using command line.

To install Homebrew on your Mac, open up your terminal and paste

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

Follow the instruction on your screen, and voila! Homebrew will be installed on your computer.

iTerm

iTerm2 (https://iterm2.com)

Now for one of our stars today. iTerm2 is like a terminal with steroid to me, it is simple to use, yet so powerful when customized.

Installation

iTerm2 can be installed using brew that we’ve installed in the last step.

brew install --cask iterm2

The --cask is to indicate that we’re installing a cask (application) instead of a formula (package).

When the installation finished and you launch it for the first time, you’ll find this lovely iTerm window.

Greeting from iTerm2

Customization

As I’ve told you that iTerm is simple, it means that you can use as it is, but if you prefer to make it powerful (or beautiful), customization is the way to go.

Appearance

First thing for me is to set theme to Minimal because I like the way it looks. You can set it or explore other options by going to Preferences (⌘-,) > Appearance > General > Theme.

Minimal Theme

Next is to set rows and columns value. Personally, I like my terminal to fill the bottom half of my screen, so I set my numbers to 300 x 30 (Columns x Rows), and snap it to the bottom of my screen.

Columns and Rows

You can go to Preferences > Profiles > Windows and set columns and rows value as you like.

There are more…

But we’ll get back after I introduce you to our star.

Fish shell

Fish shell (https://fishshell.com)

Finally, you got to meet my star, Fish shell. If you just bought your Mac or just restored your machine, it is most likely that the shell you are using is zsh (read ‘see-shell’ or ‘sea-shell’), and I admit that it is much better than bash that got shipped with the old macOS, but still it is not the best.

Fish shell is a shell built with many awesome features ‘out of the box,’ such as autosuggestion, man page completion, syntax highlighting, etc. And when it was built with such features out of the box without need for plugins, it is blazingly fast.

But enough for the upselling, let’s get this thing installed.

Installation

brew install fish

This will install fish to the directory /usr/local/bin (this will come in handy later).

Then, we have to set our default shell to fish using

# adding fish to the list of allowed shells
sudo zsh -c 'echo "/usr/local/bin/fish" >> /etc/shells'
# changing the default shell to fish
chsh -s /usr/local/bin/fish

and after you launch a new instance of terminal, you’ll notice a lovely welcome message.

Welcome message

There you have it, a freshly caught fish.

Fish basics features try on

  1. Autosuggestion: Try typing command, and it will suggest based on what you have typed before.
Autosuggestion

2. Man Page completion: Try using command with options like cat then press tab, it’ll provide you with possible options with description.

Man Page Completion

3. Syntax Highlighting: You can use any command (or wrong one), and it’ll highlight it to give you some context.

Syntax Highlighting

Customization

Like iTerm, fish is fully functional (and beyond) out of the box, but when combined with plugins, it’ll get more powerful.

Plugin Manager

First, we have to install a plugin manager to make our life easier managing plugins. My plugin manager of choice is Fisher.

curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher

Then, you can check if fisher was installed by running.

fisher

Prompt

There’s nothing wrong with default prompt, but I prefer a prompt that simply beautiful and functional, and hydro is that prompt.

fisher install jorgebucaran/hydro
Hydro prompt

You can find more details about customizing hydro in this repository.

But if you come from zsh with oh-my-zsh and you like it, you might prefer Tide or Oh-My-Fish.

Git Plugin

If you work with git everyday, this plugin will make your life much easier.

fisher install jhillyerd/plugin-git

This plugin is basically compilation of git aliases and abbreviations that will save some keystrokes for you when using git, like git commit -v -a --amend is now simply a gca!. You can hit enter to execute it (and watch it unfold to a full command for abbreviation).

Git Plugin

Plugin Bang Bang

Unlike any other shells, fish was not shipped with the ability to use !! or !$ to reuse previous command or arguments. This plugin will allow you to do exactly that.

fisher install oh-my-fish/plugin-bang-bang
Plugin Bang Bang

Z

z is a plugin to make directory jumping as easy as the plugin’s name.

fisher install jethrokuan/z

I can’t find any word to describe how cool this plugin is, so please watch the its magic unfold.

Z

Curated list of plugins

There are so many more awesome plugins for fish that’ll definitely make your life easier, if you are interested, you can check out Jorge Bucaran’s repository here.

Color Customization

After we are done with all the installation, I’m taking you to the realm of color customization.

iTerm Colors

If you want to use plain old boring iTerm default color that’s fine for me, but if you want to customize it as you want, visit https://iterm2colorschemes.com.

iterm2-color-schemes

This website is a list of popular iTerm’s color schemes to choose as you like. If you click on the color scheme’s name, it’ll show the XML file that you can download using anything you like, but personally I use curl to do the job.

curl -O https://raw.githubusercontent.com/mbadolato/iTerm2-Color-Schemes/master/schemes/${theme_name}.itermcolors

Then, you can set the color scheme by Preferences > Profiles > Colors > Color Presets > Import…

Color Scheme importing

Now, if you select the imported scheme, you’ll notice some color changes in your iTerm window.

But you might think, “hey, the text color is not changing, is this supposed to happen?”

The answer is yes. Fish has its own color scheme setting for the syntax highlighting stuff to work. So let’s get it customized too.

Fish Color Scheme

If you’re worrying that customizing fish color scheme is going to be complicated, and you have to work with CLI, you’re wrong because fish provides you with Graphical User Interface for customization. You can launch it by

fish_config

and it will open a browser window with something like this.

Fish Configuration

Now, you can choose the color scheme you like, preview it, and set it to your prompt. 🎉

My Setup

Theme

  • iTerm’s theme: Twilight
  • Fish theme: Lava

Plugins

  • jethrokuan/z
  • jorgebucaran/autopair.fish: auto pair parentheses and quotation marks
  • PatrickF1/fzf.fish: Fuzzy finder
  • jhillyerd/plugin-git
  • oh-my-fish/plugin-bang-bang
  • jorgebucaran/hydro

Final Words

There are many stuff you can play around with for both iTerm and Fish that I won’t be able (and I don’t want to) to cover it all in this article because, for me, the most fun part of doing these stuff is when I find something myself. Therefore, I don’t want to spoil that feeling for you. If you want to find out more about iTerm and Fish, I suggest you check their official website out.

If you like this article, and want some more content like this one, please consider sharing this article and subscribing, thanks a lot.

Credits

  • Jorge Buracan for Curated list of fish plugins, and some of the most awesome plugins he created himself.

--

--