Bootstrap your terminal environment in MacOS with a single Bash script

Stop worrying about what you need to install, start working on the actual problem

Eugene Obrezkov
Eugene Obrezkov
3 min readDec 18, 2017

--

The Problem

How often you face the issue with configuring your development environment? How often do you configure your terminal? Did you install Command Line Tools? What about Homebrew, don’t you forget to install it? Maybe, you forgot about some cool plugin for your shell and can’t find it?

This is the problem you usually face with clean MacOS install.

I am a developer like you. I do have this problem after re-installing the OS and I believe you have it too.

Some error in terminal, s**t, I forgot to install X…
How did that work before? Oh, I had plugin Y, but I don’t remember its name…
Who likes remembering all the fishy commands? I don’t…
Burn out my own eyes with a default theme and colors? No, thanks…
Navigating through plugin repository of your shell to find out all plugins you had
again? Haha, nope…

TL;DR

In case, you just want to check the script, here is the link.
https://github.com/ghaiklor/iterm-fish-fisherman-osx

Further content is the history, my motives, while creating the script.

Solution

It might sound silly, but write down all the steps, dependencies, plugins, etc… you install somewhere in notes or gist.

It was my solution before. I had a gist where I wrote down all the steps I need to do for setting up my glance terminal. You can take a look into it here.

And you know what? It has a huge amount of steps I need to do every time manually, while setting up my terminal environment: install Git, Homebrew, download iTerm, install color scheme and nerd font, download and configure shell and so on, and so on…

It’s boring, we need to fix that!

Automation is good, so long as you know exactly where to automate © Eliyahu Goldratt

Solution v2

What if, we do the same as before, but write down the steps in Bash script instead?

That’s how I came up with idea of creating a common Bash script that will do all the steps I do manually, but on its own.

GitHub repository was born, Gist updated with reference to newly created repo, initial commit with Bash script was created -> repository link.

Testing

Turns out, it worked perfect. Everything from my setup installed correctly.

I got my development environment just by executing Bash script with a single command in terminal (while drinking my coffee at the kitchen).

But, I didn’t like the idea of hardcoded steps, even when I do have some of required dependencies, i.e. Command Line Tools.

Why do I need to install something what I already have?

Solution v3

Bash script was improved with control flow instructions.

From now on, script could understand what you have installed and what not.

Do you have Command Line Tools installed? Ok, skip…
Do you have iTerm installed already? Ok, skip…
Do you want to have my color scheme or font? No, skip…

Modifications were done, script was published and tested out on my friends — works without any issues. Finita!

Do I need this script?

Well, you may ask this question to yourself and I’m going to give you the answer.

Do you work with terminal a lot, but too lazy to set it up? — Yes.
Is my setup fine for you and you like it? — Yes.
Do you have your own configuration? — Possibly, no.

What exactly am I setting up?

  • Command Line Tools (xcode-select — install)
  • Homebrew (ruby -e {HOMEBREW_INSTALLER})
  • iTerm2 (brew cask install iterm2)
  • Material design theme for iTerm2 and patched nerd fonts
  • Fish Shell (brew install fish)
  • Fisherman (curl -o ~/.config/fish/functions/fisher.fish {FISHERMAN})
  • 18 plugins for Fish (curl {MY_INSTALLER.sh} && ./MY_INSTALLER.sh)

Thanks

Thanks for reading. Please, share it with your friends who are frustrated with setting up environment.

Do you have any suggestions and ideas for further improvements? Please, ping me on Twitter or raise an issue in repo.

Eugene Obrezkov, Senior Software Engineer at @elastic.io, Kyiv, Ukraine.

--

--

Eugene Obrezkov
Eugene Obrezkov

Software Engineer · elastic.io · JavaScript · DevOps · Developer Tools · SDKs · Compilers · Operating Systems